Open haysclark opened 2 years ago
As a work-around, one can use the manual steps mentioned on the Gatsby website.
I'm seeing the same problem. It seems the issue has to do with Gatsby not being included in webpack transforms.
Based on the manual steps in the link @haysclark posted, I was able to fix the error by keeping the add-on and just adding the webpack exclude
part to my .storybook/main.js
:
webpackFinal: async (config) => {
config.module.rules[0].exclude = [/node_modules\/(?!(gatsby)\/)/];
return config;
},
This line is also included in storybook-addon-gatsby
here, but for some reason it doesn't seem to be applying.
Without really looking into it, here are my thoughts:
exclude
is being overridden elsewhere.typeof config.module?.rules?.[0] === "object"
being true. Maybe this is returning false for some reason and this line never runs.This is due to a new gatsby package, gatsby-scripts being required by gatsby v4.15 and having untraspiled es6 code as well. Had the same issue with jest, and changing this exclude pattern to node_modules/(?!(gatsby|gatsby-script)/)
solved my issue there. Testing now to see if that solves the problem for this package.
Edit: my assumption may have been incorrect. It doesn't appear that changing the pattern had any effect on this bug.
I have this problem and this workaround works.
webpackFinal: async (config) => {
config.module.rules[0].exclude = [/node_modules\/(?!(gatsby)\/)/];
return config;
},
After looking into this problem, It seems this addon is not loaded at all. I tried to add some loggers into the source code under node_modules, but nothing is logged.
Eventually, I found out if I remove ./preview
part in package.json, it works magically.
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
},
"./preview": {
"require": "./dist/preview.cjs",
"import": "./dist/preview.mjs"
},
"./package.json": "./package.json"
},
@angeloashmore Could you pls verify it and release a patch version?
Versions
Reproduction
Created simple sample project based off gatsby-starter-ts.
Install with
yarn
ornpm
(yarn.lock included in project)Steps to reproduce
Run
npm run storybook
from within the project directory.What is expected?
Storybook should start normally.
What is actually happening?
Storybook/Webpack throws the following error: