-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js 13.4.9 - SWC minification breaks production builds #54192
Comments
Update: @kdy1 - it looks like the problem is not with SWC. This is the generated code with 7228: function (e, r, n) {
"use strict";
n.r(r),
n.d(r, {
ClientCompoenent: function () {
return u;
},
});
var t = n(9268),
o = n(6006);
let s = (0, o.createContext)({}),
u = () => {
let [e, r] = (0, o.useState)(0);
return (0, t.jsxs)(t.Fragment, {
children: [
(0, t.jsx)(
(e) => {
let { children: r } = e;
return (0, t.jsx)(s.Provider, { value: {}, children: r });
},
{ children: (0, t.jsx)("input", {}) }
),
(0, t.jsx)("button", {
onClick: () => {
console.log("click"), r(e + 1);
},
children: "+1 (rerender)",
}),
],
});
};
}, and this is the broken code with 7365: function (e, r, n) {
"use strict";
n.r(r),
n.d(r, {
ClientCompoenent: function () {
return u;
},
});
var t = n(9268),
o = n(6006);
let s = (0, o.createContext)({}),
u = () => {
let [e, r] = (0, o.useState)(0);
return (0, t.jsxs)(t.Fragment, {
children: [
(0, t.jsx)(
(e) => {
let { children: r } = e;
return (0, t.jsx)(s.Provider, { value: {}, children: r });
},
{ children: (0, t.jsx)("input", {}) }
),
(0, t.jsx)("button", {
onClick: () => {
console.log("click"), r(e + 1);
},
children: "+1 (rerender)",
}),
],
});
};
}, as you can see (beside the module id) the code is exactly the same as before.. I can only guess but it might be because of the react upgrade from |
@jaggli has just created a new react issue: facebook/react#27248 |
I boiled down the problem to the following two statements, which are the equivalent of the code being generated through SWC, under certain conditions like shown above.
I'm not sure what de documentation is referring to, when they say
https://react.dev/reference/react/createElement So in case this sentence says: "You can't dynamically nest |
#7839) **Related issue:** - vercel/next.js#54192.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.19 pnpm: 8.6.11 Relevant Packages: next: 13.4.17 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
SWC minifier (swcMinify: true)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/jantimon/next-swc-minification-reproduction/
To Reproduce
Describe the Bug
The bug was introduced in
[email protected]
- all early versions (e.g.[email protected]
) work fine.The issue seems to be part of this change: v13.4.9-canary.1...v13.4.9-canary.2
ContextExample.tsx
Client Component.tsx
During minifcation SWC will inline the
ContextProvider
component right into the render function:It looks like SWC does this minification only if a dot is in the component name.
changing
ContextDemo.Provider
toContextDemoProvider
fixes the issue.Expected Behavior
Running
npm dev
will not trigger the swc minifcation and runs properly.A rerender will not unmount components and the input will keep its value:
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1530
The text was updated successfully, but these errors were encountered: