Unverified Commit 4cc12cc5 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

fix(next-rspack): restore webpack export presence semantics

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 4c27a1a5
...@@ -2313,9 +2313,12 @@ export default async function getBaseWebpackConfig( ...@@ -2313,9 +2313,12 @@ export default async function getBaseWebpackConfig(
webpack5Config.module!.parser = { webpack5Config.module!.parser = {
javascript: { javascript: {
url: 'relative', url: 'relative',
// Rspack defaults missing imported exports to errors, unlike webpack. // Rspack 2 defaults `exportsPresence` to 'error', while webpack only
// Preserve compatibility for imports removed by tree shaking. // warns about missing exports in non-strict ESM. Next.js feature-detects
...(isRspack ? { importExportsPresence: 'warn' } : undefined), // React 19-only APIs (e.g. `use`, `cache`, `captureOwnerStack`) that are
// absent from React 18 or from React's production builds, so restore
// webpack's behavior for both imports and re-exports.
...(isRspack ? { exportsPresence: 'warn' } : undefined),
}, },
} }
webpack5Config.module!.generator = { webpack5Config.module!.generator = {
......
...@@ -112,7 +112,8 @@ describe('ReactRefreshLogBox', () => { ...@@ -112,7 +112,8 @@ describe('ReactRefreshLogBox', () => {
` `
) )
if (isReact18) { // Rspack reports the same error under React 18 and React 19.
if (isReact18 && !isRspack) {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -306,33 +307,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -306,33 +307,6 @@ describe('ReactRefreshLogBox', () => {
}, },
] ]
`) `)
} else if (isReact18 && 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)",
],
},
{
"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)",
],
},
]
`)
} else { } else {
if (isRspack) { if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
...@@ -573,33 +547,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -573,33 +547,6 @@ describe('ReactRefreshLogBox', () => {
}, },
] ]
`) `)
} else if (isReact18 && 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)",
],
},
{
"description": "",
"environmentLabel": null,
"label": "Runtime Error",
"source": "Child.js (4:11) @ ClickCount.render
> 4 | throw new Error()
| ^",
"stack": [
"ClickCount.render Child.js (4:11)",
],
},
]
`)
} else { } else {
if (isRspack) { if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
......
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