question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

swcMinify causes some problems

See original GitHub issue

Verify 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: image

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:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lemoniedcommented, Sep 17, 2022

You can try the latest canary https://github.com/vercel/next.js/releases/tag/v12.3.1-canary.3 and see if the problem still there. The fix of swc-project/swc#5846 has been included in v12.3.1-canary.3.

It’s useful for me, the problem disappeared in version v12.3.1-canary.3, Thanks!

0reactions
github-actions[bot]commented, Oct 17, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found