Skip to content

Commit 66d3cf9

Browse files
committedNov 21, 2023
fix: force module(resolution)
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
1 parent 02e33d2 commit 66d3cf9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/transformers/typescript.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,13 @@ function getCompilerOptions({
288288

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

0 commit comments

Comments
 (0)
Please sign in to comment.