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

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
parent 9b2c0796
...@@ -968,7 +968,13 @@ export default async function getBaseWebpackConfig( ...@@ -968,7 +968,13 @@ export default async function getBaseWebpackConfig(
[ [
'next', 'next',
...(webServerRuntime ...(webServerRuntime
? [{ etag: '{}', chalk: '{}', 'react-dom': '{}' }] ? [
{
'next/dist/compiled/etag': '{}',
'next/dist/compiled/chalk': '{}',
'react-dom': '{}',
},
]
: []), : []),
] ]
: !isServerless : !isServerless
......
This diff is collapsed.
...@@ -206,17 +206,6 @@ export async function ncc_chalk(task, opts) { ...@@ -206,17 +206,6 @@ export async function ncc_chalk(task, opts) {
.source(opts.src || relative(__dirname, require.resolve('chalk'))) .source(opts.src || relative(__dirname, require.resolve('chalk')))
.ncc({ packageName: 'chalk', externals }) .ncc({ packageName: 'chalk', externals })
.target('compiled/chalk') .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 // eslint-disable-next-line camelcase
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
- e2e: These tests will run against `next dev` and `next start` - e2e: These tests will run against `next dev` and `next start`
- development: These tests only run against `next dev` - development: These tests only run against `next dev`
- production: These tests will run against `next start`. - 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. - 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. 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 ## Best practices
......
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