Eslint-plugin-import: Webpack resolver doesn't apply `resolve.root` and `externals` option.

Created on 3 May 2016  路  9Comments  路  Source: benmosher/eslint-plugin-import

My webpack configurations is

// config.js
export webpackCommon = {
  // ...,
  resolve: {
    root: srcPath, // it's /src directory path
    extensions: ['', '.jsx', '.json', '.js'],
  },
  externals: [
    /^\.\/assets\.json$/,
    fs.readdirSync(modulePath).filter(x => x !== '.bin'),
  ],
  // ...,
};
// config.es5.js
require('babel-register');
require('babel-polyfill');
module.exports = require('./config').webpackCommon;

My eslintrc setting is:

  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "./tools/conifg.es5.js"
      }
    }
  }

OS: OSX El Cap latest

this plugin can't resolve ./assets.json
2016-05-03 2 40 59

and root path modules as below:
There's two directories

  • /src/components/A
  • /src/components/B

In component A, it can resolve component B as import B from 'component/B; but it doesn't work.

Most helpful comment

Thus #300. No worries. 馃槑

All 9 comments

From your .eslintrc:

"config": "./tools/conifg.es5.js"

is that a typo in the issue or a typo in your config?

@benmosher that's my configuration.

So what happens if you update 'conifg' to 'config'?

@benmosher I can't get what you mean.

Your Webpack config path is misspelled in the resolver config.

@benmosher The path is correct. because I can reference the es5 configurations through using node-cli like:

console.log(require('./tools/config.es5.js'));

the configuration files are placed at <Project Root>/tools.

I get that, but "config" is misspelled as "conifg" in the eslintrc you pasted.

Wow... awesome... I couldn't find out... Thank you. This issue can be closed.

Thus #300. No worries. 馃槑

Was this page helpful?
0 / 5 - 0 ratings