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

allow setting isWebpack5 via option (to work with current next@canary) #215

Closed stefanprobst closed 3 years ago

stefanprobst commented 3 years ago

Are you trying to transpile a local package or an npm package? n/a

Describe the bug In the current canary version 10.2.4-canary.9, next disallows the future.webpack5 option in next.config.js, which means i cannot tell next-transpile-modules to use webpack5, even though next is using it.

Screenshot_20210609_155039

Possible solution could be to allow programmatically passing a webpack5?: boolean option to next-transpile-modules, which will be checked here.

To Reproduce

Expected behavior

Setup

Additional context Add any other context about the problem here.

martpie commented 3 years ago

Hello 👋

Thanks for the report! I guess if they removed the flag, it's because they are going to remove Webpack 4 support (I need to double check that), so this "isWepback5" would not be extremely useful.

Can you tell me more about your usecase?

stefanprobst commented 3 years ago

apparently it's now a toplevel flag (i.e. not in future anymore)

my usecase is just transpiling a package, and i wanted to try out the new next canary, which threw the error in the image above with next dev.

martpie commented 3 years ago

I will add support for top-level webpack5, should be quite trivial.

martpie commented 3 years ago

Should be fixed in 7.3.0 👍 no breaking change, everything should work out of the box

stefanprobst commented 3 years ago

thanks!

for documentation: webpack5 needs to be explicitly set to true (even though that's the default):

// next.config.js
const config = {
  /** @ts-expect-error */
  webpack5: true,
}
martpie commented 3 years ago

I will update the docs when it is official in a stable release :)

Jaxenormus commented 3 years ago

@martpie Webpack 5 now is the default in NextJS 11

martpie commented 3 years ago

Yep exactly, this is what I was waiting for, see #218 :)