-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Bug]: Vite CJS warning still present in v8 RC #26291
Comments
I also tried 8.0.0-rc.1 for our own setup. Can't confirm this, but have you tried adding this |
@JReinhold @IanVS any idea why #24395 didn't fully solve this? |
Yes, it's because of the way we load the user's config file as CJS (using https://github.com/egoist/esbuild-register), which causes Vite to still show the warning. |
If users are importing from Vite in their main config like @dan-mba is in their reproduction, they need to use a dynamic import instead of a top-level import to silence this warning, like this: import type { StorybookConfig } from "@storybook/react-vite";
- import { mergeConfig } from 'vite';
const config: StorybookConfig = {
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [ "@storybook/addon-essentials" ],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: false,
},
async viteFinal(config, {
configType
}) {
+ const { mergeConfig } = await import('vite');
// return the customized config
return mergeConfig(config, {
// customize the Vite config here
base: './'
});
},
};
export default config; This is not trivial to fix for us internally as it requires that we make changes to our preset loading, something @ndelangen is hesitant about and definitely won't happen for 8.0 GA. I think @ndelangen's hope is to do this as part of the ESM transition? We could perhaps document this dynamic import requirement though? @kylegach |
@JReinhold The dynamic import got rid of the warning for me. The sample It might also be nice to have a warning when using the update migration cli. |
Good catch, I've updated the snippets to dynamically import in #26330
This is actually unrelated to upgrading to any Storybook version, it's about users upgrading to Vite 5. So I don't think it's appropriate to show in the upgrade CLI flow. |
i still get the warning when using:
|
We have changed our main.ts accordingly, but we still get the same error, here is how the file looks:
|
Upon tracing the origin of the CJS warning, I identified its source in the file: It's worth noting that upon the comment of @wuifdesign, I also removed reactDocgen: "react-docgen-typescript", as it was another trigger for the warning message. As evidenced in this screenshot, the warning comes from The warning ceased to appear after the removal of both Both files share the same import statement: This import seems to be the culprit behind the warning. Based on my understanding from https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated, it appears that vite should be imported dynamically. Update: Upon examination of the In our project, we resolved this by explicitly setting the version in the package.json file:
However, it's worth noting that the issue persists in the I have opened a ticket for that: iFaxity/vite-plugin-istanbul#209 |
Looks like this issue has been resolved upstream, so closing this now. Let me know if this isn't the case! |
@vanessayuenn It's not solved yet for this case:
|
I am also seeing this warning, even though my entire repo is ESM (and has been so for over a year). Unlike @zuk-michal I'm disabling doc generation, but changing that setting doesn't seem to matter (I still see the warnings). Our repo is way too large (and proprietary) to provide as a repro, but I'm happy to post config files or logs. |
Will anyone be looking into this soon? To be clear, it's not the RC that has this issue; even the latest version of Storybook (8.2.5) exhibits this. And the issue exists even if doc generation is turned off. I'm asking because this warning interferes with my monorepo build. Even though the Storybook build works correctly, the presence of the warning causes the monorepo build to not be successful:
|
@kaiyoma did you try the workaround described in #26291 (comment) ? If that doesn't work, it would be great to get a minimal reproduction. We are aware of the issue with |
@JReinhold I tried it, but this doesn't help either. Same error. Here's the trace, if this is helpful:
I actually just realized that Vite offers an escape hatch for suppressing the warning ( |
In my case (Storybook I tried a similar solution as @aimad-majdou's with // ❌ not working
{
"resolutions": {
"vite-plugin-istanbul": "6.0.1"
},
} But this makes the preview (dev environment) fail:
The main issue is that > yarn why vite-plugin-istanbul
<
└─ @storybook/addon-coverage@npm:1.0.4
└─ vite-plugin-istanbul@npm:3.0.4 (via npm:^3.0.1) I created the issue in |
In my case, this is caused by |
Describe the bug
Using Vite 5 with Storybook 8 RC produces the following warning:
According to #24333 this was supposed to be fixed with v8.
As a RC has been released, I would assume this should have been fixed by now.
To Reproduce
https://github.com/dan-mba/react-svg-components/tree/sb-8
System
Additional context
No response
The text was updated successfully, but these errors were encountered: