aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-30 22:34:54 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-30 22:34:54 -0700
commit5fdaad9a2f609e29a9fb22a052987b76404e2ab1 (patch)
tree5fe353017ac0ce13b2959d9f85c9c673f556009f
parent5855fb7cc6a90f25975e1e494c3780f7afe74f48 (diff)
downloadbun-5fdaad9a2f609e29a9fb22a052987b76404e2ab1.tar.gz
bun-5fdaad9a2f609e29a9fb22a052987b76404e2ab1.tar.zst
bun-5fdaad9a2f609e29a9fb22a052987b76404e2ab1.zip
Pass macro_context when appropriate. This needs to be refactored more.
-rw-r--r--src/javascript/jsc/javascript.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig
index b37fd7125..f15fc08f5 100644
--- a/src/javascript/jsc/javascript.zig
+++ b/src/javascript/jsc/javascript.zig
@@ -627,10 +627,13 @@ pub const VirtualMachine = struct {
.macros = MacroMap.init(allocator),
.macro_entry_points = @TypeOf(VirtualMachine.vm.macro_entry_points).init(allocator),
};
+ vm.bundler.macro_context = null;
VirtualMachine.vm.bundler.configureLinker();
try VirtualMachine.vm.bundler.configureFramework(false);
+ vm.bundler.macro_context = js_ast.Macro.MacroContext.init(&vm.bundler);
+
if (_args.serve orelse false) {
VirtualMachine.vm.bundler.linker.onImportCSS = Bun.onImportCSS;
}
@@ -745,6 +748,7 @@ pub const VirtualMachine = struct {
opts.features.react_fast_refresh = false;
opts.filepath_hash_for_hmr = 0;
opts.warn_about_unbundled_modules = false;
+ opts.macro_context = &vm.bundler.macro_context.?;
const main_ast = (bundler.resolver.caches.js.parse(vm.allocator, opts, bundler.options.define, bundler.log, &vm.entry_point.source) catch null) orelse {
return error.ParseError;
};
@@ -870,7 +874,9 @@ pub const VirtualMachine = struct {
.absolute_path,
false,
);
- vm.resolved_count += vm.bundler.linker.import_counter - start_count;
+
+ if (!vm.macro_mode)
+ vm.resolved_count += vm.bundler.linker.import_counter - start_count;
vm.bundler.linker.import_counter = 0;
source_code_printer.ctx.reset();