aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 076815e54..392d7d922 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -4803,7 +4803,6 @@ fn NewParser_(
filename_ref: Ref = Ref.None,
dirname_ref: Ref = Ref.None,
import_meta_ref: Ref = Ref.None,
- bun_plugin: js_ast.BunPlugin = .{},
scopes_in_order_visitor_index: usize = 0,
has_classic_runtime_warned: bool = false,
macro_call_count: MacroCallCountType = 0,
@@ -8146,38 +8145,6 @@ fn NewParser_(
return p.s(S.Empty{}, loc);
}
- if (p.options.features.hoist_bun_plugin and strings.eqlComptime(path.text, "bun")) {
- var plugin_i: usize = std.math.maxInt(usize);
- const items = stmt.items;
- for (items, 0..) |item, i| {
- // Mark Bun.plugin()
- // TODO: remove if they have multiple imports of the same name?
- if (strings.eqlComptime(item.alias, "plugin")) {
- const name = p.loadNameFromRef(item.name.ref.?);
- const ref = try p.declareSymbol(.other, item.name.loc, name);
- try p.is_import_item.put(p.allocator, ref, {});
- p.bun_plugin.ref = ref;
- plugin_i = i;
- break;
- }
- }
-
- if (plugin_i != std.math.maxInt(usize)) {
- var list = std.ArrayListUnmanaged(@TypeOf(stmt.items[0])){
- .items = stmt.items,
- .capacity = stmt.items.len,
- };
- // remove it from the list
- _ = list.swapRemove(plugin_i);
- stmt.items = list.items;
- }
-
- // if the import statement is now empty, remove it completely
- if (stmt.items.len == 0 and stmt.default_name == null and stmt.star_name_loc == null) {
- return p.s(S.Empty{}, loc);
- }
- }
-
const macro_remap = if ((comptime allow_macros) and !is_macro)
p.options.macro_context.getRemap(path.text)
else
@@ -14563,10 +14530,6 @@ fn NewParser_(
var partStmts = ListManaged(Stmt).fromOwnedSlice(allocator, stmts);
//
- const bun_plugin_usage_count_before: usize = if (p.options.features.hoist_bun_plugin and !p.bun_plugin.ref.isNull())
- p.symbols.items[p.bun_plugin.ref.innerIndex()].use_count_estimate
- else
- 0;
try p.visitStmtsAndPrependTempRefs(&partStmts, &opts);
@@ -14602,52 +14565,6 @@ fn NewParser_(
if (partStmts.items.len > 0) {
const _stmts = partStmts.items;
- // -- hoist_bun_plugin --
- if (_stmts.len == 1 and p.options.features.hoist_bun_plugin and !p.bun_plugin.ref.isNull()) {
- const bun_plugin_usage_count_after: usize = p.symbols.items[p.bun_plugin.ref.innerIndex()].use_count_estimate;
- if (bun_plugin_usage_count_after > bun_plugin_usage_count_before) {
- var previous_parts: []js_ast.Part = parts.items;
-
- for (previous_parts, 0..) |*previous_part, j| {
- if (previous_part.stmts.len == 0) continue;
-
- var refs = previous_part.declared_symbols.refs();
-
- for (refs) |ref| {
- if (p.symbol_uses.contains(ref)) {
- // we move this part to our other file
- for (previous_parts[0..j]) |*this_part| {
- if (this_part.stmts.len == 0) continue;
- const other_refs = this_part.declared_symbols.refs();
-
- for (other_refs) |other_ref| {
- if (previous_part.symbol_uses.contains(other_ref)) {
- try p.bun_plugin.hoisted_stmts.appendSlice(p.allocator, this_part.stmts);
- this_part.stmts = &.{};
- break;
- }
- }
- }
-
- try p.bun_plugin.hoisted_stmts.appendSlice(p.allocator, previous_part.stmts);
- break;
- }
- }
- }
- p.bun_plugin.hoisted_stmts.append(p.allocator, _stmts[0]) catch unreachable;
-
- // Single-statement part which uses Bun.plugin()
- // It's effectively an unrelated file
- if (p.declared_symbols.len() > 0 or p.symbol_uses.count() > 0) {
- p.clearSymbolUsagesFromDeadPart(.{ .stmts = undefined, .declared_symbols = p.declared_symbols, .symbol_uses = p.symbol_uses });
- p.declared_symbols.clearRetainingCapacity();
- p.import_records_for_current_part.items.len = 0;
- }
- return;
- }
- }
- // -- hoist_bun_plugin --
-
try parts.append(js_ast.Part{
.stmts = _stmts,
.symbol_uses = p.symbol_uses,
@@ -21922,7 +21839,6 @@ fn NewParser_(
else
false,
// .top_Level_await_keyword = p.top_level_await_keyword,
- .bun_plugin = p.bun_plugin,
.commonjs_named_exports = p.commonjs_named_exports,
.commonjs_export_names = p.commonjs_export_names.keys(),