From b249d1b75b206aab38c5770b1d5940a0b5b0bf30 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 15 Dec 2022 23:39:59 -0800 Subject: [js parser] Ignore calls to import.meta.require that will never happen --- src/js_parser.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/js_parser.zig b/src/js_parser.zig index 5731a9c8d..38251d42f 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -14569,6 +14569,13 @@ fn NewParser_( } if (p.options.features.dynamic_require) { + // Ignore calls to require() if the control flow is provably + // dead here. We don't want to spend time scanning the required files + // if they will never be used. + if (p.is_control_flow_dead) { + return p.e(E.Null{}, expr.loc); + } + p.ignoreUsage(p.require_ref); return p.e( E.Call{ -- cgit v1.2.3