Skip to content

Commit 4dd3c84

Browse files
Copilotalexr00
andcommitted
Fix: Include test files in TypeScript checking for webpack builds
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent f87bcf0 commit 4dd3c84

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

webpack.config.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ async function getWebviewConfig(mode, env, entry) {
157157
async function getExtensionConfig(target, mode, env) {
158158
const basePath = path.join(__dirname, 'src');
159159

160+
const entry = {
161+
extension: './src/extension.ts',
162+
};
163+
if (target === 'webworker') {
164+
entry['test/index'] = './src/test/browser/index.ts';
165+
} else if (target === 'node') {
166+
entry['test/index'] = './src/test/index.ts';
167+
}
168+
169+
// Determine if we're building tests and choose the appropriate TypeScript config
170+
const hasTestEntry = 'test/index' in entry;
171+
let tsConfigFile;
172+
if (hasTestEntry) {
173+
// When building tests, use a config that includes test files
174+
tsConfigFile = target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.test.json';
175+
} else {
176+
// When building only extension, use standard configs
177+
tsConfigFile = target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json';
178+
}
179+
160180
/**
161181
* @type WebpackConfig['plugins'] | any
162182
*/
@@ -168,7 +188,8 @@ async function getExtensionConfig(target, mode, env) {
168188
async: false,
169189
formatter: 'basic',
170190
typescript: {
171-
configFile: path.join(__dirname, target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json'),
191+
configFile: path.join(__dirname, tsConfigFile),
192+
mode: 'write-tsbuildinfo'
172193
},
173194
}),
174195
new webpack.ContextReplacementPlugin(/mocha/, /^$/)
@@ -187,15 +208,6 @@ async function getExtensionConfig(target, mode, env) {
187208
}));
188209
}
189210

190-
const entry = {
191-
extension: './src/extension.ts',
192-
};
193-
if (target === 'webworker') {
194-
entry['test/index'] = './src/test/browser/index.ts';
195-
} else if (target === 'node') {
196-
entry['test/index'] = './src/test/index.ts';
197-
}
198-
199211
return {
200212
name: `extension:${target}`,
201213
entry,

0 commit comments

Comments
 (0)