Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only "main" in package.json used if path mapping matches node module #20

Closed
christoffer-dropbox opened this issue Jun 10, 2018 · 0 comments · Fixed by #21
Closed

Only "main" in package.json used if path mapping matches node module #20

christoffer-dropbox opened this issue Jun 10, 2018 · 0 comments · Fixed by #21

Comments

@christoffer-dropbox
Copy link

In our project we have a path mapping for * which explicitly maps to node_modules:

"compilerOptions": {
  ...
  "paths": {
    "*": ["./node_modules/*', ...]
  }
  ...
}

This breaks webpack bundling when using tsconfig-paths-webpack-plugin for modules that specify a "browser" field in their package.json.

I think this is because the plugin will find a path mapping match for (almost all) modules in <baseUrl>node_modules/*, but tsconfig-paths apparently only grabs the resolved path using the "main" filed package.json (source).

The expected behavior would be to respect Webpacks' module.mainFields used by the default resolver.

Our specific use case is a little unusual and I can probably find a way around it, but I figured I'd file a bug since this caused more than a fair bit of debugging to figure out. And I can imagine other use-cases where less unusual mappings would cause issues that are probably even more to trace back to the root cause described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment