-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Webpack5/Vite: Fix sourcemaps #27171
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit a9f1e1d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
0f74c00
to
17a5637
Compare
17a5637
to
19fb74d
Compare
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, but I'm not sure about potential downsides/side effects. I'd say we should properly test with a canary as we don't have any tests in place regarding sourcemaps (I don't even know how we'd be testing this in an automated way)
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.
Is there some way to do a single automated test of the toolchain in both Webpack and Vite, e.g.
import { Button } from './Button';
/** use jsdoc to to exercise the csf enhancement */
export default { component: Button };
/** again */
export const Basic = {}
So we can (1) verify that it's working properly, and more importantly (2) verify that it doesn't regress later
@shilman I had the idea to use a source map visualization like this one: https://github.com/evanw/source-map-visualization?tab=readme-ov-file. Instead, it analyzes a story and shows the correct source map mapping. I tried it out for an hour, but I would need more time to get it working somehow. If it would work, we can just easily snapshot things :) |
daf32a6
to
00619f9
Compare
Vite/Rollup only needs the "mappings" field for sourecemaps and ignores sourcesContentarrays. Therefore, there is no need to generate "sourcesContent" by setting the "includeContent" flag to true for magicString sourcemaps generation
@shilman Is this fix available in |
Hi @sag1v this isn’t patches back to Storybook 7. Please upgrade to 8 and let us know if you have difficulties with the upgrade. |
Upgrading to v8 is a bit of a blocker for us atm as we still use yarn v1 in this specific project unfortunately. Is there something i can do in "user land" to fix it? |
Although we don’t explicitly support yarn 1, it should still work with Storybook 8. Can you elaborate your issues in a new GitHub issue? I will try to help you upgrading to SB 8. I don’t think you can fix this issue from your side unfortunately. |
I will try to make time for it later on this week. Thanks 🙏🏽 |
Closes #26954
Closes #26653
Closes ni/nimble#2066
What I did
Fixes sourcemaps for the Webpack5 builder.
Several loaders in the Webpack5 loader chain were not processing source maps properly, resulting in either incorrect or incomplete mapping.
Second, I have configured unplugin for each builder separately so that sourcemaps can be handled individually.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
cheap-module-source-map
(A SourceMap without column-mappings that simplifies loader Source Maps to a single mapping per line).babelrc
file with the following content: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-27171-sha-a9f1e1db
. Try it out in a new sandbox by runningnpx [email protected] sandbox
or in an existing project withnpx [email protected] upgrade
.More information
0.0.0-pr-27171-sha-a9f1e1db
valentin/fix-webpack5-sourcemaps
a9f1e1db
1716547050
)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=27171