preact-cli-plugin-async
preact-cli-plugin-async copied to clipboard
Seems to be broken with latest preact-cli (3.0.0-rc6)
preact build output:
✖ ERROR Error: TypeError: Cannot read property 'filter' of undefined
at ode_modules/preact-cli-plugin-async/dist/async-plugin.js:1:51
Which corresponds to this:
module.exports=function(e){var r=e.module.loaders.filter
Could be the change from webpack 3 to 4.
module.loaderswere deprecated since webpack 2 and are now removed in favor ofmodule.rules.
as per webpack's To v4 from v3 page
I fixed this by pulling async-plugin.js into our codebase and changing it to this.
export default function asyncPlugin(config) {
let babel = config.module.rules.filter(loader => loader.loader && loader.loader.includes('babel-loader'))[0].options;
// Blacklist regenerator within env preset:
babel.presets[0][1].exclude.push('transform-async-to-generator');
// Add fast-async
babel.plugins.push([require.resolve('fast-async'), { spec: true }]);
}
This shouldn't be necessary in preact-cli 3, since most browsers will be loading the modern JS bundles that use native async/await.