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 84 forks source link

Next.js build failing because of `TypeError` on webpack `watchOptions.ignored` type change #292

Closed ardeshireshghi closed 1 year ago

ardeshireshghi commented 1 year ago

Are you trying to transpile a local package or an npm package? If an npm package, which one?

Describe the bug I am trying to build or run a Next.js app locally. When I try to run it, I receive the message referenced in the debug logs

I dig a bit deeper into the issue and came across this file next-transpile-modules.js. There is a line that says:

config.watchOptions.ignored = [
           ...config.watchOptions.ignored.filter
...

It seems that it expects a list of ignored patterns on watchOptions. This breaks with the latest change in the Next.js code which I have referenced below. So apparently, they have replaced the list of strings with a Regex pattern:

https://github.com/vercel/next.js/pull/52238/files

To Reproduce Steps to reproduce the behavior (a reproduction is even better):

  1. Install next.js version >= https://github.com/vercel/next.js/releases/tag/v13.4.9
    • This can be done using npx create-next-app@latest
  2. Install the next-transpile-modules and add it to the next config file
  3. Run next dev or next build and the error message should appear

Expected behavior It is expected for the build to succeed and not throw this error, because the webpack-config is not configurable/changable before getting to the module

Setup

Debug logs (optiona)

TypeError: config.watchOptions.ignored.filter is not a function or its return value is not iterable
    at Object.webpack (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next-transpile-modules/src/next-transpile-modules.js:266:42)
    at Object.newWebpackFunction [as webpack] (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/@sentry/nextjs/cjs/config/webpack.js:66:37)
    at getBaseWebpackConfig (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/build/webpack-config.js:2152:32)
    at async Promise.all (index 0)
    at async Span.traceAsyncFn (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/trace/trace.js:103:20)
    at async Span.traceAsyncFn (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/trace/trace.js:103:20)
    at async HotReloader.start (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/server/dev/hot-reloader.js:573:30)
    at async DevServer.prepareImpl (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/server/dev/next-dev-server.js:683:9)
    at async NextServer.prepare (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/server/next.js:165:13)
    at async Server.<anonymous> (/Users/ardeshireshghi/workspace/givver-org/givver-web/node_modules/next/dist/server/lib/render-server.js:128:17) {
  type: 'TypeError'
}

Additional context Add any other context about the problem here.

ardeshireshghi commented 1 year ago

I am going to close this after realising that the package is deprecated. Thanks 🙏