Eslint-plugin-import: Webpack resolver does not work when webpack exports a promise configuration

Created on 28 Jun 2017  路  2Comments  路  Source: benmosher/eslint-plugin-import

As of webpack v2, the webpack configuration file can export a Promise: https://webpack.js.org/configuration/configuration-types/#exporting-a-promise.

The webpack resolver does not attempt to resolve that promise to use the configuration.

Most helpful comment

If asynchronous part of your webpack config is not used in eslint, problem can be temporary fixed by extracting synchronous/static part in another file(webpack.sync-config.js for example).
Then you include it in eslint settings, and merge it in with async part in webpack.config.js by webpack-merge.

All 2 comments

I too came here for this. Then I dug deeper. And if I understand correctly, ESLint is designed to be very synchronous, so the rules can't be async. Thought I'm not sure whether plugins can have any async preparation step.

But settings['import/resolver'].webpack.config can be a config object, so it seems possible to have some kind of script that prints the webpack config and call it in the ESLint config via execSync or something.

However, in our case it was much easier to similarly "synchronize" async pre-build tasks to get rid of promising config and return it synchronously.

If asynchronous part of your webpack config is not used in eslint, problem can be temporary fixed by extracting synchronous/static part in another file(webpack.sync-config.js for example).
Then you include it in eslint settings, and merge it in with async part in webpack.config.js by webpack-merge.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msuntharesan picture msuntharesan  路  29Comments

ThomasdenH picture ThomasdenH  路  31Comments

thewilkybarkid picture thewilkybarkid  路  36Comments

yamov picture yamov  路  29Comments

rhettlivingston picture rhettlivingston  路  31Comments