swcMinify causes some problems
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 16.17.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 12.3.1-canary.2 eslint-config-next: 12.3.0 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
Google Chrome 105.0.5195.102
How are you deploying your application? (if relevant)
next start
Describe the Bug
In development mode everything works fine.
Program crashed when I execute npm run build
and npm run start
,However when I set swcMinify
to false
everything works fine again
crash in production mode with swcMinify: true
:
Expected Behavior
I expect the program to behave the same on npm run dev
and npm run start
Link to reproduction
https://codesandbox.io/s/agitated-tree-t3jml4?file=/pages/index.tsx
To Reproduce
import Highlight, { defaultProps } from "prism-react-renderer";
const exampleCode = `
export class Store<T> {
public map<I>(i: I): I {
return i;
}
}
export const createStore = <T>(defaultState: T) => {
return new Store(defaultState);
};
`;
export default function Home() {
return (
<Highlight {...defaultProps} code={exampleCode} language="typescript">
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div key={i} {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
)
}
The above code works fine in the development mode
,crash in production mode with swcMinify: true
but works fine with swcMinify: false
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
nextjs v12 swcMinify set to true - Stack Overflow
Create a new file and name it .babelrc (if it does not exist) and add following content: { "presets": ["next/babel"] }.
Read more >Why You Should Replace Babel with SWC in Next.js
Therefore, this article will compare Babel and SWC and help you make an educated decision when choosing a suitable compiler for your next...
Read more >Upgrade Guide - Next.js
The swcMinify configuration property was changed from false to true . ... CSS is used that would previously slip through and cause unexpected...
Read more >Journey toward a fast and good minifier
The main reason is that, no one in the planet, including me, ... I learned lots of things while working on the performance...
Read more >Becky/ShinjiBekki (@shinji_becky) / Twitter
swcMinify causes some problems · Issue #40601 · vercel/next.js. Verify canary release I verified that the issue exists in the latest Next.js canary...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s useful for me, the problem disappeared in version v12.3.1-canary.3, Thanks!
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.