aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-01 00:19:33 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-01 00:19:33 -0700
commita4ccd4e0b4cc19f534bf639f30b7e4218400e1e8 (patch)
tree250f89bddd6e6c920645db2ad39bb7edf576edf0 /src/js_parser.zig
parentcb0f76aa73f6b85667b57015a77ac39d9c78aa0b (diff)
parent689434e012a47b9be897f6d90d6aa211b13dfc19 (diff)
downloadbun-a4ccd4e0b4cc19f534bf639f30b7e4218400e1e8.tar.gz
bun-a4ccd4e0b4cc19f534bf639f30b7e4218400e1e8.tar.zst
bun-a4ccd4e0b4cc19f534bf639f30b7e4218400e1e8.zip
Merge branch 'main' into jarred/portjarred/port
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index a9cd4379c..afec299d9 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -16156,6 +16156,7 @@ fn NewParser_(
.{
.is_call_target = is_call_target,
.assign_target = in.assign_target,
+ .is_delete_target = is_delete_target,
// .is_template_tag = p.template_tag != null,
},
)) |_expr| {
@@ -17438,14 +17439,6 @@ fn NewParser_(
p.recordUsage(p.require_ref);
return p.newExpr(E.Identifier{ .ref = p.require_ref }, name_loc);
} else if (!p.commonjs_named_exports_deoptimized and strings.eqlComptime(name, "exports")) {
- // Deoptimizations:
- // delete module.exports
- // module.exports();
-
- if (identifier_opts.is_call_target or identifier_opts.is_delete_target or identifier_opts.assign_target == .update) {
- p.deoptimizeCommonJSNamedExports();
- return null;
- }
// Detect if we are doing
//
@@ -17453,7 +17446,13 @@ fn NewParser_(
// foo: "bar"
// }
//
- if (identifier_opts.assign_target == .replace and
+ // Note that it cannot be any of these:
+ //
+ // module.exports += { };
+ // delete module.exports = {};
+ // module.exports()
+ if (!(identifier_opts.is_call_target or identifier_opts.is_delete_target) and
+ identifier_opts.assign_target == .replace and
p.stmt_expr_value == .e_binary and
p.stmt_expr_value.e_binary.op == .bin_assign)
{
@@ -17596,6 +17595,14 @@ fn NewParser_(
return p.newExpr(E.Missing{}, name_loc);
}
+ // Deoptimizations:
+ // delete module.exports
+ // module.exports();
+ if (identifier_opts.is_call_target or identifier_opts.is_delete_target or identifier_opts.assign_target != .none) {
+ p.deoptimizeCommonJSNamedExports();
+ return null;
+ }
+
// rewrite `module.exports` to `exports`
return p.newExpr(E.Identifier{ .ref = p.exports_ref }, name_loc);
} else if (p.options.bundle and strings.eqlComptime(name, "id") and identifier_opts.assign_target == .none) {