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

Setting swcMinify: true in production causes a client-side exception #46887

Closed
1 task done
daanboer opened this issue Mar 7, 2023 · 14 comments · Fixed by vercel/turbo#8097
Closed
1 task done

Setting swcMinify: true in production causes a client-side exception #46887

daanboer opened this issue Mar 7, 2023 · 14 comments · Fixed by vercel/turbo#8097
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@daanboer
Copy link

daanboer commented Mar 7, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1-NixOS SMP Wed Feb 22 11:57:12 UTC 2023
    Binaries:
      Node: 18.14.2
      npm: 9.5.0
      Yarn: N/A
      pnpm: 7.26.3
    Relevant packages:
      next: 13.2.4-canary.5
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

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

SWC minifier (swcMinify: true)

Link to the code that reproduces this issue

https://github.com/daanboer/next-citationjs-repro

To Reproduce

Setup and run the example code using:

pnpm install
pnpm build
pnpm start

Then visit localhost:3000. This will issue a client-side exception, and the formatted citation is not shown.

Describe the Bug

Using the @citation-js/core, and @citation-js/plugin-csl packages to format a CSL-json document results in a client-side exception when combined with swcMinify: true. Disabling swcMinify results in the desired behavior and the formatted citation is shown without any errors. This bug only occurs in production, enabling swcMinify in the dev environment works just fine.

Expected Behavior

The generated page should not issue any errors and show a formatted citation.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@daanboer daanboer added the bug Issue was opened via the bug report template. label Mar 7, 2023
@LunaTK
Copy link

LunaTK commented Apr 19, 2023

Having a same issue.

@avitorio
Copy link

Hey @daanboer and @LunaTK , I'm currently experiencing this. Did you all find a solution? My package breaks on next.js if swcMinify isn't set to false...

@daanboer
Copy link
Author

Hey @daanboer and @LunaTK , I'm currently experiencing this. Did you all find a solution? My package breaks on next.js if swcMinify isn't set to false...

Nope, sadly I haven't found a solution, and the issue still persists.

@LunaTK
Copy link

LunaTK commented Jun 20, 2023

Me neither. Still using next.js with swcMinify disabled :(

Seems like the bug is due to the duplicated identifier from minified code.

@kcrwfrd
Copy link

kcrwfrd commented May 14, 2024

We started experiencing a TypeError from another package after upgrading to 14.2.3 ... if we set swcMinify: false or downgrade to 14.1.4, it works fine.

@daanboer
Copy link
Author

daanboer commented May 15, 2024

Yes, this problem seems to have returned in 14.2.~. I have updated the reproduction example to the 14.3.0 canary. It now uses the app router and the error has moved to the build step. This issue starts to become more pressing, as swcMinify is being deprecated in the near future.

@huozhi
Copy link
Member

huozhi commented May 15, 2024

@kcrwfrd @daanboer could you share a reproduction repo about your issue?

@daanboer
Copy link
Author

@huozhi sure, a reproduction example can be found here: https://github.com/daanboer/next-citationjs-repro.

@huozhi
Copy link
Member

huozhi commented May 15, 2024

Sorry for duplicated tagging, forgot to mention we're already investigating that one. Asking @\kcrwfrd 's case to see if it's a different case 🙏 thanks!

@kdy1 kdy1 self-assigned this May 15, 2024
@kdy1 kdy1 added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label May 15, 2024
@kcrwfrd
Copy link

kcrwfrd commented May 15, 2024

Sorry for duplicated tagging, forgot to mention we're already investigating that one. Asking @\kcrwfrd 's case to see if it's a different case 🙏 thanks!

My encounter with the bug involved another package so I don't have it isolated very well, but I can put something together @huozhi

@kcrwfrd
Copy link

kcrwfrd commented May 15, 2024

@huozhi okay I just successfully put together a reproduction: https://github.com/kcrwfrd/next-swc-minify-bug-reproduction

Thanks for looking into it 🙏🏼

@timneutkens timneutkens added linear: next Confirmed issue that is tracked by the Next.js team. and removed linear: turbopack Confirmed issue that is tracked by the Turbopack team. labels May 15, 2024
@kdy1
Copy link
Member

kdy1 commented May 16, 2024

swc-project/swc#8956 will fix this issue, and the issue reported by @kcrwfrd will be fixed by swc-project/swc#8957.
I'll close this with swc_core update PRs.

Thank you for reporting and creating a repro! Fixing a minifier bug is nearly impossible without a good repro.

kdy1 added a commit to swc-project/swc that referenced this issue May 16, 2024
kdy1 added a commit to swc-project/swc that referenced this issue May 16, 2024
kdy1 added a commit to vercel/turbo that referenced this issue May 17, 2024
### Description


 - Closes PACK-3042
 - Closes NEXT-3241
 - Closes NEXT-3242
 - Closes vercel/next.js#46887
 - Closes vercel/next.js#65064
 - Closes vercel/next.js#65066
 - Closes vercel/next.js#65237

### Testing Instructions

See [next.js counterpart](vercel/next.js#65450)
@daanboer
Copy link
Author

@kdy1 Thank you for treating this issue. I have updated the reproduction example to use the latest canary release (14.3.0-canary.70), but the problem still persists. Is this to be expected?

Copy link
Contributor

github-actions bot commented Jun 1, 2024

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.

@github-actions github-actions bot added the locked label Jun 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants