aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-03 01:56:02 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-03 01:56:02 -0800
commit7f00482cfec3a938c2d7a7fe07aaffc4ecbe316f (patch)
tree872bacb8ac5f26ec9d95720f740a753e982db729
parentb2a69a35b8887c233c606e9f2e7ebec35f82a65e (diff)
downloadbun-7f00482cfec3a938c2d7a7fe07aaffc4ecbe316f.tar.gz
bun-7f00482cfec3a938c2d7a7fe07aaffc4ecbe316f.tar.zst
bun-7f00482cfec3a938c2d7a7fe07aaffc4ecbe316f.zip
Fix bug with macro remaps in Bun.Transpiler api
-rw-r--r--src/javascript/jsc/api/transpiler.zig11
-rw-r--r--src/javascript/jsc/bindings/helpers.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/javascript/jsc/api/transpiler.zig b/src/javascript/jsc/api/transpiler.zig
index 894287b7c..68985719c 100644
--- a/src/javascript/jsc/api/transpiler.zig
+++ b/src/javascript/jsc/api/transpiler.zig
@@ -530,6 +530,10 @@ pub fn constructor(
return null;
};
+ if (transpiler_options.macro_map.count() > 0) {
+ bundler.options.macro_remap = transpiler_options.macro_map;
+ }
+
var transpiler = getAllocator(ctx).create(Transpiler) catch unreachable;
transpiler.* = Transpiler{
.transpiler_options = transpiler_options,
@@ -538,10 +542,6 @@ pub fn constructor(
.scan_pass_result = ScanPassResult.init(getAllocator(ctx)),
};
- if (transpiler_options.macro_map.count() > 0) {
- bundler.options.macro_remap = transpiler_options.macro_map;
- }
-
return Class.make(ctx, transpiler);
}
@@ -907,6 +907,9 @@ pub fn scanImports(
this.bundler.options.jsx;
var opts = JSParser.Parser.Options.init(jsx, loader);
+ if (this.bundler.macro_context == null) {
+ this.bundler.macro_context = JSAst.Macro.MacroContext.init(&this.bundler);
+ }
opts.macro_context = &this.bundler.macro_context.?;
var log = logger.Log.init(getAllocator(ctx));
defer log.deinit();
diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h
index f11aaf064..cacdd624e 100644
--- a/src/javascript/jsc/bindings/helpers.h
+++ b/src/javascript/jsc/bindings/helpers.h
@@ -87,7 +87,7 @@ static bool isTaggedUTF16Ptr(const unsigned char *ptr) {
return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 63)) != 0;
}
-// Do we need to upcase the string?
+// Do we need to convert the string from UTF-8 to UTF-16?
static bool isTaggedUTF8Ptr(const unsigned char *ptr) {
return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 61)) != 0;
}