Skip to content

fix: use inline-source-map when debugger#445

Merged
9aoy merged 2 commits intomainfrom
fix/debugger
Aug 6, 2025
Merged

fix: use inline-source-map when debugger#445
9aoy merged 2 commits intomainfrom
fix/debugger

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 5, 2025

Summary

  • Use inline-source-map when debugger.
  • Limit the size of each chunk (maxSize: 1MB) to speed up the source map loading in inspector

Related Links

fix #409

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 5, 2025 07:30
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 5, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 0c34819
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/6891c1d95bd55d0008174a5a
😎 Deploy Preview https://deploy-preview-445--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 enable is ambiguous. Consider renaming it to isDebuggerAttached or debuggerEnabled for better clarity.
const enable = inspector.url() !== undefined;

const assetFilePath = path.join(outputPath!, asset.name);

if (inlineSourceMap) {
const content = await readFile(assetFilePath);
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

if (inlineSourceMap) {
const content = await readFile(assetFilePath);
return [assetFilePath, parseInlineSourceMap(content)];
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
config.optimization ??= {};
config.optimization.splitChunks = {
...(config.optimization.splitChunks || {}),
maxSize: 1024 * 1024,
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 1024 * 1024 (1MB) should be extracted to a named constant for better maintainability and clarity.

Suggested change
maxSize: 1024 * 1024,
maxSize: ONE_MEGABYTE,

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit 39abfd1 into main Aug 6, 2025
16 checks passed
@9aoy 9aoy deleted the fix/debugger branch August 6, 2025 10:03
@9aoy 9aoy mentioned this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Breakpoint unstable while debug

2 participants