-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack resolver does not work when webpack exports a promise configuration #883
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 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( |
As a terrible, terrible workaround for when you have to have your async webpack config passed to eslint, you can "un-async" parts of your config by running another interpreter process with // async-webpack.config.js
const load = async () => {
// ...
process.stdout.write(
JSON.stringify({
/* ... */
})
);
};
load().catch(e => {
console.error(e);
process.exitCode = 1;
}); // sync-webpack.config.js
const path = require('path');
const { spawnSync } = require('child_process');
const { stdout, stderr, status, signal, error } = spawnSync(process.argv0, [
path.resolve(__dirname, 'async-webpack.config.js')
]);
// Error handling here (status/signal/error)...
const asyncConfig = JSON.parse(stdout);
// ... |
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.
The text was updated successfully, but these errors were encountered: