Commit 88581b91 authored by Cong-Cong Pan's avatar Cong-Cong Pan Committed by Jiachi Liu

chore: upgrade rspack 1.6.0 (#84210)

1. Fixed the incremental update bug in buildChunkGraph.
2. Fixed a bug in Rspack's built-in CssChunkingPlugin.

For detailed release information, please see
https://github.com/web-infra-dev/rspack/releases.

Note: All the faulty Rspack test cases on GitHub, from what I can see,
either time out or also produce errors in Rspack version 1.5.0.

---------
Co-authored-by: 's avatarBenjamin Woodruff <benjamin.woodruff@vercel.com>
parent 4da7406f
......@@ -142,7 +142,7 @@
"@next/third-parties": "workspace:*",
"@opentelemetry/api": "1.4.1",
"@picocss/pico": "1.5.10",
"@rspack/core": "1.5.0",
"@rspack/core": "1.6.0",
"@slack/web-api": "7.9.1",
"@swc/cli": "0.1.55",
"@swc/core": "1.11.24",
......
......@@ -7,6 +7,6 @@
},
"types": "index.d.ts",
"dependencies": {
"@next/rspack-core": "1.0.0"
"@next/rspack-core": "1.0.1"
}
}
......@@ -169,7 +169,7 @@
"@next/swc": "16.0.2",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.51.1",
"@rspack/core": "1.5.0",
"@rspack/core": "1.6.0",
"@storybook/addon-a11y": "8.6.0",
"@storybook/addon-essentials": "8.6.0",
"@storybook/addon-interactions": "8.6.0",
......
......@@ -287,6 +287,10 @@ export function hasExternalOtelApiPackage(): boolean {
const UNSAFE_CACHE_REGEX = /[\\/]pages[\\/][^\\/]+(?:$|\?|#)/
const NEGATIVE_UNSAFE_CACHE_REGEX = new RegExp(
`^(?!.*${UNSAFE_CACHE_REGEX.source}).*$`
)
export function getCacheDirectories(
configs: webpack.Configuration[]
): Set<string> {
......@@ -2257,12 +2261,8 @@ export default async function getBaseWebpackConfig(
}
if (isRspack) {
// @ts-ignore
// Disable Rspack's incremental buildChunkGraph due to Next.js compatibility issues
// TODO: Remove this workaround after Rspack 1.5.1 release
webpack5Config.experiments.incremental = {
buildChunkGraph: false,
}
// The layers experiment is now stable in Rspack
delete webpack5Config.experiments!.layers
}
webpack5Config.module!.parser = {
......@@ -2488,11 +2488,22 @@ export default async function getBaseWebpackConfig(
if (dev) {
if (webpackConfig.module) {
webpackConfig.module.unsafeCache = (module: any) =>
!UNSAFE_CACHE_REGEX.test(module.resource)
if (isRspack) {
;(webpackConfig.module.unsafeCache as any) = NEGATIVE_UNSAFE_CACHE_REGEX
} else {
webpackConfig.module.unsafeCache = (module: any) =>
!UNSAFE_CACHE_REGEX.test(module.resource)
}
} else {
webpackConfig.module = {
unsafeCache: (module: any) => !UNSAFE_CACHE_REGEX.test(module.resource),
if (isRspack) {
;(webpackConfig.module as any) = {
unsafeCache: NEGATIVE_UNSAFE_CACHE_REGEX,
}
} else {
webpackConfig.module = {
unsafeCache: (module: any) =>
!UNSAFE_CACHE_REGEX.test(module.resource),
}
}
}
}
......
This diff is collapsed.
......@@ -1791,6 +1791,17 @@ version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06432fb54d3be7964ecd3649233cddf80db2832f47fec34c01f65b3d9d774983"
[[package]]
name = "io-uring"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
dependencies = [
"bitflags 2.9.1",
"cfg-if",
"libc",
]
[[package]]
name = "ipnet"
version = "2.10.1"
......@@ -6503,6 +6514,7 @@ checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408"
dependencies = [
"parking_lot",
"pin-project-lite",
"slab",
"tokio-macros",
"tracing",
]
......
......@@ -438,8 +438,8 @@ packages:
'@napi-rs/wasm-runtime@0.2.12':
resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==}
'@napi-rs/wasm-runtime@1.0.3':
resolution: {integrity: sha512-rZxtMsLwjdXkMUGC3WwsPwLNVqVqnTJT6MNIB6e+5fhMcSCPP0AOsNWuMQ5mdCq6HNjs/ZeWAEchpqeprqBD2Q==}
'@napi-rs/wasm-runtime@1.0.7':
resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==}
'@napi-rs/wasm-runtime@1.0.7':
resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==}
......@@ -1066,7 +1066,7 @@ snapshots:
'@napi-rs/lzma-wasm32-wasi@1.4.5':
dependencies:
'@napi-rs/wasm-runtime': 1.0.3
'@napi-rs/wasm-runtime': 1.0.7
optional: true
'@napi-rs/lzma-win32-arm64-msvc@1.4.5':
......@@ -1174,11 +1174,11 @@ snapshots:
'@tybys/wasm-util': 0.10.0
optional: true
'@napi-rs/wasm-runtime@1.0.3':
'@napi-rs/wasm-runtime@1.0.7':
dependencies:
'@emnapi/core': 1.4.5
'@emnapi/runtime': 1.4.5
'@tybys/wasm-util': 0.10.0
'@emnapi/core': 1.5.0
'@emnapi/runtime': 1.5.0
'@tybys/wasm-util': 0.10.1
optional: true
'@napi-rs/wasm-runtime@1.0.7':
......
......@@ -4,13 +4,11 @@ import path from 'path'
import { outdent } from 'outdent'
describe('ReactRefreshLogBox-builtins app', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
await using sandbox = await createSandbox(
......@@ -135,10 +133,10 @@ describe('ReactRefreshLogBox-builtins app', () => {
"label": "Build Error",
"source": "./index.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>'
╭─[2:17]
╭─[2:0]
1 │ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import Comp from 'b';
· ───
· ─────────────────────
3 │ export default function Oops() {
4 │ return /*#__PURE__*/ _jsxDEV("div", {
╰────
......@@ -204,10 +202,10 @@ describe('ReactRefreshLogBox-builtins app', () => {
"label": "Build Error",
"source": "./app/page.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>/app'
╭─[2:17]
╭─[2:0]
1 │ /* __next_internal_client_entry_do_not_use__ default auto */ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import Comp from 'b';
· ───
· ─────────────────────
3 │ export default function Oops() {
4 │ return /*#__PURE__*/ _jsxDEV("div", {
╰────
......@@ -270,10 +268,10 @@ describe('ReactRefreshLogBox-builtins app', () => {
"label": "Build Error",
"source": "./app/page.js
× Module not found: Can't resolve './non-existent.css' in '<FIXME-project-root>/app'
╭─[2:7]
╭─[2:0]
1 │ /* __next_internal_client_entry_do_not_use__ default auto */ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import './non-existent.css';
· ────────────────────
· ────────────────────────────
3 │ export default function Page(props) {
4 │ return /*#__PURE__*/ _jsxDEV("p", {
╰────",
......
......@@ -6,14 +6,12 @@ import path from 'path'
import { outdent } from 'outdent'
describe('ReactRefreshLogBox app', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
patchFileDelay: 1000,
})
const isRspack = !!process.env.NEXT_RSPACK
test('should strip whitespace correctly with newline', async () => {
await using sandbox = await createSandbox(next)
const { browser, session } = sandbox
......@@ -1443,7 +1441,7 @@ describe('ReactRefreshLogBox app', () => {
× Module not found: Can't resolve 'non-existing-module' in '<FIXME-project-root>/app'
╭────
1 │ import "non-existing-module";
· ─────────────────────
· ─────────────────────────────
╰────
Import trace for requested module:
./app/module.js
......
......@@ -4,11 +4,10 @@ import path from 'path'
import { outdent } from 'outdent'
describe('ReactRefreshLogBox app', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
test('server-side only compilation errors', async () => {
await using sandbox = await createSandbox(next)
......
......@@ -6,11 +6,10 @@ import path from 'path'
import { outdent } from 'outdent'
describe('Error recovery app', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
test('can recover from a syntax error without losing state', async () => {
await using sandbox = await createSandbox(next)
......
......@@ -4,11 +4,10 @@ import { outdent } from 'outdent'
import path from 'path'
describe('ReactRefreshLogBox', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
......@@ -133,10 +132,10 @@ describe('ReactRefreshLogBox', () => {
"label": "Build Error",
"source": "./index.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>'
╭─[2:17]
╭─[2:0]
1 │ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import Comp from 'b';
· ───
· ─────────────────────
3 │ export default function Oops() {
4 │ return /*#__PURE__*/ _jsxDEV("div", {
╰────
......@@ -202,10 +201,10 @@ describe('ReactRefreshLogBox', () => {
"label": "Build Error",
"source": "./pages/index.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>/pages'
╭─[2:17]
╭─[2:0]
1 │ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import Comp from 'b';
· ───
· ─────────────────────
3 │ export default function Oops() {
4 │ return /*#__PURE__*/ _jsxDEV("div", {
╰────
......@@ -277,10 +276,10 @@ describe('ReactRefreshLogBox', () => {
"label": "Build Error",
"source": "./pages/_app.js
× Module not found: Can't resolve './non-existent.css' in '<FIXME-project-root>/pages'
╭─[2:7]
╭─[2:0]
1 │ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2 │ import './non-existent.css';
· ────────────────────
· ────────────────────────────
3 │ export default function App({ Component, pageProps }) {
4 │ return /*#__PURE__*/ _jsxDEV(Component, {
╰────",
......
......@@ -13,11 +13,10 @@ import { outdent } from 'outdent'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
describe('ReactRefreshLogBox', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
test('should strip whitespace correctly with newline', async () => {
await using sandbox = await createSandbox(next)
......
......@@ -6,10 +6,9 @@ import { outdent } from 'outdent'
import path from 'path'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
const isRspack = !!process.env.NEXT_RSPACK
describe('pages/ error recovery', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
})
......
......@@ -9,7 +9,7 @@ import {
import { outdent } from 'outdent'
describe('Cache Components Dev Errors', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: __dirname,
})
......@@ -153,6 +153,26 @@ describe('Cache Components Dev Errors', () => {
"stack": [],
}
`)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.tsx
× Module build failed:
╰─▶ × Error: x Route segment config "revalidate" is not compatible with \`nextConfig.cacheComponents\`. Please remove it.
│ ,-[1:1]
│ 1 | export const revalidate = 10
│ : ^^^^^^^^^^
│ 2 | export default function Page() {
│ 3 | return (
│ 4 | <div>Hello World</div>
│ \`----
│",
"stack": [],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
......
......@@ -3,11 +3,10 @@ import stripAnsi from 'strip-ansi'
import { nextTestSetup } from 'e2e-utils'
describe('middleware - development errors', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname,
patchFileDelay: 500,
})
const isRspack = !!process.env.NEXT_RSPACK
beforeEach(async () => {
await next.stop()
......
......@@ -10,13 +10,12 @@ import path from 'path'
import { nextTestSetup } from 'e2e-utils'
describe('Client Navigation', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixture'),
env: {
TEST_STRICT_NEXT_HEAD: String(true),
},
})
const isRspack = !!process.env.NEXT_RSPACK
describe('with empty getInitialProps()', () => {
it('should render a redbox', async () => {
......
......@@ -11,13 +11,12 @@ import url from 'url'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
describe('Client Navigation rendering', () => {
const { isTurbopack, next } = nextTestSetup({
const { isTurbopack, next, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixture'),
env: {
TEST_STRICT_NEXT_HEAD: String(true),
},
})
const isRspack = !!process.env.NEXT_RSPACK
function render(
pathname: Parameters<typeof renderViaHTTP>[1],
......
......@@ -3,12 +3,11 @@ import { waitForNoErrorToast } from 'next-test-utils'
import { getPrerenderOutput } from './utils'
describe('Cache Components Errors', () => {
const { next, isTurbopack, isNextStart, skipped } = nextTestSetup({
const { next, isTurbopack, isNextStart, skipped, isRspack } = nextTestSetup({
files: __dirname + '/fixtures/default',
skipStart: !isNextDev,
skipDeployment: true,
})
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) {
return
......
import { nextTestSetup } from 'e2e-utils'
describe('metadata-invalid-image-file', () => {
const { next, isTurbopack, isNextDev, skipped } = nextTestSetup({
const { next, isTurbopack, isNextDev, skipped, isRspack } = nextTestSetup({
files: __dirname,
skipDeployment: true,
skipStart: true,
})
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) return
......
......@@ -8,7 +8,7 @@ import {
import * as path from 'path'
describe('non-root-project-monorepo', () => {
const { next, skipped, isTurbopack, isNextDev } = nextTestSetup({
const { next, skipped, isTurbopack, isNextDev, isRspack } = nextTestSetup({
files: {
apps: new FileRef(path.resolve(__dirname, 'apps')),
packages: new FileRef(path.resolve(__dirname, 'packages')),
......@@ -23,7 +23,6 @@ describe('non-root-project-monorepo', () => {
installCommand: 'pnpm i',
skipDeployment: true,
})
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) {
return
......
......@@ -19,14 +19,13 @@ describe('app-dir - server source maps', () => {
'internal-pkg': `link:./internal-pkg`,
'external-pkg': `file:./external-pkg`,
}
const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({
const { skipped, next, isNextDev, isTurbopack, isRspack } = nextTestSetup({
dependencies,
files: path.join(__dirname, 'fixtures/default'),
// Deploy tests don't have access to runtime logs.
// Manually verify that the runtime logs match.
skipDeployment: true,
})
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) return
......
......@@ -3,14 +3,12 @@ import { waitForRedbox } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
describe('use-cache-segment-configs', () => {
const { next, skipped, isNextDev, isTurbopack } = nextTestSetup({
const { next, skipped, isNextDev, isTurbopack, isRspack } = nextTestSetup({
files: __dirname,
skipStart: process.env.NEXT_TEST_MODE !== 'dev',
skipDeployment: true,
})
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) {
return
}
......
......@@ -9,10 +9,8 @@ import {
import stripAnsi from 'strip-ansi'
import { createSandbox } from 'development-sandbox'
const isRspack = !!process.env.NEXT_RSPACK
describe('use-cache-unknown-cache-kind', () => {
const { next, isNextStart, isTurbopack, skipped } = nextTestSetup({
const { next, isNextStart, isTurbopack, isRspack, skipped } = nextTestSetup({
files: __dirname,
skipStart: process.env.NEXT_TEST_MODE !== 'dev',
skipDeployment: true,
......
......@@ -13,10 +13,8 @@ const nextConfigWithUseCache: NextConfig = {
experimental: { useCache: true },
}
const isRspack = !!process.env.NEXT_RSPACK
describe('use-cache-without-experimental-flag', () => {
const { next, isNextStart, isTurbopack, skipped } = nextTestSetup({
const { next, isNextStart, isTurbopack, skipped, isRspack } = nextTestSetup({
files: __dirname,
skipStart: process.env.NEXT_TEST_MODE !== 'dev',
skipDeployment: true,
......
......@@ -6,12 +6,10 @@ const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
const pprEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const isRspack = !!process.env.NEXT_RSPACK
describe('build-output-prerender', () => {
describe('with a next config file', () => {
describe('without --debug-prerender', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixtures/with-config-file'),
skipStart: true,
})
......@@ -97,7 +95,7 @@ describe('build-output-prerender', () => {
})
describe('with --debug-prerender', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixtures/with-config-file'),
skipStart: true,
buildArgs: ['--debug-prerender'],
......@@ -215,7 +213,7 @@ describe('build-output-prerender', () => {
describe('without a next config file', () => {
describe('without --debug-prerender', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixtures/without-config-file'),
skipStart: true,
})
......@@ -270,7 +268,7 @@ describe('build-output-prerender', () => {
})
describe('with --debug-prerender', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: path.join(__dirname, 'fixtures/without-config-file'),
skipStart: true,
buildArgs: ['--debug-prerender'],
......
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