-
-
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: Fix addon bundling script #26145
Conversation
…s even for CJS output, make CJS output neutral platform
Co-authored-by: Jeppe Reinhold <jeppe@chromatic.com>
I used the canary to test portable stories and although I found issues, these issues are unrelated to this PR, so from the perspective of portable-stories I think the changes look good 👍 |
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.
LGTM I Think!
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 confident about patching this back. But let's get it out in 8.0-beta ASAP and see how it does there. Great job!!! ❤️
Will this land in v7 any time soon? |
Core: Fix addon bundling script (cherry picked from commit 21a2300)
This is included in 7.6.18 and 8.0.0 |
@yannbf
Both of these aren't available:
|
@ndelangen
Which package please? These aren't published as |
@AndyOGo It doesn't look like 7.6.18 has been published. Are you unable to upgrade to Storybook 8? |
@shilman Thx for your answer. |
For us, it is also a problem. Would really appreciate if it could be ported back to v7 |
@ndelangen seems like the patch release that was going to include this change was closed, I'm not sure why: #26121 |
@yannbf, @ndelangen any chances of this being release in 7.x? |
+1 when will this be released in 7.6.18? we can't jump all the way to v8 yet, we need a working v7 first. |
@ndelangen Please respond |
Core: Fix addon bundling script (cherry picked from commit 21a2300)
@AndyOGo, @heathercodes, @sjwilczynski, @reshu0408 v7.6.18 has been released now with the fix. https://github.com/storybookjs/storybook/releases/tag/v7.6.18 |
Closes: #26126
Closes: Jakob-em/storybook-addon-angular-router#26
Closes: #26030
What I did
I researched the problem and discovered:
addons/actions/dist/index.js
(which is an export-type-entry for the addon is compiled in ESM and CJS, however the CJS is compiled for NODE.addons/actions/dist/index.js
(which is an import-type-entry for the addon is compiled in ESM and CJS, however the CJS is compiling in all preview related packages (package consolidation would fix this).These factors cause code designed to be run in NODE (unbundled), to be bundled again and then ran in a browser.
It seems webpack just can't really work with the output from esbuild when esbuild compiled for NODE, and webpack compiles for the browser. It creates an empty context, which then causes the issue.
How I fixed it:
I changed the bundling script that bundles our addons, so that it now does:
preview-api
.neutral
.module
.The result is that:
addons/actions/dist/index.js
has 7800 lines of code removed.What is next?
I am pretty confident in this change, however it does change the dynamics with NODE.
I'd like to ask @yannbf 's help to verify if this did not change/break portable stories or the test-runner in some way.
I'd also like @shilman 's position on how safe they feel this change is.
This change would need to be patched back to 7.x.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
I published a canary, so testing this with any sandbox or repro should be easy.
Check if:
Also check:
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 pull request has been released as version
0.0.0-pr-26145-sha-32b8346f
. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-26145-sha-32b8346f sandbox
or in an existing project withnpx storybook@0.0.0-pr-26145-sha-32b8346f upgrade
.More information
0.0.0-pr-26145-sha-32b8346f
norbert/fix-addon-bundling
32b8346f
1708605052
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=26145