Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes source map handling when using a debugger by implementing inline source map support. The change ensures that when debugging, source maps are properly read from inline comments within the generated code rather than separate files.
- Adds automatic detection of Node.js inspector/debugger usage
- Configures webpack to use inline source maps when debugger is active
- Implements parsing of inline source maps from generated code
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/core/rsbuild.ts | Adds inline source map parsing logic and integrates the inspect plugin |
| packages/core/src/core/plugins/inspect.ts | New plugin that detects debugger usage and configures inline source maps |
Comments suppressed due to low confidence (1)
packages/core/src/core/plugins/inspect.ts:4
- [nitpick] The variable name
enableis ambiguous. Consider renaming it toisDebuggerAttachedordebuggerEnabledfor better clarity.
const enable = inspector.url() !== undefined;
| const assetFilePath = path.join(outputPath!, asset.name); | ||
|
|
||
| if (inlineSourceMap) { | ||
| const content = await readFile(assetFilePath); |
There was a problem hiding this comment.
The readFile function expects a file path but may fail if the asset file doesn't exist or isn't readable. Consider adding error handling around this call to prevent unhandled promise rejections.
|
|
||
| if (inlineSourceMap) { | ||
| const content = await readFile(assetFilePath); | ||
| return [assetFilePath, parseInlineSourceMap(content)]; |
There was a problem hiding this comment.
If parseInlineSourceMap returns null, this will store null as the source map value, which may cause issues downstream. Consider handling the null case explicitly or filtering out null results.
| config.optimization ??= {}; | ||
| config.optimization.splitChunks = { | ||
| ...(config.optimization.splitChunks || {}), | ||
| maxSize: 1024 * 1024, |
There was a problem hiding this comment.
The magic number 1024 * 1024 (1MB) should be extracted to a named constant for better maintainability and clarity.
| maxSize: 1024 * 1024, | |
| maxSize: ONE_MEGABYTE, |
Summary
inline-source-mapwhen debugger.Related Links
fix #409
Checklist