aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api')
-rw-r--r--src/bun.js/api/JSBundler.zig7
-rw-r--r--src/bun.js/api/JSTranspiler.zig7
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index 741d956bf..8e85f1190 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -61,6 +61,7 @@ pub const JSBundler = struct {
code_splitting: bool = false,
minify: Minify = .{},
server_components: ServerComponents = ServerComponents{},
+ no_macros: bool = false,
names: Names = .{},
external: bun.StringSet = bun.StringSet.init(bun.default_allocator),
@@ -188,6 +189,12 @@ pub const JSBundler = struct {
}
}
+ if (config.getTruthy(globalThis, "macros")) |macros_flag| {
+ if (!macros_flag.coerce(bool, globalThis)) {
+ this.no_macros = true;
+ }
+ }
+
if (try config.getOptionalEnum(globalThis, "target", options.Target)) |target| {
this.target = target;
}
diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig
index 8a59f59e7..c58029c5e 100644
--- a/src/bun.js/api/JSTranspiler.zig
+++ b/src/bun.js/api/JSTranspiler.zig
@@ -75,6 +75,7 @@ const TranspilerOptions = struct {
minify_whitespace: bool = false,
minify_identifiers: bool = false,
minify_syntax: bool = false,
+ no_macros: bool = false,
};
// Mimalloc gets unstable if we try to move this to a different thread
@@ -479,6 +480,10 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std
if (object.getIfPropertyExists(globalThis, "macro")) |macros| {
macros: {
if (macros.isUndefinedOrNull()) break :macros;
+ if (macros.isBoolean()) {
+ transpiler.no_macros = !macros.asBoolean();
+ break :macros;
+ }
const kind = macros.jsType();
const is_object = kind.isObject();
if (!(kind.isStringLike() or is_object)) {
@@ -775,7 +780,7 @@ pub fn constructor(
globalThis.throwError(err, "Error creating transpiler");
return null;
};
-
+ bundler.options.no_macros = transpiler_options.no_macros;
bundler.configureLinkerWithAutoJSX(false);
bundler.options.env.behavior = .disable;
bundler.configureDefines() catch |err| {