Skip to content
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

Fix emitting real mapping sources when null mapping comes first #4082

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions internal/linker/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6963,13 +6963,13 @@ func (c *linkerContext) generateSourceMapForChunk(
items := make([]item, 0, len(results))
nextSourcesIndex := 0
for _, result := range results {
if _, ok := sourceIndexToSourcesIndex[result.sourceIndex]; ok {
if result.isNullEntry {
continue
}
sourceIndexToSourcesIndex[result.sourceIndex] = nextSourcesIndex
if result.isNullEntry {
if _, ok := sourceIndexToSourcesIndex[result.sourceIndex]; ok {
continue
}
sourceIndexToSourcesIndex[result.sourceIndex] = nextSourcesIndex
file := &c.graph.Files[result.sourceIndex]

// Simple case: no nested source map
Expand Down Expand Up @@ -7057,7 +7057,16 @@ func (c *linkerContext) generateSourceMapForChunk(
for _, result := range results {
chunk := result.sourceMapChunk
offset := result.generatedOffset
sourcesIndex := sourceIndexToSourcesIndex[result.sourceIndex]
sourcesIndex, ok := sourceIndexToSourcesIndex[result.sourceIndex]
if !ok {
// If there's no sourcesIndex, then every mapping for this result's
// sourceIndex were null mappings. We still need to emit the null
// mapping, but its source index won't matter.
sourcesIndex = 0
if !result.isNullEntry {
panic("Internal error")
}
}

// This should have already been checked earlier
if chunk.ShouldIgnore {
Expand Down
Loading