Closed haoniukun closed 2 years ago
I managed to change the configuration to make it work. I have to include only preact related node modules in the mjs config. const newMjsRule = { test: /.mjs$/, include: /node_modules\/preact/, type: 'javascript/auto' } config.module.rules = [newMjsRule, ...config.module.rules]; return config; }
Hi, Happy new year! Thanks for providing the tool for react. When I build a story book based on preact and this addon as a decoractor, I'm seeing a lot of compilation errors like the following. ModuleDependencyError: Can't reexport the named export 'renderToString' from non EcmaScript module (only default export is available) at Compilation.reportDependencyErrorsAndWarnings (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/webpack/lib/Compilation.js:1468:21) at /Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/webpack/lib/Compilation.js:1258:10 at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/tapable/lib/HookCodeFactory.js:33:10),:22:1)
at AsyncSeriesHook.lazyCompileHook (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/tapable/lib/Hook.js:154:20)
at Compilation.finish (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/webpack/lib/Compilation.js:1253:28)
at /Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/webpack/lib/Compiler.js:672:17
at _done (eval at create (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/tapable/lib/HookCodeFactory.js:33:10), :9:1)
at eval (eval at create (/Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/tapable/lib/HookCodeFactory.js:33:10), :32:22)
at /Users/kniu/code/jet/jet/packages/playgrounds/jwaldman/node_modules/webpack/lib/Compilation.js:1185:12
If I change the way webpack handles mjs file in node_modules folder, compilation succeeds. But index.html of storybook is not generated, so the website cannot be loaded.
I added this in my preview.js to handle mjs files in node_modules.
module.exports.webpackFinal = async config => {
const newMjsRule = {
test: /.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
}
config.module.rules = [newMjsRule, ...config.module.rules];
return config;
}
I'm using storybook 6.3.
So my question is if there is a way to make this addon working with preact.
Thanks