aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bundler/bundle_v2.zig7
-rw-r--r--src/js_parser.zig7
2 files changed, 9 insertions, 5 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
index ad690b644..0f69c415c 100644
--- a/src/bundler/bundle_v2.zig
+++ b/src/bundler/bundle_v2.zig
@@ -3991,7 +3991,7 @@ const LinkerContext = struct {
{
if (other_kind == .esm) {
flags[other_file].wrap = .esm;
- } else {
+ } else if (!force_cjs_to_esm[other_file]) {
flags[other_file].wrap = .cjs;
exports_kind[other_file] = .cjs;
}
@@ -4002,8 +4002,7 @@ const LinkerContext = struct {
// returns a promise, so the imported file must be a CommonJS module
if (exports_kind[other_file] == .esm) {
flags[other_file].wrap = .esm;
- } else {
- // even if force_cjs_to_esm[other_file]) is true, we need to wrap
+ } else if (!force_cjs_to_esm[other_file]) {
flags[other_file].wrap = .cjs;
exports_kind[other_file] = .cjs;
}
@@ -6041,7 +6040,7 @@ const LinkerContext = struct {
// Generate the exports for the entry point, if there are any
const entry_point_tail = brk: {
- if (chunk.isEntryPoint() or c.graph.meta.items(.flags)[chunk.entry_point.source_index].needs_synthetic_default_export) {
+ if (chunk.isEntryPoint()) {
break :brk c.generateEntryPointTailJS(
toCommonJSRef,
toESMRef,
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 3b2900187..024f2246b 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -17373,6 +17373,7 @@ fn NewParser_(
.other,
std.fmt.allocPrint(p.allocator, "${any}", .{strings.fmtIdentifier(name)}) catch unreachable,
) catch unreachable;
+ p.module_scope.generated.push(p.allocator, new_ref) catch unreachable;
named_export_entry.value_ptr.* = .{
.loc_ref = LocRef{
.loc = name_loc,
@@ -17931,7 +17932,11 @@ fn NewParser_(
.binding = p.b(B.Identifier{ .ref = ref }, bin.left.loc),
.value = bin.right,
};
- p.recordDeclaredSymbol(ref) catch unreachable;
+ // we have to ensure these are known to be top-level
+ p.declared_symbols.append(p.allocator, .{
+ .ref = ref,
+ .is_top_level = true,
+ }) catch unreachable;
p.esm_export_keyword.loc = stmt.loc;
p.esm_export_keyword.len = 5;
p.had_commonjs_named_exports_this_visit = true;