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

No longer resolves nested packages unless full path is provided #233

Closed dtothefp closed 2 years ago

dtothefp commented 2 years ago

Are you trying to transpile a local package or an npm package? NPM package. Multiple, for example escape-string-regexp which has non es5 compliant code

Describe the bug Upgraded from 4.x to 8.x

module.exports = withTM({ webpack5: true, });

This doesn't seem like a very sustainable config. Is there a reason that the plugin no longer compiles just based upon a match of the module name rather than the full path?

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

in package.json

```json
"dependencies": {
  "escape-string-regexp": "1.0.5",
  "mdast-util-find-and-replace": "1.1.1"
}

only use escape-string-regexp in your transpile modules config and check the output that only version one version of the lib is being compiled. the nested lib in mdast with version ^4.0.0 will remain uncompiled with es6 syntax

Expected behavior All versions of escape-string-regexp in node_modules are compiled

Setup

Additional context Add any other context about the problem here.

martpie commented 2 years ago

So it's not really a bug and that's the intended behavior regarding having to specify the whole path. If your package manager nested a duplicate version of escape-string-regexp inside a dependency's node_modules, that probably means you have multiple versions of this library in your node_modules.

You may want to use (for example with Yarn) the resolutions field of your app's package.json (be careful to not use incompatible versions though), or solve the issue with mdast-util-find-and-replace's maintainer.

https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

Hope that helps!

dtothefp commented 2 years ago

@martpie I agree this is bad on our end to be including multiple versions of the same package but it's a big app. is there a reason for this change because it seemed like this "just worked' in previous versions

martpie commented 2 years ago

I'm pretty sure the problem does not come from ntm but from a dependencies update you may have done recently and that provocated this duplication of this package :)

Did you happen to do that?

Fi1osof commented 2 years ago

It's work with next-transpile-modules@^4.0, but not next-transpile-modules@^9.0 :(((

martpie commented 2 years ago

Please read the changelog :)

Fi1osof commented 2 years ago

Please read the changelog :)

I tried, but find nothing helps me.

martpie commented 2 years ago

Please open a new issue 👍