next.js icon indicating copy to clipboard operation
next.js copied to clipboard

13.0.3+13.0.4 production builds cause some external libraries to misbehave

Open apancutt opened this issue 3 years ago • 7 comments

Verify canary release

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

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.11.0
      npm: 8.19.2
      Yarn: 3.2.4
      pnpm: N/A
    Relevant packages:
      next: 13.0.3
      eslint-config-next: 13.0.3
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Production builds of next 13.0.3 cause luxon to break - I suspect the impact is more widespread than just this library hence reporting here.

Development builds work fine.

The specific issue I'm seeing is that DateTime.now().toISO() should return an ISO date-time string (e.g 2022-11-13T00:00:00+1:00). In 13.0.3 I just receive the GMT offset part (e.g. +1:00).

Versions <= 13.0.2 are fine; canary is broken.

Expected Behavior

Production builds should not break applications.

Production builds should not differ in behavior to development builds.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://stackblitz.com/edit/vercel-next-js-ph9din

To Reproduce

See reproduction for example code.

Create a build (next build) and start the server (next start) and see that only the timezone offset is displayed.

apancutt avatar Nov 13 '22 09:11 apancutt

I had a similar issue with another library and I was able to fix the issue in 13.0.3 by setting swcMinify: false. I believe the issue is fixed here: https://github.com/vercel/next.js/pull/42790.

Also related #42878

mutewinter avatar Nov 14 '22 21:11 mutewinter

I'm unable to test since 13.0.4-canary.0 has not been published yet and attempts to install using a github URL fails with Error: next@https://github.com/vercel/next.js.git#commit=df3ddec1085ad4231cd655b5f99e070db99c0d03: Assertion failed: Unsupported workflow (Yarn3).

This isn't the first time - and won't be the last - that SWC minification causes discrepancies between dev and prod. Why not enable minification in dev? I'd rather it took an extra few ms for a hot reload in dev than find out the app is completely broken in staging/production.

Could this at least be made an opt-in option?

apancutt avatar Nov 15 '22 04:11 apancutt

Hi there, I have the same problem with a third party package that makes a callback back to the next backend (redirect url from a ssoLib package). The link is resolved wrong and so it will not be redirected correctly. Like @mutewinter mentioned swcMinify: false helped for me as well.

kolorfilm avatar Nov 15 '22 13:11 kolorfilm

Issue seems to affect hls.js https://github.com/video-dev/hls.js/issues/5015 and other libraries - swcMinify: false confirmed as workaround.

iscekic avatar Nov 15 '22 13:11 iscekic

We published 13.0.4-canary.1, but I could still reproduce this, so marking as a bug. We will look into this!

balazsorban44 avatar Nov 15 '22 18:11 balazsorban44

Just to confirm, still an issue in 13.0.4.

apancutt avatar Nov 18 '22 08:11 apancutt

Same issue with noVNC swcMinify: false as workaround fixes it https://github.com/vercel/next.js/issues/43042#issuecomment-1318951503

niranjan94 avatar Nov 18 '22 09:11 niranjan94

This also breaks luxon.

See https://github.com/moment/luxon/issues/1328

davecarlson avatar Nov 19 '22 17:11 davecarlson

@kdy1 @ijjk The [email protected] issue is still present with [email protected], is there still an issue with minification? (eg. maybe also including web workers?)

karlhorky avatar Nov 24 '22 09:11 karlhorky

@karlhorky Yes, but it's a different issue

kdy1 avatar Nov 24 '22 09:11 kdy1

Ok, is this planned on being fixed in Next.js / SWC too? Maybe this issue should be reopened to track this?

karlhorky avatar Nov 24 '22 09:11 karlhorky

I made https://github.com/swc-project/swc/issues/6504 instead

kdy1 avatar Nov 24 '22 09:11 kdy1

Great, thanks! Subscribed over there.

Maybe once it's fixed, you can also mention over in that other issue which Next.js release it will be published in (or here, also an option).

karlhorky avatar Nov 24 '22 09:11 karlhorky

I'll update next.js once I fix all easily fixable minifier issues and once again when I fix others too. But I'm not sure about the version.

kdy1 avatar Nov 24 '22 09:11 kdy1

From my perspective I can confirm the issue is fixed. The client sso library package works without any issues and swcMinify is on. Thanks! 🚀

kolorfilm avatar Nov 24 '22 13:11 kolorfilm

New PR in Next.js to update to fixed SWC version:

  • https://github.com/vercel/next.js/pull/43449

karlhorky avatar Nov 29 '22 16:11 karlhorky

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[bot] avatar Dec 30 '22 00:12 github-actions[bot]