Skip to content

Refactor source map upload#273

Open
gingerbenw wants to merge 8 commits intonextfrom
gingerbenw/source-map-parsing
Open

Refactor source map upload#273
gingerbenw wants to merge 8 commits intonextfrom
gingerbenw/source-map-parsing

Conversation

@gingerbenw
Copy link
Member

@gingerbenw gingerbenw commented Mar 17, 2026

Goal

Updates JS source map discovery to pair bundles with their referenced source maps by parsing sourceMappingURL directives, aligning behavior with the TC39 ECMA-426 “without parsing” approach.

Changeset

  • Add ExtractSourceMappingURL, ResolveBundlePaths, and a new ResolveSourceMapPaths that returns bundle+map pairs.
  • Update JS upload flow to use bundle/map pairs and handle direct .map path inputs.

Testing

Expand unit/feature fixtures and scenarios to reflect bundle-driven map resolution.

Copy link

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

Updates JS source map discovery to pair bundles with their referenced source maps by parsing sourceMappingURL directives, aligning behavior with the TC39 ECMA-426 “without parsing” approach.

Changes:

  • Add ExtractSourceMappingURL, ResolveBundlePaths, and a new ResolveSourceMapPaths that returns bundle+map pairs.
  • Update JS upload flow to use bundle/map pairs and handle direct .map path inputs.
  • Expand unit/feature fixtures and scenarios to reflect bundle-driven map resolution.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/upload/js.go Implements sourceMappingURL extraction and bundle→map pairing; updates upload flow accordingly.
test/upload/js_test.go Adds tests for sourceMappingURL extraction and bundle discovery; updates existing sourcemap path test to assert bundle/map pairs.
features/js/fixtures/js-multiple-maps/dist/other.js Updates fixture bundle to reference the new map filename.
features/js/fixtures/js-multiple-maps/dist/other-123.js.map Adds new sourcemap fixture referenced by other.js.
features/cli/exclude-option.feature Updates exclude patterns to match the renamed fixture sourcemap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +344 to +352

// Try to find bundle by stripping .map suffix
withoutSuffix, found := strings.CutSuffix(sourceMapPath, ".map")
if found && utils.FileExists(withoutSuffix) {
logger.Info(fmt.Sprintf("Automatically using the bundle at path %s based on stripping the .map suffix.", withoutSuffix))
return []SourceMapBundle{{BundlePath: withoutSuffix, SourceMapPath: sourceMapPath}}, nil
}
// If no bundle found, return empty bundle path (bundle is optional)
return []SourceMapBundle{{BundlePath: "", SourceMapPath: sourceMapPath}}, nil
Copy link
Member Author

Choose a reason for hiding this comment

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

@joshedney does this sound sensible to you?

Copy link
Member Author

Choose a reason for hiding this comment

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

@joshedney bump! I think this seems sensible but just wanted your input

gingerbenw and others added 2 commits March 17, 2026 17:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@gingerbenw gingerbenw requested a review from joshedney March 17, 2026 17:42
@gingerbenw gingerbenw changed the title Gingerbenw/source map parsing Refactor source map upload Mar 17, 2026
@gingerbenw gingerbenw marked this pull request as ready for review March 18, 2026 08:56
@gingerbenw gingerbenw requested a review from lemnik March 18, 2026 08:56
@gingerbenw gingerbenw requested a review from tomlongridge March 19, 2026 09:35
@gingerbenw
Copy link
Member Author

@tomlongridge requested review for some error wording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants