vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.91k stars 26.87k forks source link

Production build minification results in 'invalid left hand assignment' #52373

Open petyosi opened 1 year ago

petyosi commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103
    Binaries:
      Node: 18.16.1
      npm: 9.5.1
      Yarn: 1.22.19
      pnpm: 8.3.0
    Relevant Packages:
      next: 13.4.9-canary.3
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/petyosi/lezer-minification-next

To Reproduce

image

Describe the Bug

I believe that this is a bug in the minification. Going to the location in the minified source code, I see code that seems to assign something to 0. The package that causes the culprit is @lezer/markdown, used by codemirror.

Expected Behavior

No minification error

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

gudvinga commented 1 year ago

Have the similar issue with minification on last canary release

TypeError: Cannot read properties of undefined (reading 'cat')

If turn off minification with webpack everything is fine.

module.exports = (nextConfig) => {
  return {
    ...nextConfig,
    webpack(webpackConfig) {
      return {
        ...webpackConfig,
        optimization: {
          minimize: false
        }
      };
    }
  };
};

next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103
    Binaries:
      Node: 16.18.0
      npm: 9.2.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.10-canary.3
      eslint-config-next: 13.1.1
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: N/A
petyosi commented 1 year ago

More information, this is a bug in SWC - https://github.com/swc-project/swc/issues/7640.

gudvinga commented 1 year ago

More information, this is a bug in SWC - swc-project/swc#7640.

Thanks, swcMinify: false -- like a workaround

jprjr commented 1 year ago

It looks like this is fixed in @swc/core 1.3.68 (the latest release).

loukamb commented 11 months ago

Any updates on this? It creates hydration errors in component MDXEditor which I am using for my project. https://github.com/mdx-editor/editor/issues/4

petyosi commented 11 months ago

@mblouka, mdxeditor author here, I believe that this is resolved in the latest Next.js release.

cmdcolin commented 8 months ago

we saw an example of this with a library here, using swcMinify:false fixed it but hopefully could get a fix from swc also https://github.com/molstar/molstar/issues/1046

tested with next 14.10

repro https://github.com/cmdcolin/nextjs-molstar-swc-minify-error