Skip to content

Commit

Permalink
fix(emit): don't emit test files (#5789)
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 authored Jun 4, 2024
1 parent 44adf5f commit 50892f1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/compiler/transpile/run-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ 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') ||
emitFilePath === 'e2e.d.ts' ||
emitFilePath === 'spec.d.ts'
if (
emitFilePath.includes('e2e.') ||
emitFilePath.includes('spec.') ||
emitFilePath.endsWith('e2e.d.ts') ||
emitFilePath.endsWith('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 50892f1

Please sign in to comment.