Update web runtime externals (#32717)

As mentioned in https://github.com/vercel/next.js/pull/32679#discussion_r773357113 it looks like these externals need to be updated to the compiled path not that they are ncc'd. Also updated the test readme a bit to reduce confusion in https://github.com/vercel/next.js/issues/32367#issuecomment-997969759
This commit is contained in:
JJ Kasper 2021-12-21 20:34:36 -06:00 committed by GitHub
parent 9b2c079680
commit b6fb52bbb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 15 deletions

View file

@ -968,7 +968,13 @@ export default async function getBaseWebpackConfig(
[
'next',
...(webServerRuntime
? [{ etag: '{}', chalk: '{}', 'react-dom': '{}' }]
? [
{
'next/dist/compiled/etag': '{}',
'next/dist/compiled/chalk': '{}',
'react-dom': '{}',
},
]
: []),
]
: !isServerless

File diff suppressed because one or more lines are too long

View file

@ -206,17 +206,6 @@ export async function ncc_chalk(task, opts) {
.source(opts.src || relative(__dirname, require.resolve('chalk')))
.ncc({ packageName: 'chalk', externals })
.target('compiled/chalk')
const content = fs.readFileSync(
join(__dirname, 'compiled/chalk/index.js'),
'utf8'
)
// ensure undefined process.argv is handled for web runtime
// TODO: should chalk be being included in web runtime?
fs.writeFileSync(
join(__dirname, 'compiled/chalk/index.js'),
content.replace('process.argv', 'process.argv||[]')
)
}
// eslint-disable-next-line camelcase

View file

@ -5,12 +5,12 @@
- e2e: These tests will run against `next dev` and `next start`
- development: These tests only run against `next dev`
- production: These tests will run against `next start`.
- integration: These tests run misc checks and modes and is where tests used to be added before we added more specific folders. We **should not** add any more tests here.
- integration: These tests run misc checks and modes and is where tests used to be added before we added more specific folders. Ideally we don't add new test suites here as tests here are not isolated from the monorepo.
- unit: These are very fast tests that should run without a browser or running next and should be testing a specific utility.
For the e2e, production, and development tests the `createNext` utility should be used and an example is available [here](./e2e/example.test.txt). This creates an isolated Next.js install to ensure nothing in the monorepo is relied on accidentally causing incorrect tests.
All new tests should be written in TypeScript either `.ts` (or `.tsx` for unit tests). This will help ensure we catch smaller issues in tests that could cause flakey or incorrect tests.
All new test suites should be written in TypeScript either `.ts` (or `.tsx` for unit tests). This will help ensure we catch smaller issues in tests that could cause flakey or incorrect tests.
## Best practices