Skip to content

Commit 29fcf57

Browse files
fix(emit): don't emit test files
This fixes a bug introduced in #4315, which upgraded to TypeScript 5. In that PR we had to change the way that we prevented certain files from being emitted by the typescript compiler because in the 5.0 release our previous approach stopped working. However, in porting over to a new approach that worked with TS 5.0 there was an oversight. I misunderstood the intent of the old code as being to merely prevent writing `.d.ts` files in the output, when actually it was about preventing the compiled JavaScript from being written for `.e2e.ts` and `.spec.ts` files. This change ensures that we no longer emit these files. fixes #5788 STENCIL-1325
1 parent 5f4fcfa commit 29fcf57

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/compiler/transpile/run-program.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ export const runTsProgram = async (
4343
const typesOutputTarget = config.outputTargets.filter(isOutputTargetDistTypes);
4444
const emittedDts: string[] = [];
4545
const emitCallback: ts.WriteFileCallback = (emitFilePath, data, _w, _e, tsSourceFiles) => {
46-
if (emitFilePath.endsWith('.js') || emitFilePath.endsWith('js.map')) {
47-
updateModule(config, compilerCtx, buildCtx, tsSourceFiles[0], data, emitFilePath, tsTypeChecker, null);
48-
} else if (
49-
emitFilePath.endsWith('.e2e.d.ts') ||
50-
emitFilePath.endsWith('.spec.d.ts') ||
46+
if (
47+
emitFilePath.includes('.e2e.') ||
48+
emitFilePath.includes('/e2e.') ||
49+
emitFilePath.includes('.spec.') ||
50+
emitFilePath.endsWith('/spec.') ||
5151
emitFilePath === 'e2e.d.ts' ||
5252
emitFilePath === 'spec.d.ts'
5353
) {
5454
// we don't want to write these to disk!
5555
return;
56+
}
57+
58+
if (emitFilePath.endsWith('.js') || emitFilePath.endsWith('js.map')) {
59+
updateModule(config, compilerCtx, buildCtx, tsSourceFiles[0], data, emitFilePath, tsTypeChecker, null);
5660
} else if (emitFilePath.endsWith('.d.ts')) {
5761
const srcDtsPath = normalizePath(tsSourceFiles[0].fileName);
5862
const relativeEmitFilepath = getRelativeDts(config, srcDtsPath, emitFilePath);

0 commit comments

Comments
 (0)