Skip to content

Commit 9ba29b4

Browse files
authored
Revert "Revert "Revert "Revert "Add a --webpack flag and default --turbopack to true (#84216)"""" (#84394)
Reverts #84389 Attempt number 3, #84374 fixed propagation of bundler environment variables to vercel cli operations, to ensure the test configuration is respected. [Deployment Tests Run 1](https://github.com/vercel/next.js/actions/runs/18146684793/job/51649631635). A fair number of failures. [Deployment Tests Run 2](https://github.com/vercel/next.js/actions/runs/18154875270). After #84395. These still have a set of failures, but i confirmed that the deployment builds are running `webpack`. The tests that are failing are related to 'prefetches' (test/e2e/app-dir/segment-cache/prefetch-runtime/prefetch-runtime.test.ts and test/e2e/app-dir/segment-cache/prefetch-layout-sharing/prefetch-layout-sharing.test.ts) and generally the error is a timeout. Recent deployment runs for canary releases are also failing, but on different tests. Trying again after #[84419](#84419). [Deployment Tests Run 3](https://github.com/vercel/next.js/actions/runs/18173375427). Failures appeared flaky, rerunning failures...
1 parent 2330e14 commit 9ba29b4

File tree

17 files changed

+412
-180
lines changed

17 files changed

+412
-180
lines changed

.github/workflows/build_and_test.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ jobs:
502502
503503
export NEXT_TEST_MODE=start
504504
export NEXT_TEST_WASM=true
505+
export IS_WEBPACK_TEST=1
505506
node run-tests.js \
506507
test/production/pages-dir/production/test/index.test.ts \
507508
test/e2e/streaming-ssr/index.test.ts
@@ -711,7 +712,7 @@ jobs:
711712

712713
secrets: inherit
713714

714-
test-dev:
715+
test-dev: # TODO: rename to include webpack
715716
name: test dev
716717
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
717718
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
@@ -728,6 +729,7 @@ jobs:
728729
uses: ./.github/workflows/build_reusable.yml
729730
with:
730731
afterBuild: |
732+
export IS_WEBPACK_TEST=1
731733
export NEXT_TEST_MODE=dev
732734
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
733735
@@ -752,8 +754,10 @@ jobs:
752754

753755
uses: ./.github/workflows/build_reusable.yml
754756
with:
757+
# Should this be using turbopack? a variation?
755758
afterBuild: |
756759
export NEXT_TEST_MODE=dev
760+
export IS_WEBPACK_TEST=1
757761
758762
node run-tests.js \
759763
test/e2e/app-dir/app/index.test.ts \
@@ -780,6 +784,7 @@ jobs:
780784
with:
781785
nodeVersion: 20.9.0
782786
afterBuild: |
787+
export IS_WEBPACK_TEST=1
783788
node run-tests.js \
784789
--concurrency 4 \
785790
test/production/pages-dir/production/test/index.test.ts \
@@ -808,6 +813,7 @@ jobs:
808813
with:
809814
afterBuild: |
810815
export NEXT_TEST_MODE=start
816+
export IS_WEBPACK_TEST=1
811817
812818
node run-tests.js --type production \
813819
test/e2e/app-dir/app/index.test.ts \
@@ -836,6 +842,7 @@ jobs:
836842
uses: ./.github/workflows/build_reusable.yml
837843
with:
838844
afterBuild: |
845+
export IS_WEBPACK_TEST=1
839846
export NEXT_TEST_MODE=start
840847
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
841848
@@ -875,6 +882,7 @@ jobs:
875882
with:
876883
nodeVersion: 20.9.0
877884
afterBuild: |
885+
export IS_WEBPACK_TEST=1
878886
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
879887
880888
node run-tests.js \
@@ -896,6 +904,7 @@ jobs:
896904
897905
# these all run without concurrency because they're heavier
898906
export TEST_CONCURRENCY=1
907+
export IS_WEBPACK_TEST=1
899908
900909
BROWSER_NAME=firefox node run-tests.js \
901910
test/production/pages-dir/production/test/index.test.ts
@@ -923,6 +932,7 @@ jobs:
923932
afterBuild: |
924933
export __NEXT_EXPERIMENTAL_PPR=true
925934
export NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json"
935+
export IS_WEBPACK_TEST=1
926936
927937
node run-tests.js \
928938
--timings \
@@ -945,6 +955,7 @@ jobs:
945955
export __NEXT_EXPERIMENTAL_PPR=true
946956
export NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json"
947957
export NEXT_TEST_MODE=dev
958+
export IS_WEBPACK_TEST=1
948959
949960
node run-tests.js \
950961
--timings \
@@ -968,6 +979,7 @@ jobs:
968979
export __NEXT_EXPERIMENTAL_PPR=true
969980
export NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json"
970981
export NEXT_TEST_MODE=start
982+
export IS_WEBPACK_TEST=1
971983
972984
node run-tests.js \
973985
--timings \
@@ -990,6 +1002,7 @@ jobs:
9901002
export __NEXT_EXPERIMENTAL_PPR=true # for compatibility with the existing tests
9911003
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
9921004
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
1005+
export IS_WEBPACK_TEST=1
9931006
9941007
node run-tests.js \
9951008
--timings \
@@ -1014,6 +1027,7 @@ jobs:
10141027
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
10151028
export NEXT_TEST_MODE=dev
10161029
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
1030+
export IS_WEBPACK_TEST=1
10171031
10181032
node run-tests.js \
10191033
--timings \
@@ -1038,6 +1052,7 @@ jobs:
10381052
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
10391053
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
10401054
export NEXT_TEST_MODE=start
1055+
export IS_WEBPACK_TEST=1
10411056
10421057
node run-tests.js \
10431058
--timings \

.github/workflows/pull_request_stats.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ jobs:
6060

6161
- uses: ./.github/actions/next-stats-action
6262
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
63+
env:
64+
# This uses the webpack bundle analyzer and for consistent results we need to use webpack.
65+
# Once there is an equivalent analyzer for turbopack, we can remove this.
66+
IS_WEBPACK_TEST: 1

.github/workflows/test_e2e_deploy_release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ jobs:
7878
matrix:
7979
group: [1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 8/8]
8080
with:
81-
afterBuild: npm i -g vercel@latest && NEXT_E2E_TEST_TIMEOUT=240000 NEXT_TEST_MODE=deploy NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json" NEXT_TEST_VERSION="${{ github.event.inputs.nextVersion || 'canary' }}" VERCEL_CLI_VERSION="${{ github.event.inputs.vercelCliVersion || 'vercel@latest' }}" node run-tests.js --timings -g ${{ matrix.group }} -c 2 --type e2e
81+
afterBuild: |
82+
npm i -g vercel@latest && \
83+
NEXT_E2E_TEST_TIMEOUT=240000 \
84+
NEXT_TEST_MODE=deploy \
85+
IS_WEBPACK_TEST=1 \
86+
NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json" \
87+
NEXT_TEST_VERSION="${{ github.event.inputs.nextVersion || 'canary' }}" \
88+
VERCEL_CLI_VERSION="${{ github.event.inputs.vercelCliVersion || 'vercel@latest' }}" \
89+
node run-tests.js --timings -g ${{ matrix.group }} -c 2 --type e2e
8290
skipNativeBuild: 'yes'
8391
skipNativeInstall: 'no'
8492
stepName: 'test-deploy-${{ matrix.group }}'

bench/heavy-npm-deps/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"scripts": {
66
"dev-turbopack": "next dev --turbopack",
7-
"dev-webpack": "next dev",
7+
"dev-webpack": "next dev --webpack",
88
"build-turbopack": "next build --turbopack",
9-
"build-webpack": "next build",
9+
"build-webpack": "next build --webpack",
1010
"start-turbopack": "next start",
1111
"start-webpack": "next start",
1212
"build-application": "next build",

bench/module-cost/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"scripts": {
44
"prepare-bench": "node scripts/prepare-bench.mjs",
55
"benchmark": "node scripts/benchmark-runner.mjs",
6-
"dev-webpack": "next dev",
7-
"dev-turbopack": "next dev --turbo",
8-
"build-webpack": "next build",
9-
"build-turbopack": "next build --turbo",
6+
"dev-webpack": "next dev --webpack",
7+
"dev-turbopack": "next dev --turbopack",
8+
"build-webpack": "next build --webpack",
9+
"build-turbopack": "next build --turbopack",
1010
"start": "next start"
1111
},
1212
"devDependencies": {

package.json

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,49 @@
1717
"ci:publish": "tsx ./scripts/release/publish-npm.ts",
1818
"test-types": "tsc",
1919
"test-unit": "jest test/unit/ packages/next/ packages/font",
20-
"test-dev": "cross-env NEXT_TEST_MODE=dev pnpm testheadless",
21-
"test-dev-experimental": "cross-env NEXT_TEST_MODE=dev pnpm run with-experimental pnpm testheadless",
22-
"test-dev-rspack": "pnpm run with-rspack pnpm run test-dev",
23-
"test-dev-experimental-rspack": "pnpm run with-rspack pnpm run test-dev-experimental",
24-
"test-dev-turbo": "cross-env NEXT_TEST_MODE=dev IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm testheadless",
25-
"test-dev-experimental-turbo": "cross-env NEXT_TEST_MODE=dev IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm run with-experimental pnpm testheadless",
26-
"test-start": "cross-env NEXT_TEST_MODE=start pnpm testheadless",
27-
"test-start-experimental": "cross-env NEXT_TEST_MODE=start pnpm run with-experimental pnpm testheadless",
28-
"test-start-rspack": "pnpm run with-rspack pnpm run test-start",
29-
"test-start-experimental-rspack": "pnpm run with-rspack pnpm run test-start-experimental",
30-
"test-start-turbo": "cross-env NEXT_TEST_MODE=start IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm testheadless",
31-
"test-start-experimental-turbo": "cross-env NEXT_TEST_MODE=start IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm run with-experimental pnpm testheadless",
32-
"test-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testheadless",
33-
"testonly-dev": "cross-env NEXT_TEST_MODE=dev pnpm testonly",
34-
"testonly-dev-rspack": "pnpm run with-rspack pnpm run testonly-dev",
35-
"testonly-dev-turbo": "cross-env NEXT_TEST_MODE=dev IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm testonly",
36-
"testonly-start": "cross-env NEXT_TEST_MODE=start pnpm testonly",
37-
"testonly-start-rspack": "pnpm run with-rspack pnpm run testonly-start",
38-
"testonly-start-turbo": "cross-env NEXT_TEST_MODE=start IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm testonly",
39-
"testonly-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testonly",
40-
"test": "pnpm testheadless",
41-
"test-rspack": "pnpm run with-rspack pnpm run test",
42-
"test-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 TURBOPACK_BUILD=1 pnpm testheadless",
20+
"test-dev-inner": "cross-env NEXT_TEST_MODE=dev pnpm testheadless",
21+
"test-dev": "pnpm run test-dev-webpack",
22+
"test-dev-webpack": "pnpm run with-webpack pnpm test-dev-inner",
23+
"test-dev-experimental-inner": "pnpm run with-experimental pnpm test-dev-inner",
24+
"test-dev-experimental": "pnpm run test-dev-experimental-webpack",
25+
"test-dev-experimental-webpack": "pnpm run with-webpack pnpm test-dev-experimental-inner",
26+
"test-dev-rspack": "pnpm run with-rspack pnpm run test-dev-inner",
27+
"test-dev-experimental-rspack": "pnpm run with-rspack pnpm run test-dev-experimental-inner",
28+
"test-dev-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm test-dev-inner",
29+
"test-dev-experimental-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm run with-experimental pnpm test-dev-inner",
30+
"test-start-inner": "cross-env NEXT_TEST_MODE=start pnpm testheadless",
31+
"test-start": "pnpm run test-start-webpack",
32+
"test-start-webpack": "pnpm run with-webpack pnpm run test-start-inner",
33+
"test-start-experimental-inner": "pnpm run with-experimental pnpm test-start-inner",
34+
"test-start-experimental": "pnpm run test-start-experimental-webpack",
35+
"test-start-experimental-webpack": "pnpm run with-webpack pnpm run test-start-experimental-inner",
36+
"test-start-rspack": "pnpm run with-rspack pnpm run test-start-inner",
37+
"test-start-experimental-rspack": "pnpm run with-rspack pnpm run test-start-experimental-inner",
38+
"test-start-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm test-start-inner",
39+
"test-start-experimental-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm run with-experimental pnpm test-start-experimental-inner",
40+
"test-deploy-inner": "cross-env NEXT_TEST_MODE=deploy pnpm testheadless",
41+
"test-deploy": "pnpm run test-deploy-webpack",
42+
"test-deploy-webpack": "pnpm run with-webpack pnpm test-deploy-inner",
43+
"test-deploy-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm test-deploy-inner",
44+
"testonly-dev-inner": "cross-env NEXT_TEST_MODE=dev pnpm testonly",
45+
"testonly-dev": "pnpm run testonly-dev-webpack",
46+
"testonly-dev-webpack": "pnpm run with-webpack pnpm run testonly-dev-inner",
47+
"testonly-dev-rspack": "pnpm run with-rspack pnpm run testonly-dev-inner",
48+
"testonly-dev-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm testonly-dev-inner",
49+
"testonly-start-inner": "cross-env NEXT_TEST_MODE=start pnpm testonly",
50+
"testonly-start": "pnpm run testonly-start-webpack",
51+
"testonly-start-webpack": "pnpm run with-webpack pnpm run testonly-start-inner",
52+
"testonly-start-rspack": "pnpm run with-rspack pnpm run testonly-start-inner",
53+
"testonly-start-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm testonly-start-inner",
54+
"testonly-deploy-inner": "cross-env NEXT_TEST_MODE=deploy pnpm testonly",
55+
"testonly-deploy": "pnpm run testonly-deploy-webpack",
56+
"testonly-deploy-webpack": "pnpm run with-webpack pnpm run testonly-deploy-inner",
57+
"testonly-deploy-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 pnpm testonly-deploy-inner",
58+
"test-inner": "pnpm testheadless",
59+
"test": "pnpm test-webpack",
60+
"test-webpack": "pnpm run with-webpack pnpm run test-inner",
61+
"test-rspack": "pnpm run with-rspack pnpm run test-inner",
62+
"test-turbo": "cross-env IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 TURBOPACK_BUILD=1 pnpm test-inner",
4363
"testonly": "jest --runInBand",
4464
"testheadless": "cross-env HEADLESS=true pnpm testonly",
4565
"genstats": "cross-env LOCAL_STATS=true node .github/actions/next-stats-action/src/index.js",
@@ -89,6 +109,7 @@
89109
"build-storybook": "turbo run build-storybook",
90110
"test-storybook": "turbo run test-storybook",
91111
"with-rspack": "cross-env NEXT_RSPACK=1 NEXT_TEST_USE_RSPACK=1",
112+
"with-webpack": "cross-env IS_WEBPACK_TEST=1",
92113
"with-experimental": "cross-env __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true __NEXT_EXPERIMENTAL_PPR=true"
93114
},
94115
"devDependencies": {

packages/next-rspack/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
module.exports = function withRspack(config) {
22
process.env.NEXT_RSPACK = 'true'
33
process.env.RSPACK_CONFIG_VALIDATE = 'loose-silent'
4+
if (process.env.TURBOPACK === 'auto') {
5+
// If next has defaulted to turbopack, override it.
6+
delete process.env.TURBOPACK
7+
} else {
8+
console.error(
9+
`Cannot call withRspack and pass the ${process.env.TURBOPACK ? '--turbopack' : '--webpack'} flag.`
10+
)
11+
console.error('Please configure only one bundler.')
12+
process.exit(1)
13+
}
414
return config
515
}

packages/next/src/bin/next.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ program
133133
.option('--no-mangling', 'Disables mangling.')
134134
.option('--profile', 'Enables production profiling for React.')
135135
.option('--experimental-app-only', 'Builds only App Router routes.')
136-
.option('--turbo', 'Starts development mode using Turbopack.')
137-
.option('--turbopack', 'Starts development mode using Turbopack.')
136+
.option('--turbo', 'Builds using Turbopack.')
137+
.option('--turbopack', 'Builds using Turbopack.')
138+
.option('--webpack', 'Builds using webpack.')
138139
.addOption(
139140
new Option(
140141
'--experimental-build-mode [mode]',
@@ -173,6 +174,7 @@ program
173174
)
174175
.option('--turbo', 'Starts development mode using Turbopack.')
175176
.option('--turbopack', 'Starts development mode using Turbopack.')
177+
.option('--webpack', 'Starts development mode using webpack.')
176178
.addOption(
177179
new Option(
178180
'-p, --port <port>',

0 commit comments

Comments
 (0)