Skip to content

Commit d6fb79b

Browse files
committed
fix: include .vue files as the project root files
Closes: #452
1 parent ad0eac9 commit d6fb79b

File tree

6 files changed

+51
-37
lines changed

6 files changed

+51
-37
lines changed

src/typescript-reporter/extension/TypeScriptEmbeddedExtension.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,40 @@ function createTypeScriptEmbeddedExtension({
130130
fileExists: createEmbeddedFileExists(host.fileExists),
131131
};
132132
},
133+
extendParseConfigFileHost<THost extends ts.ParseConfigFileHost>(host: THost): THost {
134+
return {
135+
...host,
136+
readDirectory(
137+
rootDir: string,
138+
extensions: readonly string[],
139+
excludes: readonly string[] | undefined,
140+
includes: readonly string[],
141+
depth?: number
142+
): readonly string[] {
143+
return host
144+
.readDirectory(
145+
rootDir,
146+
[...extensions, ...embeddedExtensions],
147+
excludes,
148+
includes,
149+
depth
150+
)
151+
.map((fileName) => {
152+
const isEmbeddedFile = embeddedExtensions.some((embeddedExtension) =>
153+
fileName.endsWith(embeddedExtension)
154+
);
155+
156+
if (isEmbeddedFile) {
157+
const embeddedSource = getCachedEmbeddedSource(fileName);
158+
159+
return embeddedSource ? `${fileName}${embeddedSource.extension}` : fileName;
160+
} else {
161+
return fileName;
162+
}
163+
});
164+
},
165+
};
166+
},
133167
};
134168
}
135169

src/typescript-reporter/extension/TypeScriptExtension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface TypeScriptHostExtension {
2020
host: THost,
2121
parsedCommandLine?: ts.ParsedCommandLine
2222
): THost;
23+
extendParseConfigFileHost?<THost extends ts.ParseConfigFileHost>(host: THost): THost;
2324
}
2425

2526
interface TypeScriptReporterExtension {

src/typescript-reporter/reporter/TypeScriptReporter.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,25 @@ function createTypeScriptReporter(configuration: TypeScriptReporterConfiguration
115115
if (!parsedConfiguration) {
116116
const parseConfigurationDiagnostics: ts.Diagnostic[] = [];
117117

118+
let parseConfigFileHost: ts.ParseConfigFileHost = {
119+
...system,
120+
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
121+
parseConfigurationDiagnostics.push(diagnostic);
122+
},
123+
};
124+
125+
extensions.forEach((extension) => {
126+
if (extension.extendParseConfigFileHost) {
127+
parseConfigFileHost = extension.extendParseConfigFileHost(parseConfigFileHost);
128+
}
129+
});
130+
118131
performance.markStart('Parse Configuration');
119132
parsedConfiguration = parseTypeScriptConfiguration(
120133
configuration.configFile,
121134
configuration.context,
122135
configuration.configOverwrite,
123-
{
124-
...system,
125-
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
126-
parseConfigurationDiagnostics.push(diagnostic);
127-
},
128-
}
136+
parseConfigFileHost
129137
);
130138
performance.markEnd('Parse Configuration');
131139

test/e2e/TypeScriptVueExtension.spec.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@ describe('TypeScript Vue Extension', () => {
6161
]);
6262

6363
if (vue === '^2.6.11') {
64-
await sandbox.write(
65-
'src/index.ts',
66-
[
67-
"import Vue from 'vue'",
68-
"import App from './App.vue'",
69-
'',
70-
'new Vue({',
71-
' render: h => h(App)',
72-
"}).$mount('#app')",
73-
].join('\n')
74-
);
7564
await sandbox.write(
7665
'src/vue-shim.d.ts',
7766
[
@@ -82,15 +71,6 @@ describe('TypeScript Vue Extension', () => {
8271
].join('\n')
8372
);
8473
} else {
85-
await sandbox.write(
86-
'src/index.ts',
87-
[
88-
"import { createApp } from 'vue'",
89-
"import App from './App.vue'",
90-
'',
91-
"createApp(App).mount('#app')",
92-
].join('\n')
93-
);
9474
await sandbox.write('src/vue-shim.d.ts', 'declare module "*.vue";');
9575
}
9676

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
"importsNotUsedAsValues": "preserve"
4141
},
4242
"include": [
43-
"src/**/*.ts",
44-
"src/**/*.vue"
43+
"src",
4544
],
4645
"exclude": [
4746
"node_modules"
@@ -62,7 +61,7 @@ try {
6261
}
6362

6463
module.exports = {
65-
entry: './src/index.ts',
64+
entry: './src/App.vue',
6665
output: {
6766
filename: 'index.js',
6867
path: path.resolve(__dirname, 'dist'),

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
/// src/index.ts
2-
import Vue from 'vue'
3-
import App from './App.vue'
4-
5-
new Vue({
6-
render: h => h(App)
7-
}).$mount('#app')
8-
91
/// src/App.vue
102
<template>
113
<logged-in v-if="user" :user="user" @logout="logout"></logged-in>

0 commit comments

Comments
 (0)