Unverified Commit 1a0b5d25 authored by Steven's avatar Steven Committed by GitHub

fix: `moduleResolution: bundler` support in tsconfig.json (#51065)

- Fixes https://github.com/vercel/next.js/issues/47858
- Closes https://github.com/vercel/next.js/pull/50289

fix #47858
fix NEXT-1281
Co-authored-by: 's avatarKevin Wolf <3157426+kevinwolfcr@users.noreply.github.com>
parent 90ee9589
......@@ -69,6 +69,7 @@ function getDesiredCompilerOptions(
(ts.ModuleResolutionKind as any).Node12,
ts.ModuleResolutionKind.Node16,
ts.ModuleResolutionKind.NodeNext,
ts.ModuleResolutionKind.Bundler,
].filter((val) => typeof val !== 'undefined'),
value: 'node',
reason: 'to match webpack resolution',
......
......@@ -354,6 +354,62 @@ describe('tsconfig.json verifier', () => {
`)
})
it('allows you to set bundler moduleResolution mode', async () => {
expect(await exists(tsConfig)).toBe(false)
await writeFile(
tsConfig,
`{ "compilerOptions": { "esModuleInterop": false, "moduleResolution": "bundler" } }`
)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code, stderr, stdout } = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
})
expect(stderr + stdout).not.toContain('moduleResolution')
expect(code).toBe(0)
expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
"{
\\"compilerOptions\\": {
\\"esModuleInterop\\": true,
\\"moduleResolution\\": \\"bundler\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
\\"esnext\\"
],
\\"allowJs\\": true,
\\"skipLibCheck\\": true,
\\"strict\\": false,
\\"forceConsistentCasingInFileNames\\": true,
\\"noEmit\\": true,
\\"incremental\\": true,
\\"module\\": \\"esnext\\",
\\"resolveJsonModule\\": true,
\\"isolatedModules\\": true,
\\"jsx\\": \\"preserve\\",
\\"plugins\\": [
{
\\"name\\": \\"next\\"
}
],
\\"strictNullChecks\\": true
},
\\"include\\": [
\\"next-env.d.ts\\",
\\".next/types/**/*.ts\\",
\\"**/*.ts\\",
\\"**/*.tsx\\"
],
\\"exclude\\": [
\\"node_modules\\"
]
}
"
`)
})
it('allows you to set target mode', async () => {
expect(await exists(tsConfig)).toBe(false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment