aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-05-18 12:35:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-18 12:35:34 -0700
commit755c0d62c47b0e8301a3d975697d476fe5c7436f (patch)
tree75973b4dc02d63b4fb552f34663b215576d4323a /src
parent228ca3269a97d9beb72d2a959f65aea7fb0b3964 (diff)
downloadbun-755c0d62c47b0e8301a3d975697d476fe5c7436f.tar.gz
bun-755c0d62c47b0e8301a3d975697d476fe5c7436f.tar.zst
bun-755c0d62c47b0e8301a3d975697d476fe5c7436f.zip
Fixes #2942 (#2947)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
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;
}