Skip to content

Commit 9426115

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 44adf5f commit 9426115

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/compiler/transpile/run-program.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ 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') ||
51-
emitFilePath === 'e2e.d.ts' ||
52-
emitFilePath === 'spec.d.ts'
46+
if (
47+
emitFilePath.includes('e2e.') ||
48+
emitFilePath.includes('spec.') ||
49+
emitFilePath.endsWith('e2e.d.ts') ||
50+
emitFilePath.endsWith('spec.d.ts') ||
5351
) {
5452
// we don't want to write these to disk!
5553
return;
54+
}
55+
56+
if (emitFilePath.endsWith('.js') || emitFilePath.endsWith('js.map')) {
57+
updateModule(config, compilerCtx, buildCtx, tsSourceFiles[0], data, emitFilePath, tsTypeChecker, null);
5658
} else if (emitFilePath.endsWith('.d.ts')) {
5759
const srcDtsPath = normalizePath(tsSourceFiles[0].fileName);
5860
const relativeEmitFilepath = getRelativeDts(config, srcDtsPath, emitFilePath);

0 commit comments

Comments
 (0)