diff options
Diffstat (limited to 'src/js_printer.zig')
-rw-r--r-- | src/js_printer.zig | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index af820520e..8a540edf9 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -1831,7 +1831,11 @@ fn NewPrinter( } if (comptime is_bun_platform) { - p.print("import.meta.require"); + if (p.options.module_type == .esm) { + p.print("import.meta.require"); + } else { + p.print("require"); + } } else { p.printSymbol(p.options.require_ref.?); } @@ -2183,6 +2187,15 @@ fn NewPrinter( p.print(")"); } }, + .e_require_call_target => { + p.addSourceMapping(expr.loc); + + if (p.options.module_type == .cjs or !is_bun_platform) { + p.print("require"); + } else { + p.print("import.meta.require"); + } + }, .e_require_string => |e| { if (rewrite_esm_to_cjs and p.importRecord(e.import_record_index).is_legacy_bundled) { p.printIndent(); |