Fix bug with macro remaps in Bun.Transpiler api

This commit is contained in:
Jarred Sumner
2022-02-03 01:56:02 -08:00
parent b2a69a35b8
commit 7f00482cfe
2 changed files with 8 additions and 5 deletions

View File

@@ -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();

View File

@@ -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;
}