Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly handle import modules with .vue suffix #420

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions src/typescript-reporter/extension/TypeScriptEmbeddedExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,10 @@ function createTypeScriptEmbeddedExtension({
type FileExists = (fileName: string) => boolean;
function createEmbeddedFileExists(fileExists: FileExists): FileExists {
return function embeddedFileExists(fileName) {
const { embeddedExtension, embeddedFileName, extension } = parsePotentiallyEmbeddedFileName(
fileName
);

if (embeddedExtensions.includes(embeddedExtension)) {
const embeddedSource = getCachedEmbeddedSource(embeddedFileName);
const { embeddedExtension, embeddedFileName } = parsePotentiallyEmbeddedFileName(fileName);

// we return true only if file extension matches extension returned by the getEmbeddedSource method.
// we assume that there is a regular TypeScript resolveModuleName implementation that runs fileExists
// for files with all TypeScript supported extensions (.ts, .d.ts, .tsx, .js)
if (embeddedSource && embeddedSource.extension === extension) {
// already checked if file exists in the getEmbeddedSource call.
// we can assume that file still exists because we are relying on the watch mechanism
// which removes cache entry on any file change
return true;
}
if (embeddedExtensions.includes(embeddedExtension) && fileExists(embeddedFileName)) {
return true;
}

return fileExists(fileName);
Expand Down
1 change: 1 addition & 0 deletions test/e2e/fixtures/environment/typescript-vue.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typescript": ${TYPESCRIPT_VERSION},
"vue-loader": "^15.8.3",
"vue-template-compiler": "^2.6.11",
"qrcode.vue": "^1.7.0",
"webpack": ${WEBPACK_VERSION},
"webpack-cli": ${WEBPACK_CLI_VERSION},
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/fixtures/implementation/typescript-vue.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ export default class App extends Vue {
<input v-model="email" name="email" type="email" />
<input v-model="password" name="password" type="password" />

<qrcode-vue :value="url"></qrcode-vue>

<button type="submit" v-bind:disabled="pending">Login</button>
</form>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import QrcodeVue from "qrcode.vue";

@Component
export default class LoginForm extends Vue {
public email = '';
public password = '';
public pending = false;
public url = 'http://my-site.com/login';

async login() {
try {
Expand Down