未验证 提交 2b116cea 编写于 作者: J JJ Kasper 提交者: GitHub

Ensure module not found error is shown with jsconfig paths (#11889)

* Ensure correct module not found error is shown with jsconfig paths

* bump
上级 67e6cae4
......@@ -204,11 +204,6 @@ export class JsConfigPathsPlugin implements ResolvePlugin {
return result
}
throw new Error(`
Request "${moduleName}" matched tsconfig.json or jsconfig.json "paths" pattern ${matchedPatternText} but could not be resolved.
Tried paths: ${triedPaths.join(' ')}
`)
}
)
}
......
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { join } from 'path'
import cheerio from 'cheerio'
import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils'
import {
renderViaHTTP,
findPort,
launchApp,
killApp,
waitFor,
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
......@@ -17,9 +24,18 @@ async function get$(path, query) {
describe('TypeScript Features', () => {
describe('default behavior', () => {
let output = ''
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {})
app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg || ''
},
onStderr(msg) {
output += msg || ''
},
})
})
afterAll(() => killApp(app))
......@@ -27,5 +43,22 @@ describe('TypeScript Features', () => {
const $ = await get$('/hello')
expect($('body').text()).toMatch(/World/)
})
it('should have correct module not found error', async () => {
const basicPage = join(appDir, 'pages/hello.js')
const contents = await fs.readFile(basicPage, 'utf8')
await fs.writeFile(
basicPage,
contents.replace('components/world', 'components/worldd')
)
await renderViaHTTP(appPort, '/hello')
await waitFor(2 * 1000)
await fs.writeFile(basicPage, contents)
expect(output).toContain(
`Module not found: Can't resolve 'components/worldd' in`
)
})
})
})
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { join } from 'path'
import cheerio from 'cheerio'
import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils'
import {
renderViaHTTP,
findPort,
launchApp,
killApp,
waitFor,
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
......@@ -17,9 +24,18 @@ async function get$(path, query) {
describe('TypeScript Features', () => {
describe('default behavior', () => {
let output = ''
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {})
app = await launchApp(appDir, appPort, {
onStderr(msg) {
output += msg || ''
},
onStdout(msg) {
output += msg || ''
},
})
})
afterAll(() => killApp(app))
......@@ -42,5 +58,17 @@ describe('TypeScript Features', () => {
const $ = await get$('/single-alias')
expect($('body').text()).toMatch(/Hello/)
})
it('should have correct module not found error', async () => {
const basicPage = join(appDir, 'pages/basic-alias.js')
const contents = await fs.readFile(basicPage, 'utf8')
await fs.writeFile(basicPage, contents.replace('@c/world', '@c/worldd'))
await renderViaHTTP(appPort, '/basic-alias')
await waitFor(2 * 1000)
await fs.writeFile(basicPage, contents)
expect(output).toContain(`Module not found: Can't resolve '@c/worldd' in`)
})
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册