martpie / next-transpile-modules

Next.js plugin to transpile code from node_modules. Please see: https://github.com/martpie/next-transpile-modules/issues/291
MIT License
1.13k stars 85 forks source link

NextJS v13.0.1 breaks transpile #282

Closed dohomi closed 1 year ago

dohomi commented 1 year ago

Describe the bug From NextJS 13.0.0 => 13.0.1 next stops compiling.

To Reproduce Upgrade NextJS 13.0.0. => 13.0.1 with a pages folder structure.

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

Expected behavior NextJS 13.0.0 works fine, without any code change.

Setup

eugenejeonme commented 1 year ago

I hope this issue is resolved soon. And I found, secondary way to make it work. Using the experimental.transpilePackages option of NextJS Config.

https://beta.nextjs.org/docs/api-reference/next.config.js#transpilepackages

martpie commented 1 year ago

Thank you very much for the report! It would seem their fix for the duplicated code in bundles have broken ntm.

On a sidenote, we don't officially support Next 13 yet.

Cf. #281

Regarding transpilePackages, be wary it's not a 1-to-1 replacement and it's still an experimental feature.

Cf. https://github.com/vercel/next.js/discussions/42136 for the feature gap.

terrymun commented 1 year ago

Thanks for opening the ticket @dohomi, we have encountered the same issue as well. This seems to be coming from a change introduced in 13.0.1 originating from this PR on NextJS: https://github.com/vercel/next.js/pull/42106/files

The issuer field has been removed :( and next-transpile-module relies on this field here: https://github.com/martpie/next-transpile-modules/blob/master/src/next-transpile-modules.js#L206

I am wondering if it's something we can patch for this, or it's something for NextJs maintainers to do (i.e. restore the issuer field)?

martpie commented 1 year ago

Thank you for identifying the faulty commit, that will help a lot 👍

Please note that Next.js 13 is not yet supported by next-transpile-modules.

You can check #281 for work in progress

terrymun commented 1 year ago

I've created a support ticket on NextJs repo to see if it's something they can fix for the moment being :) https://github.com/vercel/next.js/issues/42296

@eugenejeonme We tried your solution of using the experimental transpilation flag, but as we are using Nx the issue simply bubbles up to with-nx.ts and fails in the similar way as it failed on next-transpile-modules.

terrymun commented 1 year ago

@martpie We are indeed pushing our luck with the NextJs@13 upgrade, but so far everything worked perfectly with your plugin :)

martpie commented 1 year ago

Fixed in next-transpile-modules@10.0.0, cheers!