Feature request: add support for babel-plugin-module-resolver
See original GitHub issueContext
babel-plugin-module-resolver is an alternate way to alias module paths. The syntax is a bit simpler than Webpack’s alias
option.
Expected Behavior
Would be awesome if dependency-cruiser
could follow these aliases import paths.
Current Behavior
Currently, any import path aliased with babel-plugin-module-resolver
is unresolvable.
Possible Solution
The module path mapping is pretty straight forward in the Babel config – it’s just alias name to relative path.
Considered alternatives
Could move our module aliases from our Babel config to our Webpack config
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
babel-plugin-module-resolver | Yarn - Package Manager
This plugin allows you to add new "root" directories that contain your modules. It also allows you to setup a custom alias for...
Read more >@fdao/babel-plugin-module-resolver - npm package | Snyk
A Babel plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to add...
Read more >Options - Babel.js
would allow plugins and presets to decide that, since ES modules are supported, they will skip compilation of ES modules into CommonJS modules....
Read more >Babel module resolver doesn't work as expected
Should be marked as the accepted solution. Adding aliases to babel (babelrc or babel.config) will only inform babel during transpiling that the ...
Read more >Cannot Resolve Imports when using babel-resolver
I don't think we'd ever put efforts on adding special support for certain babel plugin... anyway, please feel free to file a request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @atav32 & @tpucci thanks again for bringing this to my attention.
TL;DR The next version of dependency-cruiser will have babel support (including the plugin/ preset ecosystem) - also see the linked PR (#304 ☝️ ).
=> I’d love to hear any feed back on how it works for you. I’ve published with the beta tag on npm as
dependency-cruiser@9.4.0-beta-1
rationale
@tpucci’s remark made me realise there’s use cases for having a babel plugin taking care of path aliasing. There might be more than these, but they’re already enough to warrant support in dependency-cruiser:
Next to that: dependency-cruiser uses acorn, and acorn only implements TC39 stage 4. If you’re using babel you likely do this because you want to use stuff from earlier stages, like
export * as flakes from 'snowdash'
. In order to enable you to use dependency-cruiser on that as well it’ll have to grow babel support too.@atav32 it should still work. If it doesn’t it’s a bug. I’ve tested it manually just now, and it seems to work fine still (both in 9.24.0 and 9.25.1).
=> Could you share your .dependency-cruiser.js?
I’ve split documentation of rules and options a while ago, which might explain why you couldn’t find it; it’s now here: babelConfig - use a babel configuration file.