From 2173d308d62cb1fa48188d45bb5ffa30ec446728 Mon Sep 17 00:00:00 2001 From: Zack Radisic <56137411+zackradisic@users.noreply.github.com> Date: Fri, 26 Sep 2025 17:45:05 -0700 Subject: [PATCH] damn --- src/bundler/LinkerGraph.zig | 2 +- src/bundler/bundle_v2.zig | 5 ++++- .../linker_context/computeCrossChunkDependencies.zig | 6 ++++-- src/bundler/linker_context/postProcessJSChunk.zig | 6 ++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/bundler/LinkerGraph.zig b/src/bundler/LinkerGraph.zig index 0e436c0771..cbbe5e1f37 100644 --- a/src/bundler/LinkerGraph.zig +++ b/src/bundler/LinkerGraph.zig @@ -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); diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index f93b2904d1..934fc1dba0 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -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(), diff --git a/src/bundler/linker_context/computeCrossChunkDependencies.zig b/src/bundler/linker_context/computeCrossChunkDependencies.zig index 8e4c3ba3ac..079d08cd41 100644 --- a/src/bundler/linker_context/computeCrossChunkDependencies.zig +++ b/src/bundler/linker_context/computeCrossChunkDependencies.zig @@ -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 diff --git a/src/bundler/linker_context/postProcessJSChunk.zig b/src/bundler/linker_context/postProcessJSChunk.zig index 110b3870cd..b89bdf4a01 100644 --- a/src/bundler/linker_context/postProcessJSChunk.zig +++ b/src/bundler/linker_context/postProcessJSChunk.zig @@ -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