Skip to content

Commit

Permalink
fix: force module(resolution)
Browse files Browse the repository at this point in the history
transpileModule treats NodeNext as CommonJS because it doesn't read the package.json. Also see microsoft/TypeScript#53022 (the filename workaround doesn't work). Related to sveltejs/kit#11086
  • Loading branch information
dummdidumm committed Nov 21, 2023
1 parent 02e33d2 commit 66d3cf9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/transformers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ function getCompilerOptions({

const compilerOptions: CompilerOptions = {
target: ts.ScriptTarget.ES2015,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
...(convertedCompilerOptions as CompilerOptions),
// force module(resolution) to esnext and a compatible moduleResolution. Reason:
// transpileModule treats NodeNext as CommonJS because it doesn't read the package.json.
// Also see https://github.com/microsoft/TypeScript/issues/53022 (the filename workaround doesn't work).
module: ts.ModuleKind.ESNext,
moduleResolution:
ts.ModuleResolutionKind.NodeJs ?? ts.ModuleResolutionKind.Node10, // in case the first option every goes away
allowNonTsExtensions: true,
// Clear outDir since it causes source map issues when the files aren't actually written to disk.
outDir: undefined,
Expand Down

0 comments on commit 66d3cf9

Please sign in to comment.