This commit is contained in:
Zack Radisic
2025-09-26 17:45:05 -07:00
parent dfafe46f71
commit 2173d308d6
4 changed files with 15 additions and 4 deletions

View File

@@ -319,7 +319,7 @@ pub fn load(
// For client components, the import record index currently points to the original source index, instead of the reference source index.
for (this.reachable_files) |source_id| {
for (import_records_list[source_id.get()].slice()) |*import_record| {
if (import_record.source_index.isValid() and this.is_scb_bitset.isSet(import_record.source_index.get())) {
if (import_record.source_index.isValid() and this.is_scb_bitset.isSet(import_record.source_index.get()) and this.ast.items(.target)[source_id.get()] != .browser) {
// Only rewrite if this is an original SCB file, not a reference file
if (scb.getReferenceSourceIndex(import_record.source_index.get())) |ref_index| {
import_record.source_index = Index.init(ref_index);

View File

@@ -3845,14 +3845,17 @@ pub const BundleV2 = struct {
.browser,
) catch |err| bun.handleOom(err);
break :brk .{ server_index, Index.invalid.get() };
// break :brk .{ server_index, Index.invalid.get() };
break :brk .{ Index.invalid.get(), server_index };
};
// if (result.ast.target != .browser) {
graph.pathToSourceIndexMap(result.ast.target).put(
this.allocator(),
result.source.path.text,
reference_source_index,
) catch |err| bun.handleOom(err);
// }
graph.server_component_boundaries.put(
this.allocator(),

View File

@@ -227,11 +227,13 @@ fn computeCrossChunkDependenciesWithChunkMetas(c: *LinkerContext, chunks: []Chun
// Ignore uses that aren't top-level symbols
if (symbol.chunkIndex()) |other_chunk_index| {
if (@as(usize, other_chunk_index) != chunk_index) {
if (comptime Environment.allow_assert)
if (comptime Environment.allow_assert) {
const file = c.parse_graph.input_files.get(import_ref.sourceIndex()).source.path.text;
debug("Import name: {s} (in {s})", .{
symbol.original_name,
c.parse_graph.input_files.get(import_ref.sourceIndex()).source.path.text,
file,
});
}
{
var entry = try js

View File

@@ -91,6 +91,7 @@ pub fn postProcessJSChunk(ctx: GenerateChunkCtx, worker: *ThreadPool.Worker, chu
c,
toCommonJSRef,
toESMRef,
chunk,
chunk.entry_point.source_index,
worker.allocator,
arena.allocator(),
@@ -439,6 +440,7 @@ pub fn generateEntryPointTailJS(
c: *LinkerContext,
toCommonJSRef: Ref,
toESMRef: Ref,
chunk: *Chunk,
source_index: Index.Int,
allocator: std.mem.Allocator,
temp_allocator: std.mem.Allocator,
@@ -641,6 +643,10 @@ pub fn generateEntryPointTailJS(
},
) catch unreachable;
} else {
if (chunk.content.javascript.exports_to_other_chunks.get(resolved_export.data.import_ref) != null) {
continue;
}
// Local identifiers can be exported using an export clause. This is done
// this way instead of leaving the "export" keyword on the local declaration
// itself both because it lets the local identifier be minified and because