Open penx opened 1 year ago
+1
I've just spent a few days debugging an issue caused by this exact problem.
same here :(
I' ve tried this way to implement react svg component in storybook 7.0.7, it helps me solved the Failed to fetch dynamically imported module
error.
However, when I used the way above, it caused another issue that i couldn't correctly import react svg component in other .tsx file, if i changed the config back to
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
// https://vitejs.dev/config/
export default defineConfig({
base: '/component-playground/',
plugins: [react(), svgr()],
build: {
cssMinify: true,
cssTarget: 'es2015',
},
css: {
modules: {
localsConvention: 'camelCase',
},
},
});
it will works for normal .tsx file but not for storybook :( it frustrated me for days, really wants to know whether there's any plugin that can helps.
here's my repo
same issue, what's wrong with storybook v7?!
Same here...
Same issue here, I tried the following main.ts
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
core: {
builder: '@storybook/builder-vite', // 👈 The builder enabled here.
},
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
babel: async (options) => {
return {
...options,
presets: ['@babel/preset-react'],
plugins: ['@babel/plugin-syntax-flow'],
};
},
};
export default config;
And i get the following error Failed to fetch dynamically imported module: http://localhost:6006/src/components/health-gauge-card/health-gauge-card.stories.tsx
👋 Hello! I had the same problem here: I was receiving Failed to fetch dynamically imported module ...
.
I solved it by adding a .nojekyll
file to the folder upon which the GitHub page will be built.
See issue https://github.com/storybookjs/storybook/issues/20564 for more info
I have my branch where a CI is run to deploy the storybook to GitHub pages.
The CI runs a yarn storybook:build
command to build the storybook, which creates a new folder called docs
.
The CI then runs the JamesIves/github-pages-deploy-action
which takes the docs
folder and puts it in a new branch called gh-pages
, that GitHub pages to display its content.
Opening the GitHub page, the storybook was displaying the Failed to fetch dynamically imported module ...
error message.
You can see my repo here: https://github.com/Adonis-Stavridis/caroumesh/tree/develop
I stumbled upon this issue: https://github.com/storybookjs/storybook/issues/20564.
Basically, adding a .nojekyll
file in the main folder of which GitHub pages will be built upon, can solve the issue.
So I've manually added an empty file called .nojekyll
in my gh-pages
branch.
The JamesIves/github-pages-deploy-action
has a cleanup job as well, so I've configured it to not delete that file as suggested in the docs.
And that works!
It took me a few days to understand how to fix it, so hope this helps 😄
@Adonis-Stavridis is my hero. Adding the .nojekyll
file to the root worked 🎉
Same issue here for me. Adding the .nojekyll
file doesn't help for me unfortunately.
I do use Sitecore as an CMS, so Storybook needs to load some components from Sitecore. This issue only appears as soon as I import import { Text } from "@sitecore-jss/sitecore-jss-nextjs";
, but I have no clue why or how to potentially fix it. I see little to no similar issues online unfortunately.
@akmjenkins wanna be my hero and help me?
fixed for me ! adding .nojekyll file did the job !
I'm seeing a somewhat similar error but mine references the storybook preview.tsx - in which we have no dynamic imports :(
TypeError: Failed to fetch dynamically imported module: http://localhost:6006/.storybook/preview.tsx
Same issue here, right after installing storybook and running it a second time (without manually changing anything).
TypeError: Failed to fetch dynamically imported module: http://localhost:6006/src/stories/Configure.mdx?import
Adding .mdx
to vite config solves the issue:
👋 Hello! I had the same problem here: I was receiving
Failed to fetch dynamically imported module ...
.I solved it by adding a
.nojekyll
file to the folder upon which the GitHub page will be built. See issue #20564 for more infoContext
I have my branch where a CI is run to deploy the storybook to GitHub pages. The CI runs a
yarn storybook:build
command to build the storybook, which creates a new folder calleddocs
. The CI then runs theJamesIves/github-pages-deploy-action
which takes thedocs
folder and puts it in a new branch calledgh-pages
, that GitHub pages to display its content. Opening the GitHub page, the storybook was displaying theFailed to fetch dynamically imported module ...
error message. You can see my repo here: https://github.com/Adonis-Stavridis/caroumesh/tree/developSolution
I stumbled upon this issue: #20564. Basically, adding a
.nojekyll
file in the main folder of which GitHub pages will be built upon, can solve the issue. So I've manually added an empty file called.nojekyll
in mygh-pages
branch. TheJamesIves/github-pages-deploy-action
has a cleanup job as well, so I've configured it to not delete that file as suggested in the docs. And that works!It took me a few days to understand how to fix it, so hope this helps 😄
Hi! this solution helped, although, github keeps automatically deleting this file from the gh-pages
branch every once in a while, anyone ran in to that?
I am also having this issue. Just upgraded to storybook v7 from v6 and seeing this happen when using vite and react and importing a static asset (for example a .gif or .png) will cause this error to occur.
I had also this same issue and I solved it by configuring the main.ts file by adding "reactDocgen: 'react-docgen-typescript'" into typescript object.
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = { stories: ['../src/*/.mdx', '../src/*/.stories.@(js|jsx|mjs|ts|tsx)'], addons: [ '@storybook/addon-onboarding', '@storybook/addon-links', '@storybook/addon-essentials', '@chromatic-com/storybook', '@storybook/addon-interactions' ], framework: { name: '@storybook/react-vite', options: {} }, typescript: { check: true, reactDocgen: 'react-docgen-typescript', }, };
export default config;
I ran into the same issue when upgrading from 8.1.7 to 8.2.6
Clearing node_modules/.cache/storybook
or optimizeDeps: { exclude: ... } }
doesn't work.
@alpzaf change by adding reactDocgen: 'react-docgen-typescript'
works. 🍻
Nothing in this thread worked for me. It may appear to work at first, but the error seems completely random and will fail sometimes and not others. Installing another random library is not a solution.
Describe the bug
If you:
public
in your storybook staticDirsThen storybook will error with:
If you look at the network activity, the asset is returned with
Content-Type: image/png
, butContent-Type: application/javascript
is expected and an error is thrown:To Reproduce
https://github.com/penx/storybook-issue-2023-03-14
System
Additional context
This took me far too long to debug 😂
We have our storybook config inside src so that we can import files from src without typescript + ts lint complaining that our storybook files aren't in our project.
We have
public
in our storybook staticDirs as we have fonts and other assets that are loaded e.g. by .storybook/preview-head.html. There are some places where we have the assets in the same location in our src folder (public/themes/some-asset and src/themes/some-asset).Now that I can see the issue, I should be able to find a workaround, but the errors were cryptic and I expect others could be faced with the same issue.
Note this error doesn't occur if the storybook config is not in the src or when running the vite app directly using
vite dev