fix: sourcemap tool get modules contents#1400
Merged
Conversation
✅ Deploy Preview for rsdoctor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue with sourcemap tool module content retrieval by changing getModuleByFile to return an array of modules instead of a single module. This allows handling cases where multiple modules may share the same file path.
Key changes:
- Updated
getModuleByFilemethod signature to returnModuleInstance[]instead ofModuleInstance | undefined - Enhanced sourcemap parsing logic to handle complex loader chains, builtin modules, and query parameters
- Modified consumers to iterate over multiple modules when setting size and source data
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/sdk/module.ts | Updated getModuleByFile return type from single module to array |
| packages/graph/src/graph/module-graph/graph.ts | Changed implementation to filter and return array of matching modules |
| packages/graph/src/transform/chunks/assetsModules.ts | Updated to iterate over returned module array when setting parsed data |
| packages/core/src/build-utils/build/module-graph/webpack/transform.ts | Updated to access first element of returned array with null check |
| packages/core/src/inner-plugins/plugins/sourcemapTool.ts | Enhanced source path parsing to handle loader chains, builtins, and query parameters |
| pnpm-lock.yaml | Added compiled package placeholders for various dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
77be97e to
cfd3034
Compare
LingyuCoder
approved these changes
Nov 11, 2025
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
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.
Summary
fix: sourcemap tool get modules contents
In asset.source.sourceAndMap(), the map's source(s) may carry loader identifiers — we need to support/handle this kind of source.
Example:
javascript/auto|User/demo/packages/A/dist/build-utils/build/loader/probeLoader.js??ruleSet[1].rules[4].oneOf[0].use[0]!builtin:swc-loader??ruleSet[1].rules[4].oneOf[0].use[1]!/Users/demo/packages/core/dist/build-utils/build/loader/probeLoader.js??/Users/demo/node_modules/.pnpm/@aaaa+ccc@2.4.19_@babel+runtime@7.28.4_@CCC+ddd@0.112.3_@by_jwmsj3bjj7ci3pv4sanrci5qyy/node_modules/@AAAA/ccc/dist/components/Loading/button.tsx|react:background
The module graph can contain multiple entries with the same file path, but their identifiers differ due to entry-related reasons, so moduleGraph.getModuleByFile was optimized to handle this.
——————————————————————————————————————————————————————————————
asset.source.sourceAndMap() 中的 map.source 会携带 loaders 的 identifier 情况,需要兼容这种 source
例如:javascript/auto|User/demo/packages/A/dist/build-utils/build/loader/probeLoader.js??ruleSet[1].rules[4].oneOf[0].use[0]!builtin:swc-loader??ruleSet[1].rules[4].oneOf[0].use[1]!/Users/demo/packages/core/dist/build-utils/build/loader/probeLoader.js??/Users/demo/node_modules/.pnpm/@aaaa+ccc@2.4.19_@babel+runtime@7.28.4_@CCC+ddd@0.112.3_@by_jwmsj3bjj7ci3pv4sanrci5qyy/node_modules/@AAAA/ccc/dist/components/Loading/button.tsx|react:background
module graph 中会存在多个相同的 file path,但因为 entry 问题 identifier 不同,所以优化了 moduleGraph.getModuleByFile。
Related Links