aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-27 01:33:23 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-27 01:33:23 -0700
commit4f9558dd71be56345a7dfe7a9b69e3c9031caf55 (patch)
tree8b949b83773ce476f6256cef62e25b19ac19b254
parent86109dcfd008baf8778cc221cc25f90dd77121e9 (diff)
downloadbun-4f9558dd71be56345a7dfe7a9b69e3c9031caf55.tar.gz
bun-4f9558dd71be56345a7dfe7a9b69e3c9031caf55.tar.zst
bun-4f9558dd71be56345a7dfe7a9b69e3c9031caf55.zip
Bundling ignores macros
-rw-r--r--src/js_parser/js_parser.zig36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index cf251c66a..c73ae5718 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -1855,9 +1855,10 @@ pub const Parser = struct {
// - import 'foo';
// - import("foo")
// - require("foo")
- import_record.is_unused = import_record.kind == .stmt and
+ import_record.is_unused = import_record.is_unused or
+ (import_record.kind == .stmt and
!import_record.was_originally_bare_import and
- !import_record.calls_run_time_re_export_fn;
+ !import_record.calls_run_time_re_export_fn);
}
var iter = scan_pass.used_symbols.iterator();
@@ -6168,6 +6169,7 @@ pub fn NewParser(
p.import_records.items[stmt.import_record_index].path.namespace = js_ast.Macro.namespace;
if (comptime only_scan_imports_and_do_not_visit) {
p.import_records.items[stmt.import_record_index].path.is_disabled = true;
+ p.import_records.items[stmt.import_record_index].is_internal = true;
}
}
@@ -6175,10 +6177,12 @@ pub fn NewParser(
const name = p.loadNameFromRef(stmt.namespace_ref);
stmt.namespace_ref = try p.declareSymbol(.import, star, name);
if (comptime ParsePassSymbolUsageType != void) {
- p.parse_pass_symbol_uses.put(name, .{
- .ref = stmt.namespace_ref,
- .import_record_index = stmt.import_record_index,
- }) catch unreachable;
+ if (!is_macro) {
+ p.parse_pass_symbol_uses.put(name, .{
+ .ref = stmt.namespace_ref,
+ .import_record_index = stmt.import_record_index,
+ }) catch unreachable;
+ }
}
if (is_macro) {
@@ -6208,10 +6212,12 @@ pub fn NewParser(
try p.is_import_item.put(ref, true);
name_loc.ref = ref;
if (comptime ParsePassSymbolUsageType != void) {
- p.parse_pass_symbol_uses.put(name, .{
- .ref = ref,
- .import_record_index = stmt.import_record_index,
- }) catch unreachable;
+ if (!is_macro) {
+ p.parse_pass_symbol_uses.put(name, .{
+ .ref = ref,
+ .import_record_index = stmt.import_record_index,
+ }) catch unreachable;
+ }
}
if (is_macro) {
@@ -6230,10 +6236,12 @@ pub fn NewParser(
item_refs.putAssumeCapacity(item.alias, LocRef{ .loc = item.name.loc, .ref = ref });
if (comptime ParsePassSymbolUsageType != void) {
- p.parse_pass_symbol_uses.put(name, .{
- .ref = ref,
- .import_record_index = stmt.import_record_index,
- }) catch unreachable;
+ if (!is_macro) {
+ p.parse_pass_symbol_uses.put(name, .{
+ .ref = ref,
+ .import_record_index = stmt.import_record_index,
+ }) catch unreachable;
+ }
}
if (is_macro) {