Babel-plugin-module-resolver: avoid resolution warning in transforming the alias

Created on 11 Sep 2018  路  1Comment  路  Source: tleunen/babel-plugin-module-resolver

Hi,

I want to set alias for production builds with webpack, and simply change the path from like:

import someComponent from 'MyLibrary/src/components/some-component'

to

import someComponent from 'MyLibrary/dist/some-component'

and I also set these import as externals in webpack

so when my library user use my modules , theire webpack actually resolve these modules, it would go to the dist dir and resolve these modules correctly.

But the problem was, I got these warnings:

Could not resolve "MyLibrary/dist/some-component" in file /Users/me/WorkSpace/MyLibrary/src/components/some-component/xx.js.

I got the correct result from the babel ouputs:

var _someComponent = _interopRequireDefault(require("MyLibrary/dist/some-component"));

Even though, MyLibrary/dist/** is not actually a real folder in my cwd, but it will eventually maps to the package I publish on npm.

In summary, it there a way to just simply transform those requires but not actually trigger the resolution warnning ?

Most helpful comment

I'm also getting tons of Could not resolve warnings even though everything works.

>All comments

I'm also getting tons of Could not resolve warnings even though everything works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dschinkel picture dschinkel  路  4Comments

alanreidt picture alanreidt  路  3Comments

melloc01 picture melloc01  路  7Comments

ViktorAksionov picture ViktorAksionov  路  3Comments

WrathChaos picture WrathChaos  路  6Comments