Skip to content

Commit cfcc0fe

Browse files
authored
fix: properly handle import modules with .vue suffix (#420)
Closes: #416
1 parent 1ff3ce4 commit cfcc0fe

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/typescript-reporter/extension/TypeScriptEmbeddedExtension.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,10 @@ function createTypeScriptEmbeddedExtension({
5050
type FileExists = (fileName: string) => boolean;
5151
function createEmbeddedFileExists(fileExists: FileExists): FileExists {
5252
return function embeddedFileExists(fileName) {
53-
const { embeddedExtension, embeddedFileName, extension } = parsePotentiallyEmbeddedFileName(
54-
fileName
55-
);
56-
57-
if (embeddedExtensions.includes(embeddedExtension)) {
58-
const embeddedSource = getCachedEmbeddedSource(embeddedFileName);
53+
const { embeddedExtension, embeddedFileName } = parsePotentiallyEmbeddedFileName(fileName);
5954

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

7159
return fileExists(fileName);

test/e2e/fixtures/environment/typescript-vue.fixture

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"typescript": ${TYPESCRIPT_VERSION},
1919
"vue-loader": "^15.8.3",
2020
"vue-template-compiler": "^2.6.11",
21+
"qrcode.vue": "^1.7.0",
2122
"webpack": ${WEBPACK_VERSION},
2223
"webpack-cli": ${WEBPACK_CLI_VERSION},
2324
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}

test/e2e/fixtures/implementation/typescript-vue.fixture

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ export default class App extends Vue {
4141
<input v-model="email" name="email" type="email" />
4242
<input v-model="password" name="password" type="password" />
4343

44+
<qrcode-vue :value="url"></qrcode-vue>
45+
4446
<button type="submit" v-bind:disabled="pending">Login</button>
4547
</form>
4648
</template>
4749

4850
<script lang="ts">
4951
import Vue from "vue";
5052
import Component from "vue-class-component";
53+
import QrcodeVue from "qrcode.vue";
5154

5255
@Component
5356
export default class LoginForm extends Vue {
5457
public email = '';
5558
public password = '';
5659
public pending = false;
60+
public url = 'http://my-site.com/login';
5761

5862
async login() {
5963
try {

0 commit comments

Comments
 (0)