prismicio-community / storybook-addon-gatsby

Storybook addon used to load stories built with Gatsby
Apache License 2.0
7 stars 6 forks source link

v0.0.4 error on startup: `no such directory: /project/.storybook/page-data/sq/d` #6

Closed sklawren closed 2 years ago

sklawren commented 2 years ago

Versions

Reproduction

I updated from 0.0.3 to 0.0.4 and Storybook build broke locally and on Chromatic with the following error:

info => Loading presets
/project/node_modules/@storybook/core-server/dist/cjs/utils/server-statics.js:118
throw new Error((0, _tsDedent.default)((0, _chalk.default)`
^
Error: Failed to load static files, no such directory: /project/.storybook/page-data/sq/d
Make sure this directory exists, or omit the -s (--static-dir) option.
at parseStaticDir

I rolled back to 0.0.3 and it works again.

sklawren commented 2 years ago

I manually copy+pasted the addon code into my storybook main.js and preview.js and it works.

The only difference between 0.0.3 and 0.0.4 is some dependencies in package-lock.json, though it's not clear which one(s) because github can't diff a large file like package-lock-json, but it's definitely breaking because of this.

Even though I locked my project to 0.0.3, this addon gets updated when you run npx sb upgrade to install newer versions of storybook, which means you have to manually uninstall and reinstall 0.0.3 every time to fix it.

For now, I'm going to stop using this addon and just keep the copy+pasted code in main and preview, but you should really fix this ASAP.

angeloashmore commented 2 years ago

Hey @sklawren, the change between 0.0.3 and 0.0.4 is supporting Gatsby's static queries (i.e. useStaticQuery() and <StaticQuery>).

You can see the changes in this commit: https://github.com/prismicio-community/storybook-addon-gatsby/commit/4014db558c10a5fcaf93fd5599c167f4061dcc80

Perhaps the addon could check the filesystem for that directory and conditionally apply static query support.

This is a community-run package so please feel free to contribute a PR. 🙂

angeloashmore commented 2 years ago

@sklawren @feedm3 If you're able to, could you test out v0.0.5 and let me know if it fixes the error?

It removes the page-data/sq/d static directory from the Storybook config. It shouldn't be necessary with the way Gatsby resolves static queries now. This path was apparently incorrect anyway (as it is relative to the .storybook directory, not the root of the project).

Thanks!

feedm3 commented 2 years ago

The new version is working again, thank you very much for fixing it 🙂