question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin Doesn't Work With babel-plugin-module-resolver

See original GitHub issue

I recently discovered that when you try to use this plug-in with another Babel plug-in, module-resolver, it breaks. That plug-in re-writes the paths of import statements, for instance transforming "~/src/foo" to "projectRoot/src/foo".

For instance:

 // a.js
 export const foo = 1;

 // b.js
 import {foo} from '~/a';

 // c.js
 import('./b');

results in:

ERROR in ./c.js Module not found: Error: Can’t resolve ‘~/a’ in …

Presumably this is happening because when c imports b this plug-in somehow bypasses the module-resolver plug-in. While this may well be module-resolver’s fault, it could also be this library’s, so I figured I’d try submitting the issue here first.

Ultimately it would be nice if these two great plug-ins could work together. Thanks.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tomataucommented, Mar 22, 2018

Good point @ljharb I thought it was related at first but then realised my module resolver setup is only used in SSR! The issue I have is more specific to webpack with a custom resolve configuration and most likely unrelated to this setting.

1reaction
machineghostcommented, Feb 7, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Babel module resolver not working with react-native
I had the same problem, I just removed the '@' from my aliases and it seems working fine now. Here is my babel.config.js...
Read more >
It doesn't resolve paths to files · Issue #424 - GitHub
I'm trying to use the plugin for css, graphql file mocks in order to run nodejs on tests. ... It doesn't resolve paths...
Read more >
babel-plugin-module-resolver - npm
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 >
How do use babel plugin module resolver in react native
babel - plugin - module - resolver | Yarn - Package Manager || Babel module resolver doesn't work as expected || Why You...
Read more >
babel-plugin-module-resolver - npm package - Snyk
Learn more about babel-plugin-module-resolver: package health score, popularity, security, maintenance, versions and more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found