Open minuz opened 1 year ago
We're also seeing the same problem
Hey there! Any updates here? Seeing the same error, works fine in dev mode and fails when building
I'm facing the same problem in a nextjs project with 7.6.2.
Module parse failed: Identifier '_$mocks$' has already been declared (77:6)
File was processed with these loaders:
* ../../node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| };
| export { preview as default };
> const _$mocks$ = {};
| export const $mock$ = (name, value) => {
| if (typeof _$mocks$[name] !== "function") throw new Error("Exported function not found.");
I partially figured out what was missing. If you read carefully the docs in the README file, you will find this phrase: "Include and exclude are enabled for storybook build where Babel is used. Not used in storybook dev. If include is omitted, all modules are covered."
I added then the include
and exclude
options, and I was able to build.
const config: StorybookConfig = {
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-designs'),
{
name: 'storybook-addon-module-mock',
options: {
include: [],
exclude: ['**/node_modules/**'],
},
},
'./local-preset.js',
],
// ...
};
Hi, I've been trying to add this addon into my storybook. It works perfectly when in Dev mode. But when building for publishing, I get the following:
This is my main.js
This is a monorepo using nrwl nx.
Any help will be appreciated. Thanks!