Skip to content
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

swcMinify causes some problems #40601

Closed
1 task done
lemonied opened this issue Sep 16, 2022 · 10 comments
Closed
1 task done

swcMinify causes some problems #40601

lemonied opened this issue Sep 16, 2022 · 10 comments

Comments

@lemonied
Copy link

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

@lemonied lemonied added the bug Issue was opened via the bug report template. label Sep 16, 2022
@lemonied
Copy link
Author

This problem occurs when I upgrade the version to 12.3.0,everything works fine in 12.2.5

@lemonied
Copy link
Author

can someone help me 🧐

@sushantdhiman
Copy link

sushantdhiman commented Sep 16, 2022

I can also confirm similar issue with swcMinify: true

Uncaught (in promise) TypeError: h is undefined
    NextJS 16
        nhw
        n_U
        nfq
        td
        td
        pf
        pf
        pf
        Ze
        Ze
        dispatch
        n
        dispatch
        dispatch
        saveDispatch
        postMessage
Caused by: undefined
[94d85b83-ad559083d4c6fd15.js:1:408967](___chunks/94d85b83-ad559083d4c6fd15.js)

@lemonied
Copy link
Author

@sushantdhiman Are you also using version 12.3.0? I have this problem after upgrading to 12.3.0

@Austaras
Copy link

Should be duplicate of swc-project/swc#5846

@balazsorban44 balazsorban44 added kind: bug and removed bug Issue was opened via the bug report template. labels Sep 16, 2022
@zzfn
Copy link

zzfn commented Sep 16, 2022

me too

@chentsulin
Copy link
Contributor

chentsulin commented 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.

@zzfn
Copy link

zzfn commented 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 should be included in v12.3.1-canary.3.

no,it still break when i use import multiavatar from '@multiavatar/multiavatar/esm'

{
    "@multiavatar/multiavatar": "^1.0.7",
}

@lemonied
Copy link
Author

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!

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants