Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into fix/trace-conditi…
Browse files Browse the repository at this point in the history
…onal-alias

# Conflicts:
#	packages/next/build/webpack-config.ts
#	test/integration/production/test/index.test.js
  • Loading branch information
ijjk committed Oct 6, 2021
2 parents 6aeccbf + aa8a885 commit a342bed
Show file tree
Hide file tree
Showing 63 changed files with 580 additions and 107,103 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -304,33 +304,6 @@ jobs:
steps:
- run: exit 0

testLegacyWebpack:
name: Webpack 4 (Basic, Production, Acceptance)
runs-on: ubuntu-latest
needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
NEXT_PRIVATE_TEST_WEBPACK4_MODE: 1

steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- run: node run-tests.js test/development/acceptance/{ReactRefresh,ReactRefreshLogBox-app-doc,ReactRefreshLogBox-scss,ReactRefreshLogBox,ReactRefreshLogBoxMisc,ReactRefreshRegression,ReactRefreshRequire}.test.ts test/development/basic/*.test.ts && node run-tests.js test/integration/{fallback-modules,link-ref,production,async-modules,font-optimization,ssr-ctx}/test/index.test.js
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testFirefox:
name: Test Firefox (production)
runs-on: ubuntu-latest
Expand Down
10 changes: 4 additions & 6 deletions errors/webpack5.md
Expand Up @@ -2,9 +2,9 @@

#### Why This Message Occurred

Next.js has adopted webpack 5 as the default for compilation, webpack 4 has been deprecated. We've spent a lot of effort into ensuring the transition from webpack 4 to 5 will be as smooth as possible.
Next.js has adopted webpack 5 as the default for compilation. We've spent a lot of effort into ensuring the transition from webpack 4 to 5 will be as smooth as possible.

Your application currently has webpack 5 disabled using the `webpack5: false` flag which will be removed in Next.js 12:
Your application currently has webpack 5 disabled using the `webpack5: false` flag which has been removed in Next.js 12:

```js
module.exports = {
Expand All @@ -28,10 +28,8 @@ In the past releases we have gradually rolled out webpack 5 to Next.js applicati

- In Next.js 10.2 we automatically opted-in applications without custom webpack configuration in `next.config.js`
- In Next.js 10.2 we automatically opted-in applications that do not have a `next.config.js`
- In Next.js 11 webpack 5 was enabled by default for all applications. You can still opt-out and use webpack 4 to help with backwards compatibility using `webpack5: false` in `next.config.js`
- In Next.js 11.2 webpack 4 was deprecated

In Next.js 12 webpack 4 support will be removed.
- In Next.js 11 webpack 5 was enabled by default for all applications. You could still opt-out and use webpack 4 to help with backwards compatibility using `webpack5: false` in `next.config.js`
- In Next.js 12 webpack 4 support was removed.

#### Custom webpack configuration

Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -80,8 +80,6 @@
"@webassemblyjs/wasm-parser": "1.11.1",
"@webassemblyjs/wast-parser": "npm:empty-npm-package@1.0.0",
"@webassemblyjs/wast-printer": "1.11.1",
"@zeit/next-css": "1.0.2-canary.2",
"@zeit/next-sass": "1.0.2-canary.2",
"@zeit/next-typescript": "1.1.2-canary.0",
"abort-controller": "3.0.0",
"alex": "9.1.0",
Expand Down
8 changes: 2 additions & 6 deletions packages/next/build/compiler.ts
Expand Up @@ -26,12 +26,8 @@ function generateStats(
// Webpack 4 does not have this close method so in order to be backwards compatible we check if it exists
function closeCompiler(compiler: webpack.Compiler | webpack.MultiCompiler) {
return new Promise<void>((resolve, reject) => {
if ('close' in compiler) {
// @ts-ignore Close only exists on the compiler in webpack 5
return compiler.close((err: any) => (err ? reject(err) : resolve()))
}

resolve()
// @ts-ignore Close only exists on the compiler in webpack 5
return compiler.close((err: any) => (err ? reject(err) : resolve()))
})
}

Expand Down
71 changes: 34 additions & 37 deletions packages/next/build/entries.ts
Expand Up @@ -174,51 +174,48 @@ export function createEntrypoints(
export function finalizeEntrypoint(
name: string,
value: any,
isServer: boolean,
isWebpack5: boolean
isServer: boolean
): any {
if (isWebpack5) {
if (isServer) {
const isApi = name.startsWith('pages/api/')
const runtime = isApi ? 'webpack-api-runtime' : 'webpack-runtime'
const layer = isApi ? 'api' : undefined
const publicPath = isApi ? '' : undefined
if (isServer) {
const isApi = name.startsWith('pages/api/')
const runtime = isApi ? 'webpack-api-runtime' : 'webpack-runtime'
const layer = isApi ? 'api' : undefined
const publicPath = isApi ? '' : undefined
if (typeof value === 'object' && !Array.isArray(value)) {
return {
publicPath,
runtime,
layer,
...value,
}
} else {
return {
import: value,
publicPath,
runtime,
layer,
}
}
} else {
if (
name !== 'polyfills' &&
name !== 'main' &&
name !== 'amp' &&
name !== 'react-refresh'
) {
const dependOn =
name.startsWith('pages/') && name !== 'pages/_app'
? 'pages/_app'
: 'main'
if (typeof value === 'object' && !Array.isArray(value)) {
return {
publicPath,
runtime,
layer,
dependOn,
...value,
}
} else {
return {
import: value,
publicPath,
runtime,
layer,
}
}
} else {
if (
name !== 'polyfills' &&
name !== 'main' &&
name !== 'amp' &&
name !== 'react-refresh'
) {
const dependOn =
name.startsWith('pages/') && name !== 'pages/_app'
? 'pages/_app'
: 'main'
if (typeof value === 'object' && !Array.isArray(value)) {
return {
dependOn,
...value,
}
} else {
return {
import: value,
dependOn,
}
dependOn,
}
}
}
Expand Down

0 comments on commit a342bed

Please sign in to comment.