preact-cli-plugin-async icon indicating copy to clipboard operation
preact-cli-plugin-async copied to clipboard

Seems to be broken with latest preact-cli (3.0.0-rc6)

Open kmiyashiro opened this issue 5 years ago • 3 comments

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.

kmiyashiro avatar Feb 17 '20 11:02 kmiyashiro

module.loaders were deprecated since webpack 2 and are now removed in favor of module.rules.

as per webpack's To v4 from v3 page

afflitto avatar Sep 04 '20 05:09 afflitto

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 }]);
}

1337rout avatar Jan 28 '22 18:01 1337rout

This shouldn't be necessary in preact-cli 3, since most browsers will be loading the modern JS bundles that use native async/await.

developit avatar Jun 06 '22 02:06 developit