Unverified Commit 5712c05c authored by Cong-Cong Pan's avatar Cong-Cong Pan Committed by GitHub

fix(Rspack): resolve HMR unresponsiveness or unexpected full reload & update dev snapshot (#83480)

This commit addresses the bugs where Hot Module Replacement (HMR) was
not functioning correctly in Rspack mode. Component edits would often
result in no update or a full page reload instead of a fast,
state-preserving refresh.

This commit implements a new, custom React Refresh plugin and runtime
specifically for Rspack, which correctly orchestrates the HMR lifecycle.
parent 844abcac
...@@ -124,7 +124,6 @@ ...@@ -124,7 +124,6 @@
"@opentelemetry/api": "1.4.1", "@opentelemetry/api": "1.4.1",
"@picocss/pico": "1.5.10", "@picocss/pico": "1.5.10",
"@rspack/core": "1.5.0", "@rspack/core": "1.5.0",
"@rspack/plugin-react-refresh": "1.2.0",
"@slack/web-api": "7.9.1", "@slack/web-api": "7.9.1",
"@swc/cli": "0.1.55", "@swc/cli": "0.1.55",
"@swc/core": "1.11.24", "@swc/core": "1.11.24",
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
}, },
"types": "index.d.ts", "types": "index.d.ts",
"dependencies": { "dependencies": {
"@rspack/core": "1.5.0", "@rspack/core": "1.5.0"
"@rspack/plugin-react-refresh": "1.2.0",
"react-refresh": "0.12.0"
} }
} }
...@@ -94,7 +94,7 @@ import { ...@@ -94,7 +94,7 @@ import {
NEXT_PROJECT_ROOT, NEXT_PROJECT_ROOT,
NEXT_PROJECT_ROOT_DIST_CLIENT, NEXT_PROJECT_ROOT_DIST_CLIENT,
} from './next-dir-paths' } from './next-dir-paths'
import { getRspackCore, getRspackReactRefresh } from '../shared/lib/get-rspack' import { getRspackCore } from '../shared/lib/get-rspack'
import { RspackProfilingPlugin } from './webpack/plugins/rspack-profiling-plugin' import { RspackProfilingPlugin } from './webpack/plugins/rspack-profiling-plugin'
import getWebpackBundler from '../shared/lib/get-webpack-bundler' import getWebpackBundler from '../shared/lib/get-webpack-bundler'
import type { NextBuildContext } from './build-context' import type { NextBuildContext } from './build-context'
...@@ -178,7 +178,7 @@ const reactRefreshLoaderName = ...@@ -178,7 +178,7 @@ const reactRefreshLoaderName =
function getReactRefreshLoader() { function getReactRefreshLoader() {
return process.env.NEXT_RSPACK return process.env.NEXT_RSPACK
? getRspackReactRefresh().loader ? 'builtin:react-refresh-loader'
: require.resolve(reactRefreshLoaderName) : require.resolve(reactRefreshLoaderName)
} }
...@@ -698,7 +698,9 @@ export default async function getBaseWebpackConfig( ...@@ -698,7 +698,9 @@ export default async function getBaseWebpackConfig(
] ]
const reactRefreshEntry = isRspack const reactRefreshEntry = isRspack
? getRspackReactRefresh().entry ? require.resolve(
`next/dist/compiled/@next/react-refresh-utils/dist/rspack-runtime`
)
: require.resolve( : require.resolve(
`next/dist/compiled/@next/react-refresh-utils/dist/runtime` `next/dist/compiled/@next/react-refresh-utils/dist/runtime`
) )
...@@ -1990,11 +1992,7 @@ export default async function getBaseWebpackConfig( ...@@ -1990,11 +1992,7 @@ export default async function getBaseWebpackConfig(
isClient && isClient &&
(isRspack (isRspack
? // eslint-disable-next-line ? // eslint-disable-next-line
new (getRspackReactRefresh() as any)({ new (require('next/dist/compiled/@next/react-refresh-utils/dist/ReactRefreshRspackPlugin').default)()
injectLoader: false,
injectEntry: false,
overlay: false,
})
: new ReactRefreshWebpackPlugin(webpack)), : new ReactRefreshWebpackPlugin(webpack)),
// Makes sure `Buffer` and `process` are polyfilled in client and flight bundles (same behavior as webpack 4) // Makes sure `Buffer` and `process` are polyfilled in client and flight bundles (same behavior as webpack 4)
(isClient || isEdgeServer) && (isClient || isEdgeServer) &&
......
...@@ -35,6 +35,12 @@ export default async function nextFontLoader(this: any) { ...@@ -35,6 +35,12 @@ export default async function nextFontLoader(this: any) {
`${bold('Cannot')} be used within ${cyan('pages/_document.js')}.` `${bold('Cannot')} be used within ${cyan('pages/_document.js')}.`
) )
err.name = 'NextFontError' err.name = 'NextFontError'
if (process.env.NEXT_RSPACK) {
// Rspack uses miette for error formatting, which automatically includes stack
// traces in the error message. To avoid showing redundant stack information
// in the final error output, we clear the stack property.
err.stack = undefined
}
callback(err) callback(err)
return return
} }
......
...@@ -7,11 +7,9 @@ const nextInvalidImportErrorLoader: webpack.LoaderDefinitionFunction<InvalidImpo ...@@ -7,11 +7,9 @@ const nextInvalidImportErrorLoader: webpack.LoaderDefinitionFunction<InvalidImpo
const { message } = this.getOptions() const { message } = this.getOptions()
const error = new Error(message) const error = new Error(message)
if (process.env.NEXT_RSPACK) { if (process.env.NEXT_RSPACK) {
/** // Rspack uses miette for error formatting, which automatically includes stack
* Rspack uses miette for error formatting, which automatically includes stack // traces in the error message. To avoid showing redundant stack information
* traces in the error message. To avoid showing redundant stack information // in the final error output, we clear the stack property.
* in the final error output, we clear the stack property.
*/
error.stack = undefined error.stack = undefined
} }
throw error throw error
......
...@@ -17,31 +17,6 @@ export function getRspackCore() { ...@@ -17,31 +17,6 @@ export function getRspackCore() {
} }
} }
export function getRspackReactRefresh() {
warnRspack()
try {
const paths = [require.resolve('next-rspack')]
// eslint-disable-next-line import/no-extraneous-dependencies
const plugin = require(
require.resolve('@rspack/plugin-react-refresh', { paths })
)
const entry = require.resolve(
'@rspack/plugin-react-refresh/react-refresh-entry',
{ paths }
)
plugin.entry = entry
return plugin
} catch (e) {
if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
throw new Error(
'@rspack/plugin-react-refresh is not available. Please make sure `next-rspack` is correctly installed.'
)
}
throw e
}
}
function warnRspack() { function warnRspack() {
if (process.env.__NEXT_TEST_MODE) { if (process.env.__NEXT_TEST_MODE) {
return return
......
import type { Compiler } from 'webpack'
const PLUGIN_NAME = 'ReactRefreshRspackPlugin'
class ReactRefreshRspackPlugin {
static loader = 'builtin:react-refresh-loader'
apply(compiler: Compiler) {
new compiler.webpack.ProvidePlugin({
$ReactRefreshRuntime$: require.resolve('./internal/RspackReactRefresh'),
}).apply(compiler)
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.additionalTreeRuntimeRequirements.tap(
PLUGIN_NAME,
(_, runtimeRequirements) => {
runtimeRequirements.add(compiler.webpack.RuntimeGlobals.moduleCache)
}
)
})
}
}
export default ReactRefreshRspackPlugin
import RefreshHelpers from './helpers'
declare const __webpack_require__: {
c: Record<string | number, { exports: unknown | (() => Promise<unknown>) }>
}
// Extracts exports from a webpack module object.
function getModuleExports(moduleId: string) {
if (typeof moduleId === 'undefined') {
// `moduleId` is unavailable, which indicates that this module is not in the cache,
// which means we won't be able to capture any exports,
// and thus they cannot be refreshed safely.
// These are likely runtime or dynamically generated modules.
return {}
}
var maybeModule = __webpack_require__.c[moduleId]
if (typeof maybeModule === 'undefined') {
// `moduleId` is available but the module in cache is unavailable,
// which indicates the module is somehow corrupted (e.g. broken Webpack `module` globals).
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
console.warn(
'[React Refresh] Failed to get exports for module: ' + moduleId + '.'
)
return {}
}
var exportsOrPromise = maybeModule.exports
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
return exportsOrPromise.then(function (exports) {
return exports
})
}
return exportsOrPromise
}
function executeRuntime(moduleExports, moduleId, webpackHot) {
RefreshHelpers.registerExportsForReactRefresh(moduleExports, moduleId)
if (webpackHot) {
var isHotUpdate = !!webpackHot.data
var prevSignature: unknown[] | null = webpackHot.data?.prevSignature ?? null
if (RefreshHelpers.isReactRefreshBoundary(moduleExports)) {
webpackHot.dispose(
// Save the previous exports signature on update so we can compare the boundary
// signatures. We avoid saving exports themselves since it causes memory leaks (https://github.com/vercel/next.js/pull/53797)
function hotDisposeCallback(data) {
data.prevSignature =
RefreshHelpers.getRefreshBoundarySignature(moduleExports)
}
)
webpackHot.accept()
// This field is set when the previous version of this module was a
// Refresh Boundary, letting us know we need to check for invalidation or
// enqueue an update.
if (prevSignature !== null) {
if (isHotUpdate) {
if (
RefreshHelpers.shouldInvalidateReactRefreshBoundary(
prevSignature,
RefreshHelpers.getRefreshBoundarySignature(moduleExports)
)
) {
webpackHot.invalidate()
} else {
RefreshHelpers.scheduleUpdate()
}
}
}
} else {
if (isHotUpdate && prevSignature !== null) {
webpackHot.invalidate()
}
}
}
}
// Port from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/loader/utils/getRefreshModuleRuntime.js#L29
export function refresh(moduleId, webpackHot) {
const currentExports = getModuleExports(moduleId)
const fn = (exports) => {
executeRuntime(exports, moduleId, webpackHot)
}
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
currentExports.then(fn)
} else {
fn(currentExports)
}
}
export {
register,
createSignatureFunctionForTransform,
} from 'react-refresh/runtime'
import RefreshRuntime from 'react-refresh/runtime'
import type { RefreshRuntimeGlobals } from './runtime'
declare const self: Window & RefreshRuntimeGlobals
if (typeof self !== 'undefined') {
var $RefreshInjected$ = '__reactRefreshInjected'
// Only inject the runtime if it hasn't been injected
if (!self[$RefreshInjected$]) {
RefreshRuntime.injectIntoGlobalHook(self)
// Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
self.$RefreshSig$ = () => (type) => type
self.$RefreshReg$ = () => {}
// Mark the runtime as injected to prevent double-injection
self[$RefreshInjected$] = true
}
}
...@@ -141,9 +141,6 @@ importers: ...@@ -141,9 +141,6 @@ importers:
'@rspack/core': '@rspack/core':
specifier: 1.5.0 specifier: 1.5.0
version: 1.5.0(@swc/helpers@0.5.15) version: 1.5.0(@swc/helpers@0.5.15)
'@rspack/plugin-react-refresh':
specifier: 1.2.0
version: 1.2.0(react-refresh@0.12.0)(webpack-hot-middleware@2.26.1)
'@slack/web-api': '@slack/web-api':
specifier: 7.9.1 specifier: 7.9.1
version: 7.9.1 version: 7.9.1
...@@ -1731,12 +1728,6 @@ importers: ...@@ -1731,12 +1728,6 @@ importers:
'@rspack/core': '@rspack/core':
specifier: 1.5.0 specifier: 1.5.0
version: 1.5.0(@swc/helpers@0.5.15) version: 1.5.0(@swc/helpers@0.5.15)
'@rspack/plugin-react-refresh':
specifier: 1.2.0
version: 1.2.0(react-refresh@0.12.0)(webpack-hot-middleware@2.26.1)
react-refresh:
specifier: 0.12.0
version: 0.12.0
packages/next-swc: packages/next-swc:
devDependencies: devDependencies:
...@@ -5029,15 +5020,6 @@ packages: ...@@ -5029,15 +5020,6 @@ packages:
resolution: {integrity: sha512-VynGOEsVw2s8TAlLf/uESfrgfrq2+rcXB1muPJYBWbsm1Oa6r5qVQhjA5ggM6z/coYPrsVMgovl3Ff7Q7OCp1w==} resolution: {integrity: sha512-VynGOEsVw2s8TAlLf/uESfrgfrq2+rcXB1muPJYBWbsm1Oa6r5qVQhjA5ggM6z/coYPrsVMgovl3Ff7Q7OCp1w==}
engines: {node: '>=16.0.0'} engines: {node: '>=16.0.0'}
'@rspack/plugin-react-refresh@1.2.0':
resolution: {integrity: sha512-DTsbtggCfsiXE5QQtYMS8rKfEF8GIjwPDbgIT6Kg8BlAjpJY4jT5IisyhfIi7YOT3d5RIvu60iFB6Kr9sSMsnA==}
peerDependencies:
react-refresh: '>=0.10.0 <1.0.0'
webpack-hot-middleware: 2.x
peerDependenciesMeta:
webpack-hot-middleware:
optional: true
'@rtsao/scc@1.1.0': '@rtsao/scc@1.1.0':
resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}
...@@ -8658,9 +8640,6 @@ packages: ...@@ -8658,9 +8640,6 @@ packages:
error-ex@1.3.2: error-ex@1.3.2:
resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==}
error-stack-parser@2.1.4:
resolution: {integrity: sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==}
es-abstract@1.20.2: es-abstract@1.20.2:
resolution: {integrity: sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==} resolution: {integrity: sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
...@@ -15213,9 +15192,6 @@ packages: ...@@ -15213,9 +15192,6 @@ packages:
stackback@0.0.2: stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
stackframe@1.3.4:
resolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}
stacktrace-parser@0.1.10: stacktrace-parser@0.1.10:
resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==} resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==}
engines: {node: '>=6'} engines: {node: '>=6'}
...@@ -20838,14 +20814,6 @@ snapshots: ...@@ -20838,14 +20814,6 @@ snapshots:
'@rspack/lite-tapable@1.0.1': {} '@rspack/lite-tapable@1.0.1': {}
'@rspack/plugin-react-refresh@1.2.0(react-refresh@0.12.0)(webpack-hot-middleware@2.26.1)':
dependencies:
error-stack-parser: 2.1.4
html-entities: 2.6.0
react-refresh: 0.12.0
optionalDependencies:
webpack-hot-middleware: 2.26.1
'@rtsao/scc@1.1.0': {} '@rtsao/scc@1.1.0': {}
'@rushstack/eslint-patch@1.10.4': {} '@rushstack/eslint-patch@1.10.4': {}
...@@ -25129,10 +25097,6 @@ snapshots: ...@@ -25129,10 +25097,6 @@ snapshots:
dependencies: dependencies:
is-arrayish: 0.2.1 is-arrayish: 0.2.1
error-stack-parser@2.1.4:
dependencies:
stackframe: 1.3.4
es-abstract@1.20.2: es-abstract@1.20.2:
dependencies: dependencies:
call-bind: 1.0.7 call-bind: 1.0.7
...@@ -33815,8 +33779,6 @@ snapshots: ...@@ -33815,8 +33779,6 @@ snapshots:
stackback@0.0.2: stackback@0.0.2:
optional: true optional: true
stackframe@1.3.4: {}
stacktrace-parser@0.1.10(patch_hash=x5tdcojc7b5m2b5ojepbcdl36a): stacktrace-parser@0.1.10(patch_hash=x5tdcojc7b5m2b5ojepbcdl36a):
dependencies: dependencies:
type-fest: 0.7.1 type-fest: 0.7.1
...@@ -104,6 +104,27 @@ describe('ReactRefreshLogBox app', () => { ...@@ -104,6 +104,27 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "no",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (3:7) @ eval
> 3 | throw new Error('no')
| ^",
"stack": [
"eval index.js (3:7)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"eval ./app/page.js",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
......
...@@ -8,6 +8,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -8,6 +8,7 @@ describe('ReactRefreshLogBox', () => {
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')), files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true, skipStart: true,
}) })
const isRspack = !!process.env.NEXT_RSPACK
// Module trace is only available with webpack 5 // Module trace is only available with webpack 5
test('Node.js builtins', async () => { test('Node.js builtins', async () => {
...@@ -57,6 +58,25 @@ describe('ReactRefreshLogBox', () => { ...@@ -57,6 +58,25 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module not found: Can't resolve 'dns' in '<FIXME-project-root>/node_modules/my-package'",
"environmentLabel": null,
"label": "Build Error",
"source": "./node_modules/my-package/index.js
× Module not found: Can't resolve 'dns' in '<FIXME-project-root>/node_modules/my-package'
╭─[1:12]
1 │ const dns = require('dns')
· ──────────────
2 │ module.exports = dns
╰────
Import trace for requested module:
./node_modules/my-package/index.js
./index.js",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -105,6 +125,27 @@ describe('ReactRefreshLogBox', () => { ...@@ -105,6 +125,27 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module not found: Can't resolve 'b' in '<FIXME-project-root>'",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>'
╭─[2:17]
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", {
╰────
Import trace for requested module:
./index.js
./pages/index.js",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -153,6 +194,26 @@ describe('ReactRefreshLogBox', () => { ...@@ -153,6 +194,26 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module not found: Can't resolve 'b' in '<FIXME-project-root>/pages'",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/index.js
× Module not found: Can't resolve 'b' in '<FIXME-project-root>/pages'
╭─[2:17]
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", {
╰────
Import trace for requested module:
./pages/index.js",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -208,6 +269,24 @@ describe('ReactRefreshLogBox', () => { ...@@ -208,6 +269,24 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module not found: Can't resolve './non-existent.css' in '<FIXME-project-root>/pages'",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_app.js
× Module not found: Can't resolve './non-existent.css' in '<FIXME-project-root>/pages'
╭─[2:7]
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, {
╰────",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -11,13 +11,13 @@ import path from 'path' ...@@ -11,13 +11,13 @@ import path from 'path'
import { outdent } from 'outdent' import { outdent } from 'outdent'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18 const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
const isRspack = !!process.env.NEXT_RSPACK
describe('ReactRefreshLogBox', () => { describe('ReactRefreshLogBox', () => {
const { isTurbopack, next } = nextTestSetup({ const { isTurbopack, next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')), files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true, skipStart: true,
}) })
const isRspack = !!process.env.NEXT_RSPACK
test('should strip whitespace correctly with newline', async () => { test('should strip whitespace correctly with newline', async () => {
await using sandbox = await createSandbox(next) await using sandbox = await createSandbox(next)
...@@ -174,6 +174,32 @@ describe('ReactRefreshLogBox', () => { ...@@ -174,6 +174,32 @@ describe('ReactRefreshLogBox', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "no",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (3:7) @ eval
> 3 | throw new Error('no')
| ^",
"stack": [
"eval index.js (3:7)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"eval ./pages/index.js",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -331,6 +357,22 @@ describe('ReactRefreshLogBox', () => { ...@@ -331,6 +357,22 @@ describe('ReactRefreshLogBox', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "no",
"environmentLabel": null,
"label": "Runtime Error",
"source": "FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^",
"stack": [
"FunctionDefault FunctionDefault.js (1:51)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -417,6 +459,39 @@ describe('ReactRefreshLogBox', () => { ...@@ -417,6 +459,39 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js
× Module build failed:
╰─▶ × Error: x Unexpected token. Did you mean \`{'}'}\` or \`&rbrace;\`?
│ ,-[7:1]
│ 4 | <p>lol</p>
│ 5 | div
│ 6 | )
│ 7 | }
│ : ^
│ \`----
│ x Expected '</', got '<eof>'
│ ,-[7:1]
│ 4 | <p>lol</p>
│ 5 | div
│ 6 | )
│ 7 | }
│ \`----
│
│
│ Caused by:
│ Syntax Error
Import trace for requested module:
./index.js
./pages/index.js",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -571,6 +646,22 @@ describe('ReactRefreshLogBox', () => { ...@@ -571,6 +646,22 @@ describe('ReactRefreshLogBox', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "",
"environmentLabel": null,
"label": "Runtime Error",
"source": "Child.js (4:11) @ ClickCount.render
> 4 | throw new Error()
| ^",
"stack": [
"ClickCount.render Child.js (4:11)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -643,6 +734,28 @@ describe('ReactRefreshLogBox', () => { ...@@ -643,6 +734,28 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.module.css
× Module build failed:
╰─▶ × SyntaxError
│
│ (1:1) <FIXME-project-root>/index.module.css Unknown word
│
│ > 1 | .button
│ | ^
│
Import trace for requested module:
./index.module.css
./index.js
./pages/index.js",
"stack": [],
}
`)
} else { } else {
await expect({ browser, next }).toDisplayRedbox(` await expect({ browser, next }).toDisplayRedbox(`
{ {
...@@ -683,6 +796,28 @@ describe('ReactRefreshLogBox', () => { ...@@ -683,6 +796,28 @@ describe('ReactRefreshLogBox', () => {
"stack": [], "stack": [],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.module.css
× Module build failed:
╰─▶ × CssSyntaxError
│
│ (1:1) Selector "button" is not pure (pure selectors must contain at least one local class or id)
│
│ > 1 | button {}
│ | ^
│
Import trace for requested module:
./index.module.css
./index.js
./pages/index.js",
"stack": [],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -321,6 +321,22 @@ describe('pages/ error recovery', () => { ...@@ -321,6 +321,22 @@ describe('pages/ error recovery', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "oops",
"environmentLabel": null,
"label": "Runtime Error",
"source": "child.js (3:9) @ Child
> 3 | throw new Error('oops')
| ^",
"stack": [
"Child child.js (3:9)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -776,6 +792,22 @@ describe('pages/ error recovery', () => { ...@@ -776,6 +792,22 @@ describe('pages/ error recovery', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "React is not defined",
"environmentLabel": null,
"label": "Runtime ReferenceError",
"source": "Foo.js (3:3) @ Foo
> 3 | return React.createElement('h1', null, 'Foo');
| ^",
"stack": [
"Foo Foo.js (3:3)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -35,6 +35,25 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => { ...@@ -35,6 +35,25 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component." \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."
`) `)
} else if (process.env.NEXT_RSPACK) {
expect(redbox.description).toMatchInlineSnapshot(
`" × Module build failed:"`
)
expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js
× Module build failed:
╰─▶ × Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component.
│ ,-[3:1]
│ 1 | import dynamic from 'next/dynamic'
│ 2 |
│ 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
│ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ 4 |
│ 5 | export default function Page() {
│ 6 | return <DynamicClient />
│ \`----
│"
`)
} else { } else {
expect(redbox.description).toMatchInlineSnapshot( expect(redbox.description).toMatchInlineSnapshot(
`" x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."` `" x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."`
......
...@@ -26,6 +26,12 @@ describe('font-loader-in-document-error', () => { ...@@ -26,6 +26,12 @@ describe('font-loader-in-document-error', () => {
next/font: error: next/font: error:
Cannot be used within _document.js" Cannot be used within _document.js"
`) `)
} else if (process.env.NEXT_RSPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"pages/_document.js
× \`next/font\` error:
│ Cannot be used within pages/_document.js."
`)
} else { } else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"pages/_document.js "pages/_document.js
......
...@@ -16,6 +16,7 @@ describe('Client Navigation', () => { ...@@ -16,6 +16,7 @@ describe('Client Navigation', () => {
TEST_STRICT_NEXT_HEAD: String(true), TEST_STRICT_NEXT_HEAD: String(true),
}, },
}) })
const isRspack = !!process.env.NEXT_RSPACK
describe('with empty getInitialProps()', () => { describe('with empty getInitialProps()', () => {
it('should render a redbox', async () => { it('should render a redbox', async () => {
...@@ -361,6 +362,23 @@ describe('Client Navigation', () => { ...@@ -361,6 +362,23 @@ describe('Client Navigation', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "An Expected error occurred",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/error-in-the-browser-global-scope.js (2:9) @ eval
> 2 | throw new Error('An Expected error occurred')
| ^",
"stack": [
"eval pages/error-in-the-browser-global-scope.js (2:9)",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
"<FIXME-next-dist-dir>",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -1225,6 +1225,34 @@ describe('Cache Components Errors', () => { ...@@ -1225,6 +1225,34 @@ describe('Cache Components Errors', () => {
}, },
] ]
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
[
{
"description": "Route "/sync-cookies" used \`cookies().get\`. \`cookies()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/sync-cookies/page.tsx (17:25) @ CookiesReadingComponent
> 17 | const token = (cookies() as unknown as UnsafeUnwrappedCookies).get('token')
| ^",
"stack": [
"CookiesReadingComponent app/sync-cookies/page.tsx (17:25)",
"Page app/sync-cookies/page.tsx (11:7)",
],
},
{
"description": "(0 , <webpack-module-id>.cookies)(...).get is not a function",
"environmentLabel": "Prerender",
"label": "Runtime TypeError",
"source": "app/sync-cookies/page.tsx (17:66) @ CookiesReadingComponent
> 17 | const token = (cookies() as unknown as UnsafeUnwrappedCookies).get('token')
| ^",
"stack": [
"CookiesReadingComponent app/sync-cookies/page.tsx (17:66)",
],
},
]
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
...@@ -1379,6 +1407,34 @@ describe('Cache Components Errors', () => { ...@@ -1379,6 +1407,34 @@ describe('Cache Components Errors', () => {
}, },
] ]
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
[
{
"description": "Route "/sync-cookies-runtime" used \`cookies().get\`. \`cookies()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/sync-cookies-runtime/page.tsx (24:25) @ CookiesReadingComponent
> 24 | const token = (cookies() as unknown as UnsafeUnwrappedCookies).get('token')
| ^",
"stack": [
"CookiesReadingComponent app/sync-cookies-runtime/page.tsx (24:25)",
"Page app/sync-cookies-runtime/page.tsx (14:9)",
],
},
{
"description": "(0 , <webpack-module-id>.cookies)(...).get is not a function",
"environmentLabel": "Server",
"label": "Runtime TypeError",
"source": "app/sync-cookies-runtime/page.tsx (24:66) @ CookiesReadingComponent
> 24 | const token = (cookies() as unknown as UnsafeUnwrappedCookies).get('token')
| ^",
"stack": [
"CookiesReadingComponent app/sync-cookies-runtime/page.tsx (24:66)",
],
},
]
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
...@@ -1468,6 +1524,21 @@ describe('Cache Components Errors', () => { ...@@ -1468,6 +1524,21 @@ describe('Cache Components Errors', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/sync-draft-mode" used \`draftMode().isEnabled\`. \`draftMode()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/sync-draft-mode/page.tsx (23:31) @ DraftModeReadingComponent
> 23 | const isEnabled = (draftMode() as unknown as UnsafeUnwrappedDraftMode)
| ^",
"stack": [
"DraftModeReadingComponent app/sync-draft-mode/page.tsx (23:31)",
"Page app/sync-draft-mode/page.tsx (13:7)",
],
}
`)
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
...@@ -1542,6 +1613,34 @@ describe('Cache Components Errors', () => { ...@@ -1542,6 +1613,34 @@ describe('Cache Components Errors', () => {
}, },
] ]
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
[
{
"description": "Route "/sync-headers" used \`headers().get\`. \`headers()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/sync-headers/page.tsx (17:29) @ HeadersReadingComponent
> 17 | const userAgent = (headers() as unknown as UnsafeUnwrappedHeaders).get(
| ^",
"stack": [
"HeadersReadingComponent app/sync-headers/page.tsx (17:29)",
"Page app/sync-headers/page.tsx (11:7)",
],
},
{
"description": "(0 , <webpack-module-id>.headers)(...).get is not a function",
"environmentLabel": "Prerender",
"label": "Runtime TypeError",
"source": "app/sync-headers/page.tsx (17:70) @ HeadersReadingComponent
> 17 | const userAgent = (headers() as unknown as UnsafeUnwrappedHeaders).get(
| ^",
"stack": [
"HeadersReadingComponent app/sync-headers/page.tsx (17:70)",
],
},
]
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
...@@ -1696,6 +1795,34 @@ describe('Cache Components Errors', () => { ...@@ -1696,6 +1795,34 @@ describe('Cache Components Errors', () => {
}, },
] ]
`) `)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(`
[
{
"description": "Route "/sync-headers-runtime" used \`headers().get\`. \`headers()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/sync-headers-runtime/page.tsx (24:29) @ HeadersReadingComponent
> 24 | const userAgent = (headers() as unknown as UnsafeUnwrappedHeaders).get(
| ^",
"stack": [
"HeadersReadingComponent app/sync-headers-runtime/page.tsx (24:29)",
"Page app/sync-headers-runtime/page.tsx (14:9)",
],
},
{
"description": "(0 , <webpack-module-id>.headers)(...).get is not a function",
"environmentLabel": "Server",
"label": "Runtime TypeError",
"source": "app/sync-headers-runtime/page.tsx (24:70) @ HeadersReadingComponent
> 24 | const userAgent = (headers() as unknown as UnsafeUnwrappedHeaders).get(
| ^",
"stack": [
"HeadersReadingComponent app/sync-headers-runtime/page.tsx (24:70)",
],
},
]
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
......
...@@ -27,6 +27,7 @@ describe('app-dir - server source maps', () => { ...@@ -27,6 +27,7 @@ describe('app-dir - server source maps', () => {
// Manually verify that the runtime logs match. // Manually verify that the runtime logs match.
skipDeployment: true, skipDeployment: true,
}) })
const isRspack = !!process.env.NEXT_RSPACK
if (skipped) return if (skipped) return
...@@ -490,6 +491,28 @@ describe('app-dir - server source maps', () => { ...@@ -490,6 +491,28 @@ describe('app-dir - server source maps', () => {
], ],
} }
`) `)
} else if (isRspack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "module-evaluation",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/module-evaluation/module.js (1:22) @ eval
> 1 | export const error = new Error('module-evaluation')
| ^",
"stack": [
"eval app/module-evaluation/module.js (1:22)",
"<FIXME-file-protocol>",
"<FIXME-file-protocol>",
"eval about:/Prerender/webpack-internal:///(rsc)/app/module-evaluation/page.js (5:60)",
"<FIXME-file-protocol>",
"<FIXME-file-protocol>",
"Function.all <anonymous>",
"Function.all <anonymous>",
"Page <anonymous>",
],
}
`)
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
...@@ -579,6 +602,45 @@ describe('app-dir - server source maps', () => { ...@@ -579,6 +602,45 @@ describe('app-dir - server source maps', () => {
}, },
] ]
`) `)
} else if (isRspack) {
// 2nd error from runHiddenSetOfSetsInternal hits https://linear.app/vercel/issue/NEXT-4412
await expect(browser).toDisplayCollapsedRedbox(`
[
{
"description": "rsc-anonymous-stack-frame-sandwich: external",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/rsc-anonymous-stack-frame-sandwich/page.js (5:29) @ Page
> 5 | runHiddenSetOfSetsExternal('rsc-anonymous-stack-frame-sandwich: external')
| ^",
"stack": [
"Set.forEach <anonymous>",
"Set.forEach <anonymous>",
"Page app/rsc-anonymous-stack-frame-sandwich/page.js (5:29)",
"Page <anonymous>",
],
},
{
"description": "rsc-anonymous-stack-frame-sandwich: internal",
"environmentLabel": "Prerender",
"label": "Console Error",
"source": "app/rsc-anonymous-stack-frame-sandwich/page.js (6:29) @ Page
> 6 | runHiddenSetOfSetsInternal('rsc-anonymous-stack-frame-sandwich: internal')
| ^",
"stack": [
"eval webpack-internal:/(ssr)/internal-pkg/ignored.ts (18:54)",
"eval webpack-internal:/(ssr)/internal-pkg/ignored.ts (12:7)",
"Set.forEach <anonymous>",
"eval webpack-internal:/(ssr)/internal-pkg/ignored.ts (11:9)",
"Set.forEach <anonymous>",
"runSetOfSets webpack-internal:/(ssr)/internal-pkg/ignored.ts (10:13)",
"runHiddenSetOfSets webpack-internal:/(ssr)/internal-pkg/ignored.ts (18:3)",
"Page app/rsc-anonymous-stack-frame-sandwich/page.js (6:29)",
"Page <anonymous>",
],
},
]
`)
} else { } else {
// 2nd error from runHiddenSetOfSetsInternal hits https://linear.app/vercel/issue/NEXT-4412 // 2nd error from runHiddenSetOfSetsInternal hits https://linear.app/vercel/issue/NEXT-4412
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
......
...@@ -7,6 +7,8 @@ const cacheComponentsEnabled = ...@@ -7,6 +7,8 @@ const cacheComponentsEnabled =
const pprEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' const pprEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const isRspack = !!process.env.NEXT_RSPACK
describe('build-output-prerender', () => { describe('build-output-prerender', () => {
describe('with a next config file', () => { describe('with a next config file', () => {
describe('without --debug-prerender', () => { describe('without --debug-prerender', () => {
...@@ -76,6 +78,15 @@ describe('build-output-prerender', () => { ...@@ -76,6 +78,15 @@ describe('build-output-prerender', () => {
✓ ppr (enabled by \`experimental.cacheComponents\`) ✓ ppr (enabled by \`experimental.cacheComponents\`)
✓ rdcForNavigations (enabled by \`experimental.ppr\`)" ✓ rdcForNavigations (enabled by \`experimental.ppr\`)"
`) `)
} else if (isRspack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (Rspack)
- Experiments (use with caution):
✓ cacheComponents
✓ enablePrerenderSourceMaps (enabled by \`experimental.cacheComponents\`)
✓ ppr (enabled by \`experimental.cacheComponents\`)
✓ rdcForNavigations (enabled by \`experimental.ppr\`)"
`)
} else { } else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (webpack) "▲ Next.js x.y.z (webpack)
...@@ -209,6 +220,19 @@ describe('build-output-prerender', () => { ...@@ -209,6 +220,19 @@ describe('build-output-prerender', () => {
✓ serverSourceMaps (enabled by \`--debug-prerender\`) ✓ serverSourceMaps (enabled by \`--debug-prerender\`)
⨯ turbopackMinify (disabled by \`--debug-prerender\`)" ⨯ turbopackMinify (disabled by \`--debug-prerender\`)"
`) `)
} else if (isRspack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Rspack)
- Experiments (use with caution):
✓ cacheComponents
✓ enablePrerenderSourceMaps (enabled by \`--debug-prerender\`)
✓ ppr (enabled by \`experimental.cacheComponents\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ rdcForNavigations (enabled by \`experimental.ppr\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`)
} else { } else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production. "⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
...@@ -316,6 +340,10 @@ describe('build-output-prerender', () => { ...@@ -316,6 +340,10 @@ describe('build-output-prerender', () => {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot( expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(
`"▲ Next.js x.y.z (Turbopack)"` `"▲ Next.js x.y.z (Turbopack)"`
) )
} else if (isRspack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(
`"▲ Next.js x.y.z (Rspack)"`
)
} else { } else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot( expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(
`"▲ Next.js x.y.z (webpack)"` `"▲ Next.js x.y.z (webpack)"`
...@@ -408,6 +436,16 @@ describe('build-output-prerender', () => { ...@@ -408,6 +436,16 @@ describe('build-output-prerender', () => {
✓ serverSourceMaps (enabled by \`--debug-prerender\`) ✓ serverSourceMaps (enabled by \`--debug-prerender\`)
⨯ turbopackMinify (disabled by \`--debug-prerender\`)" ⨯ turbopackMinify (disabled by \`--debug-prerender\`)"
`) `)
} else if (isRspack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Rspack)
- Experiments (use with caution):
✓ enablePrerenderSourceMaps (enabled by \`--debug-prerender\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`)
} else { } else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production. "⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
......
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