diff options
author | 2023-04-29 16:28:27 -0700 | |
---|---|---|
committer | 2023-04-29 16:28:27 -0700 | |
commit | 406ffb9e19846f791f1e6962cd8f6594e3a7e193 (patch) | |
tree | 6e815f5688c3ea2d447da620e83316c0fc18c1ba /src/js_ast.zig | |
parent | 96e113f41c0dae1ccd58c6d1e3b6dd2c54769636 (diff) | |
download | bun-406ffb9e19846f791f1e6962cd8f6594e3a7e193.tar.gz bun-406ffb9e19846f791f1e6962cd8f6594e3a7e193.tar.zst bun-406ffb9e19846f791f1e6962cd8f6594e3a7e193.zip |
wip treeshake nested namespace importsjarred/export-star-flat
It doesn't handle several important edgecases. I don't think this code is currently in the right place.
Diffstat (limited to 'src/js_ast.zig')
-rw-r--r-- | src/js_ast.zig | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig index 410539761..5f9ed06f9 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -5210,12 +5210,12 @@ pub const S = struct { pub fn canBeMovedAround(self: ExportDefault) bool { return switch (self.value) { .expr => |e| switch (e.data) { - .e_class => |class| class.extends == null, + .e_class => |class| class.canClassBeMoved(), .e_arrow, .e_function => true, else => e.canBeConstValue(), }, .stmt => |s| switch (s.data) { - .s_class => |class| class.class.extends == null, + .s_class => |class| class.class.canClassBeMoved(), .s_function => true, else => false, }, @@ -5719,6 +5719,7 @@ pub const Ast = struct { // since we already have to traverse the AST then anyway and the parser pass // is conveniently fully parallelized. named_imports: NamedImports = NamedImports.init(bun.failing_allocator), + nested_named_imports: NestedNamedImports = NestedNamedImports.init(bun.failing_allocator), named_exports: NamedExports = NamedExports.init(bun.failing_allocator), export_star_import_records: []u32 = &([_]u32{}), @@ -5740,7 +5741,13 @@ pub const Ast = struct { }; pub const CommonJSNamedExports = bun.StringArrayHashMapUnmanaged(CommonJSNamedExport); - pub const NamedImports = std.ArrayHashMap(Ref, NamedImport, RefHashCtx, true); + pub const NestedNamedImport = struct { + alias: string, + ref: Ref, + }; + + pub const NamedImports = std.ArrayHashMap(Ref, NamedImport, RefHashCtx, false); + pub const NestedNamedImports = std.ArrayHashMap(Ref, BabyList(NestedNamedImport), RefHashCtx, false); pub const NamedExports = bun.StringArrayHashMap(NamedExport); pub const ConstValuesMap = std.ArrayHashMapUnmanaged(Ref, Expr, RefHashCtx, false); @@ -9288,7 +9295,7 @@ pub const Macro = struct { this.caller.loc, this.allocator, "cannot coerce {s} to Bun's AST. Please return a valid macro using the JSX syntax", - .{@tagName(value.jsType())}, + .{@tagName(value.jsTypeLoose())}, ) catch unreachable; break :brk error.MacroFailed; }, @@ -9320,7 +9327,7 @@ pub const Macro = struct { var blob_: ?JSC.WebCore.Blob = null; var mime_type: ?HTTP.MimeType = null; - if (value.jsType() == .DOMWrapper) { + if (value.jsTypeLoose() == .DOMWrapper) { if (value.as(JSC.WebCore.Response)) |resp| { mime_type = HTTP.MimeType.init(resp.mimeType(null)); blob_ = resp.body.use(); @@ -9535,7 +9542,7 @@ pub const Macro = struct { this.caller.loc, this.allocator, "cannot coerce {s} to Bun's AST. Please return a valid macro using the JSX syntax", - .{@tagName(value.jsType())}, + .{@tagName(value.jsTypeLoose())}, ) catch unreachable; return error.MacroFailed; } |