diff options
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r-- | src/js_parser.zig | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index 5933b3e9d..649434690 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2988,21 +2988,31 @@ pub const Parser = struct { // https://github.com/kysely-org/kysely/issues/412 // TODO: this breaks code if they have any static variables or properties which reference anything from the parent scope // we need to fix it before we merge v0.6.0 - var list = if (!p.options.bundle and class.is_export and class.class.extends == null) &before else &parts; + var list = if (!p.options.bundle and class.class.canBeMoved()) &before else &parts; var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1); sliced.items.len = 1; sliced.items[0] = stmt; - try p.appendPart(list, sliced.items); + try p.appendPart(&parts, sliced.items); + + if (&parts != list) { + before.append(parts.getLast()) catch unreachable; + parts.items.len -= 1; + } }, .s_export_default => |value| { // We move export default statements when we can // This automatically resolves some cyclical import issues in packages like luxon // https://github.com/oven-sh/bun/issues/1961 - var list = if (!p.options.bundle and value.canBeMovedAround()) &before else &parts; + var list = if (!p.options.bundle and value.canBeMoved()) &before else &parts; var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1); sliced.items.len = 1; sliced.items[0] = stmt; - try p.appendPart(list, sliced.items); + try p.appendPart(&parts, sliced.items); + + if (&parts != list) { + before.append(parts.getLast()) catch unreachable; + parts.items.len -= 1; + } }, else => { |