-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Add deprecation notice for Vite + CommonJS #23950
Conversation
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
@benmccann @IanVS, @ndelangen reminded me that I do think we should deprecate this anyway, as it's a low cost migration for the user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to these changes, but why do we need to do it at all? Vite is not processing main.js
at all -- that's Storybook's configuration file.
Sorry, I saw you answered my question above. Perhaps this is a good chance to upgrade users to the new configuration format with the default export?
It doesn't really matter what loads the There is still potentially an issue here regardless of what handles |
I don't know if we want to continue with this PR or not, but if we do then it will need a rebase.
If we do want to make this change as simply a good practice, should we do it for all users rather than just Vite users then since we've realized this isn't actually required by Vite? |
Some day Storybook will also follow that pattern, where we expect the user to import addons rather than reference them by string, FYI. Possible in 9.0 |
7e6fc43
to
f7dba4c
Compare
What I did
Vite v5 will remove support for CommonJS, so we plan to remove support for
main.cjs
and any CommonJS syntax within (regardless of file extension) in Storybook 8 with Vite. This won't guarantee that Vite 5 works, but it's at least a step in the right direction.Technically this doesn't make much of a difference because
main.js
isn't loaded by Vite, but rather by esbuild-register because it's server-only, but I think it's a good upgrade for users.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
I manually tested this in a React-Vite sandbox by renaming the
main.js
file tomain.cjs
andmain.cts
, which caused the deprecation warning to appear. It also correctly appears if eithermodule.exports = config
orexports.default = config
is used. It correctly does not appear in a plainmain.js
file withexport default config;
.Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>