diff options
| author | 2022-12-15 23:39:59 -0800 | |
|---|---|---|
| committer | 2022-12-15 23:39:59 -0800 | |
| commit | b249d1b75b206aab38c5770b1d5940a0b5b0bf30 (patch) | |
| tree | 4cc041fc05ed8719a856f29827522539723a919b | |
| parent | 3495b7c1f8ee0ba187b0b4ba2938cb03ce5b74fd (diff) | |
| download | bun-b249d1b75b206aab38c5770b1d5940a0b5b0bf30.tar.gz bun-b249d1b75b206aab38c5770b1d5940a0b5b0bf30.tar.zst bun-b249d1b75b206aab38c5770b1d5940a0b5b0bf30.zip | |
[js parser] Ignore calls to import.meta.require that will never happen
| -rw-r--r-- | src/js_parser.zig | 7 |
1 files changed, 7 insertions, 0 deletions
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{ |
