aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_parser')
-rw-r--r--src/js_parser/js_parser.zig43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 8fde5fcbd..74d670d00 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -11632,22 +11632,18 @@ pub fn NewParser(
e_.no = p.visitExpr(e_.no);
p.is_control_flow_dead = old;
- // we diverge from esbuild here a little
- // esbuild rewrites something like "(a, true) ? b : c" => "a, b"
- // we don't do that, since the goal isn't minifying
- // though there are some cases where _not_ doing this potentially
- // leads to unnecessary imports
- if (side_effects.side_effects == .no_side_effects) {
-
- // "(1 ? fn : 2)()" => "fn()"
- // "(1 ? this.fn : 2)" => "this.fn"
- // "(1 ? this.fn : 2)()" => "(0, this.fn)()"
- if (is_call_target and e_.yes.hasValueForThisInCall()) {
- return p.e(E.Number{ .value = 0 }, e_.test_.loc).joinWithComma(e_.yes, p.allocator);
- }
+ if (side_effects.side_effects == .could_have_side_effects) {
+ return Expr.joinWithComma(SideEffects.simpifyUnusedExpr(p, e_.test_) orelse p.e(E.Missing{}, e_.test_.loc), e_.yes, p.allocator);
+ }
- return e_.yes;
+ // "(1 ? fn : 2)()" => "fn()"
+ // "(1 ? this.fn : 2)" => "this.fn"
+ // "(1 ? this.fn : 2)()" => "(0, this.fn)()"
+ if (is_call_target and e_.yes.hasValueForThisInCall()) {
+ return p.e(E.Number{ .value = 0 }, e_.test_.loc).joinWithComma(e_.yes, p.allocator);
}
+
+ return e_.yes;
} else {
// "false ? dead : live"
const old = p.is_control_flow_dead;
@@ -11656,17 +11652,18 @@ pub fn NewParser(
p.is_control_flow_dead = old;
e_.no = p.visitExpr(e_.no);
- if (side_effects.side_effects == .no_side_effects) {
-
- // "(1 ? fn : 2)()" => "fn()"
- // "(1 ? this.fn : 2)" => "this.fn"
- // "(1 ? this.fn : 2)()" => "(0, this.fn)()"
- if (is_call_target and e_.no.hasValueForThisInCall()) {
- return p.e(E.Number{ .value = 0 }, e_.test_.loc).joinWithComma(e_.no, p.allocator);
- }
+ // "(a, false) ? b : c" => "a, c"
+ if (side_effects.side_effects == .could_have_side_effects) {
+ return Expr.joinWithComma(SideEffects.simpifyUnusedExpr(p, e_.test_) orelse p.e(E.Missing{}, e_.test_.loc), e_.no, p.allocator);
+ }
- return e_.no;
+ // "(1 ? fn : 2)()" => "fn()"
+ // "(1 ? this.fn : 2)" => "this.fn"
+ // "(1 ? this.fn : 2)()" => "(0, this.fn)()"
+ if (is_call_target and e_.no.hasValueForThisInCall()) {
+ return p.e(E.Number{ .value = 0 }, e_.test_.loc).joinWithComma(e_.no, p.allocator);
}
+ return e_.no;
}
}
},
p;showmsg=1&follow=1'>astro/test/fixtures/status-code (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2023-11-27Remove support for simple objects in endpoints (#9181)Gravatar Bjorn Lu 56-529/+206
* Deprecate simple object from endpoints * Update changeset * Add missing Response return Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> * Update .changeset/clever-beds-notice.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-11-28Remove shiki lang path property support (#9196)Gravatar Bjorn Lu 7-427/+22
2023-11-28Remove deprecated features from Astro 3.0 (#9168)Gravatar Bjorn Lu 47-398/+95
2023-11-28Remove deprecated markdown-remark APIs (#9182)Gravatar Bjorn Lu 4-59/+7
2023-11-27[ci] release (#9180)astro@3.6.1Gravatar Houston (Bot) 32-65/+63
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-24Remove vercel deprecated analytics option (#9184)Gravatar Bjorn Lu 3-30/+12
2023-11-24[ci] formatGravatar Guspan Tanadi 1-2/+1
2023-11-24style: highlight markdown Tip Note section CONTRIBUTING (#9123)Gravatar Guspan Tanadi 1-5/+7
2023-11-23fix scroll restoration issue on webKit browsers (#9186)Gravatar Martin Trapp 2-1/+7
* fix scroll restoration issue on webKit browsers * add changeset * Update .changeset/shaggy-socks-glow.md * Update .changeset/shaggy-socks-glow.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-11-23fix(middleware): rename internal middleware id (#9173)Gravatar Arsh 2-1/+6
* rename internal middleware id * add changeset
2023-11-23fix: Changelog formatting for 3.6.0 View Transition events (#9176)Gravatar Martin Trapp 1-3/+3
Co-authored-by: Eva Decker <itsevadecker@gmail.com>
2023-11-22[ci] formatGravatar Eva Decker 1-3/+3
2023-11-22Fix View Transitions code block formatting (#9174)Gravatar Eva Decker 1-3/+3
2023-11-22Rename entryPoint to entrypoint (#9161)Gravatar Bjorn Lu 14-26/+38
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-11-22Fix esbuild warning for local dev (#9160)Gravatar Bjorn Lu 1-1/+1
2023-11-22[ci] release (#9165)astro@3.6.0Gravatar Houston (Bot) 34-90/+83
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>