import-js/eslint-plugin-import
View on GitHubWebpack config function executing multiple times when using `resolve.alias` and `eslint-import-resolver-webpack`
Open
#1,178 opened on Oct 8, 2018
help wantedpackage: resolver/webpack
Repository metrics
- Stars
- (4,946 stars)
- PR merge metrics
- (Avg merge 138d 22h) (3 merged PRs in 30d)
Description
Description
If webpack.config.js represents config as a function with resolve.alias defined, and when we import/require this alias later in the code while using eslint-import-resolver-webpack for resolving imports in eslint, then webpack config function executing additionally multiple times: one time for each import with alias. I.e. it happens when .eslintrc.js uses eslint-config-airbnb-base and defines wepback import resolver as follows:
module.exports = {
'extends': ['airbnb-base'],
'settings': {
'import/resolver': {
'webpack': {
'config': path.join(__dirname, 'webpack.config.js')
}
}
}
};
How to reproduce
- Clone a test repo: https://github.com/andreyvolokitin/testcase1
- Run
npm i && npm run build. The webpack build log in the console will contain multiple additionalexecute configstrings, one for each usage ofresolve.aliasinsrc/js/index.js:
test
execute config
execute config
execute config
- Remove
'import/resolver'setting from.eslintrc.jsand runnpm run buildagain. The build log in console will contain only one instance ofexecute config:
test
execute config