diff --git a/packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts b/packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts index 3f1effbd04ac6efb6597fbffdd190dc2a3c0d647..e9e4db9821120df64faa816cb8e78f8954a096e1 100644 --- a/packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts +++ b/packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts @@ -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(' ')} - `) } ) } diff --git a/test/integration/jsconfig-baseurl/test/index.test.js b/test/integration/jsconfig-baseurl/test/index.test.js index ec516f7766ac8753a58f81ea156d9b14aac49d7f..095bbae98324db91fc81cc267347aecbd40363d5 100644 --- a/test/integration/jsconfig-baseurl/test/index.test.js +++ b/test/integration/jsconfig-baseurl/test/index.test.js @@ -1,8 +1,15 @@ /* 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` + ) + }) }) }) diff --git a/test/integration/jsconfig-paths/test/index.test.js b/test/integration/jsconfig-paths/test/index.test.js index d7fd31aa92f8658f3b221c29fc631fc6e1ff2a25..fa02370a8f8f9c862963ffeb9e0d3d6909e1be90 100644 --- a/test/integration/jsconfig-paths/test/index.test.js +++ b/test/integration/jsconfig-paths/test/index.test.js @@ -1,8 +1,15 @@ /* 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`) + }) }) })