Skip to content

Commit

Permalink
fix(emit): don't emit test files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alicewriteswrongs committed May 22, 2024
1 parent 5f4fcfa commit 29fcf57
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/compiler/transpile/run-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ export const runTsProgram = async (
const typesOutputTarget = config.outputTargets.filter(isOutputTargetDistTypes);
const emittedDts: string[] = [];
const emitCallback: ts.WriteFileCallback = (emitFilePath, data, _w, _e, tsSourceFiles) => {
if (emitFilePath.endsWith('.js') || emitFilePath.endsWith('js.map')) {
updateModule(config, compilerCtx, buildCtx, tsSourceFiles[0], data, emitFilePath, tsTypeChecker, null);
} else if (
emitFilePath.endsWith('.e2e.d.ts') ||
emitFilePath.endsWith('.spec.d.ts') ||
if (
emitFilePath.includes('.e2e.') ||
emitFilePath.includes('/e2e.') ||
emitFilePath.includes('.spec.') ||
emitFilePath.endsWith('/spec.') ||
emitFilePath === 'e2e.d.ts' ||
emitFilePath === 'spec.d.ts'
) {
// we don't want to write these to disk!
return;
}

if (emitFilePath.endsWith('.js') || emitFilePath.endsWith('js.map')) {
updateModule(config, compilerCtx, buildCtx, tsSourceFiles[0], data, emitFilePath, tsTypeChecker, null);
} else if (emitFilePath.endsWith('.d.ts')) {
const srcDtsPath = normalizePath(tsSourceFiles[0].fileName);
const relativeEmitFilepath = getRelativeDts(config, srcDtsPath, emitFilePath);
Expand Down

0 comments on commit 29fcf57

Please sign in to comment.