aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bundler/bundle_v2.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
index dca0d6982..d1b43c80b 100644
--- a/src/bundler/bundle_v2.zig
+++ b/src/bundler/bundle_v2.zig
@@ -7397,7 +7397,20 @@ const LinkerContext = struct {
var clone = std.ArrayList(G.Decl).initCapacity(allocator, before.decls.len + after.decls.len) catch unreachable;
clone.appendSliceAssumeCapacity(before.decls.slice());
clone.appendSliceAssumeCapacity(after.decls.slice());
- before.decls.update(clone);
+ // we must clone instead of overwrite in-place incase the same S.Local is used across threads
+ // https://github.com/oven-sh/bun/issues/2942
+ stmts.items[end - 1] = Stmt.allocate(
+ allocator,
+ S.Local,
+ S.Local{
+ .decls = BabyList(G.Decl).fromList(clone),
+ .is_export = before.is_export,
+ .was_commonjs_export = before.was_commonjs_export,
+ .was_ts_import_equals = before.was_ts_import_equals,
+ .kind = before.kind,
+ },
+ stmts.items[end - 1].loc,
+ );
}
continue;
}