aboutsummaryrefslogtreecommitdiff
path: root/src/js_printer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_printer.zig')
-rw-r--r--src/js_printer.zig24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig
index b2436bbf7..6cbd1a931 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -355,6 +355,13 @@ pub fn NewPrinter(
pub fn printSymbol(p: *Printer, ref: Ref) void {
debug("<printSymbol>\n {s}", .{ref});
defer debugl("</printSymbol>");
+ if (speedy) {
+ if (p.options.require_ref) |require| {
+ if (ref.eql(require)) {
+ return p.printIdentifier("module.require");
+ }
+ }
+ }
const name = p.renamer.nameForSymbol(ref);
p.printIdentifier(name);
@@ -436,6 +443,14 @@ pub fn NewPrinter(
p.print("}");
}
+ pub fn bestQuoteCharForEString(p: *Printer, str: *const E.String, allow_backtick: bool) u8 {
+ if (str.isUTF8()) {
+ return p.bestQuoteCharForString(str.utf8, allow_backtick);
+ } else {
+ return p.bestQuoteCharForString(str.value, allow_backtick);
+ }
+ }
+
pub fn bestQuoteCharForString(p: *Printer, str: anytype, allow_backtick: bool) u8 {
var single_cost: usize = 0;
var double_cost: usize = 0;
@@ -697,8 +712,13 @@ pub fn NewPrinter(
p.printSpaceBeforeIdentifier();
+ if (speedy) {
+ p.print("module.require(");
+ } else {
+ p.print("require(");
+ }
// if (p.options.platform == .node) {
- p.print("require(");
+
p.printQuotedUTF8(record.path.text, true);
p.print(")");
// } else {
@@ -1286,7 +1306,7 @@ pub fn NewPrinter(
return;
}
- const c = p.bestQuoteCharForString(e.value, true);
+ const c = p.bestQuoteCharForEString(e, true);
p.print(c);
p.printStringContent(e, c);
p.print(c);