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

chore(linker): remove meaningless re-assignment to isFileInThisChunk #3297

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hyf0
Copy link

@hyf0 hyf0 commented Aug 7, 2023

isPartInThisChunk could only be true while isFileInThisChunk = true. So the isFileInThisChunk = true in

if isPartInThisChunk {
isFileInThisChunk = true

seems meaningless.

See

isFileInThisChunk := chunk.entryBits.Equals(file.EntryBits)
// Wrapped files can't be split because they are all inside the wrapper
canFileBeSplit := repr.Meta.Wrap == graph.WrapNone
// Make sure the generated call to "__export(exports, ...)" comes first
// before anything else in this file
if canFileBeSplit && isFileInThisChunk && repr.AST.Parts[js_ast.NSExportPartIndex].IsLive {
jsParts = appendOrExtendPartRange(jsParts, sourceIndex, js_ast.NSExportPartIndex)
}
for partIndex, part := range repr.AST.Parts {
isPartInThisChunk := isFileInThisChunk && repr.AST.Parts[partIndex].IsLive
// Also traverse any files imported by this part
for _, importRecordIndex := range part.ImportRecordIndices {
record := &repr.AST.ImportRecords[importRecordIndex]
if record.SourceIndex.IsValid() && (record.Kind == ast.ImportStmt || isPartInThisChunk) {
if c.isExternalDynamicImport(record, sourceIndex) {
// Don't follow import() dependencies
continue
}
visit(record.SourceIndex.GetIndex())
}
}
// Then include this part after the files it imports
if isPartInThisChunk {
isFileInThisChunk = true
if canFileBeSplit && uint32(partIndex) != js_ast.NSExportPartIndex && c.shouldIncludePart(repr, part) {
if sourceIndex == runtime.SourceIndex {
jsPartsPrefix = appendOrExtendPartRange(jsPartsPrefix, sourceIndex, uint32(partIndex))
} else {
jsParts = appendOrExtendPartRange(jsParts, sourceIndex, uint32(partIndex))
}
}
}
}
if isFileInThisChunk {
js = append(js, sourceIndex)
// CommonJS files are all-or-nothing so all parts must be contiguous
if !canFileBeSplit {
jsPartsPrefix = append(jsPartsPrefix, partRange{
sourceIndex: sourceIndex,
partIndexBegin: 0,
partIndexEnd: uint32(len(repr.AST.Parts)),
})
}
}
}
}
for more details.

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.

1 participant