-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Test: Fix missing source map for Webpack/Vite mock loaders and plugins #32111
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
Merged
valentinpalkovic
merged 2 commits into
next
from
valentin/fix-missing-source-map-for-webpack-mock-loaders
Jul 23, 2025
Merged
Test: Fix missing source map for Webpack/Vite mock loaders and plugins #32111
valentinpalkovic
merged 2 commits into
next
from
valentin/fix-missing-source-map-for-webpack-mock-loaders
Jul 23, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
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.
2 files reviewed, no comments
|
View your CI Pipeline Execution ↗ for commit b914f50
☁️ Nx Cloud last updated this comment at |
d0c7393 to
9b42715
Compare
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 56 | 56 | 0 |
| Self size | 41.37 MB | 41.35 MB | 🎉 -15 KB 🎉 |
| Dependency size | 18.22 MB | 18.22 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 57 | 57 | 0 |
| Self size | 1 KB | 1 KB | 0 B |
| Dependency size | 59.59 MB | 59.58 MB | 🎉 -15 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 221 | 221 | 0 |
| Self size | 584 KB | 584 KB | 0 B |
| Dependency size | 103.99 MB | 103.98 MB | 🎉 -15 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 190 | 190 | 0 |
| Self size | 31 KB | 31 KB | 0 B |
| Dependency size | 88.08 MB | 88.07 MB | 🎉 -15 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
…d file redirection logic to preserve source maps
cc1b058 to
b914f50
Compare
11 tasks
This was referenced Aug 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #
What I did
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!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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/coreteam 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>Greptile Summary
This PR fixes missing source map generation for two Webpack loaders used in Storybook's mocking system. The changes modify both
webpack-automock-loader.tsandstorybook-mock-transform-loader.tsto return an object containing both transformed code and source maps, rather than just the code string.In the
webpack-automock-loader.ts, the change leverages theMagicStringinstance returned bygetAutomockCode()to generate proper source maps using its built-ingenerateMap()method. The loader now returns{ code: mocked.toString(), map: mocked.generateMap() }instead of just the string.The
storybook-mock-transform-loader.tsis similarly updated to return{ code: result.code, map: result.map }from therewriteSbMockImportCalls()function result. This aligns both loaders with the standard Webpack loader pattern of providing source maps for better debugging support.These loaders are part of Storybook's core infrastructure for handling module mocking during development and testing. The source maps enable developers to debug their original code instead of seeing transformed/generated mock code in their debugger, significantly improving the developer experience when working with mocked modules.
PR Description Notes:
Confidence score: 2/5
storybook-mock-transform-loader.tsassumesresult.mapexists, but therewriteSbMockImportCalls()function may not generate source maps by defaultstorybook-mock-transform-loader.tsfile needs careful review to ensure source maps are properly generated before being returned