Unverified Commit f6c96e05 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix incorrect build log for moduleResolution (#39991)

Removes extra log shown when checking `moduleResolution` in
`tsconfig.json` and adds regression test.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
parent 6da621df
......@@ -90,9 +90,6 @@ export function getRequiredConfiguration(
const desiredCompilerOptions = getDesiredCompilerOptions(ts)
for (const optionKey of Object.keys(desiredCompilerOptions)) {
const ev = desiredCompilerOptions[optionKey]
if (optionKey === 'moduleResolution') {
console.log({ optionKey, ev, current: res[optionKey] })
}
if (!('value' in ev)) {
continue
}
......
......@@ -22,7 +22,7 @@ describe('correct tsconfig.json defaults', () => {
})
afterAll(() => next.destroy())
it('should add `moduleResoution` when generating tsconfig.json in dev', async () => {
it('should add `moduleResolution` when generating tsconfig.json in dev', async () => {
const tsconfigPath = path.join(next.testDir, 'tsconfig.json')
expect(fs.existsSync(tsconfigPath)).toBeFalse()
......@@ -33,9 +33,28 @@ describe('correct tsconfig.json defaults', () => {
expect(fs.existsSync(tsconfigPath)).toBeTrue()
const tsconfig = JSON.parse(await next.readFile('tsconfig.json'))
expect(next.cliOutput).not.toContain('moduleResolution')
expect(tsconfig.compilerOptions).toEqual(
expect.objectContaining({ moduleResolution: 'node' })
)
})
it('should not warn for `moduleResolution` when already present and valid', async () => {
const tsconfigPath = path.join(next.testDir, 'tsconfig.json')
expect(fs.existsSync(tsconfigPath)).toBeTrue()
await next.start()
await waitFor(1000)
await next.stop()
expect(fs.existsSync(tsconfigPath)).toBeTrue()
const tsconfig = JSON.parse(await next.readFile('tsconfig.json'))
expect(tsconfig.compilerOptions).toEqual(
expect.objectContaining({ moduleResolution: 'node' })
)
expect(next.cliOutput).not.toContain('moduleResolution')
})
})
......@@ -65,7 +65,11 @@ describe('tsconfig.json verifier', () => {
await new Promise((resolve) => setTimeout(resolve, 500))
expect(await readFile(tsConfig, 'utf8')).toBe('')
const { code } = await nextBuild(appDir)
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(`
......@@ -272,7 +276,11 @@ describe('tsconfig.json verifier', () => {
`{ "compilerOptions": { "esModuleInterop": false, "moduleResolution": "node12" } }`
)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code } = await nextBuild(appDir)
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(`
......@@ -354,7 +362,11 @@ describe('tsconfig.json verifier', () => {
await writeFile(tsConfig, `{ "extends": "./tsconfig.base.json" }`)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code } = await nextBuild(appDir)
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(
......@@ -405,7 +417,11 @@ describe('tsconfig.json verifier', () => {
await writeFile(tsConfig, `{ "extends": "./tsconfig.base.json" }`)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code } = await nextBuild(appDir)
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(`
......
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