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

Unable to build project #285

Closed Evanion closed 1 year ago

Evanion commented 1 year ago

Are you trying to transpile a local package or an npm package? Local Turborepo package.

Describe the bug When running next build in CI pipeline, it throws an error. I'm also able to replicate this locally.

We are using mui as the basis of our UI library, so we don't have any css files in our project as everything is styled components

To Reproduce Steps to reproduce the behavior (a reproduction is even better): I have no idea, this first appeared on our GH Actions CI pipeline.

Expected behavior A clear and concise description of what you expected to happen. next build to complete correctly

Setup

Debug logs (optional) https://app.warp.dev/block/QTtMEumacG8u4sSSTpUd0R

Additional context

I have tried:

next.config.js

const packageJson = require('./package.json')

const internalPackages = Object.keys(packageJson.dependencies).filter((it) =>
  it.startsWith('@ms/'),
)
const withTM = require('next-transpile-modules')(internalPackages, {
  debug: true,
})

module.exports = withTM({
  i18n: {
    locales: ['en_US', 'sv_SE'],
    defaultLocale: 'sv_SE',
  },
  poweredByHeader: false,
  reactStrictMode: true,
  swcMinify: true,
})

The error occurs in code relating to the webpack css loader as far as I can see:

if (nextCssLoader) {
  nextCssLoader.issuer.or = nextCssLoader.issuer.and ? nextCssLoader.issuer.and.concat(matcher) : matcher;
  delete nextCssLoader.issuer.not;             // ^ error occurs here
  delete nextCssLoader.issuer.and;
} else {
  console.warn('next-transpile-modules - could not find default CSS rule, CSS imports may not work');
}
martpie commented 1 year ago

Hello 👋

Are you using the new app/ dir feature?

Evanion commented 1 year ago

No, the next.config.js in the post doesn't contain the config for it. We would like to use the app dir, but it's borked when running Docker for some reason. Waiting for a response from vercel on that.

Evanion commented 1 year ago

I solved this by using the new built in experimental.transpilePackage config in next@13