diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 4cf8ffbe94..1ff5a0b6c9 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -4249,7 +4249,7 @@ pub const LinkerContext = struct { // Stop now if there were errors if (this.log.hasErrors()) { - return &[_]Chunk{}; + return error.BuildFailed; } if (comptime FeatureFlags.help_catch_memory_issues) { @@ -7611,11 +7611,10 @@ pub const LinkerContext = struct { } const imported_pretty_path = c.parse_graph.input_files.items(.source)[source_index].path.pretty; - const text: string = if (strings.eql(imported_pretty_path, tla_pretty_path)) { - std.fmt.allocPrint(c.allocator, "This require call is not allowed because the imported file {s} contains a top-level await", .{imported_pretty_path}) catch bun.outOfMemory(); - } else { - std.fmt.allocPrint(c.allocator, "This require call is not allowed because the transitive dependency {s} contains a top-level await", .{tla_pretty_path}) catch bun.outOfMemory(); - }; + const text: string = if (strings.eql(imported_pretty_path, tla_pretty_path)) + std.fmt.allocPrint(c.allocator, "This require call is not allowed because the imported file \"{s}\" contains a top-level await", .{imported_pretty_path}) catch bun.outOfMemory() + else + std.fmt.allocPrint(c.allocator, "This require call is not allowed because the transitive dependency \"{s}\" contains a top-level await", .{tla_pretty_path}) catch bun.outOfMemory(); const source: Logger.Source = c.parse_graph.input_files.items(.source)[source_index]; c.log.addRangeErrorWithNotes(&source, record.range, text, notes.items) catch bun.outOfMemory(); @@ -9572,6 +9571,8 @@ pub const LinkerContext = struct { const trace = tracer(@src(), "generateChunksInParallel"); defer trace.end(); + bun.assert(chunks.len > 0); + { debug(" START {d} renamers", .{chunks.len}); defer debug(" DONE {d} renamers", .{chunks.len}); diff --git a/src/js_ast.zig b/src/js_ast.zig index f5029d682f..f00f4137d1 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -6823,7 +6823,7 @@ pub const Ast = struct { // that they can be used in log messages. Check to see if "Len > 0". import_keyword: logger.Range = logger.Range.None, // Does not include TypeScript-specific syntax or "import()" export_keyword: logger.Range = logger.Range.None, // Does not include TypeScript-specific syntax - top_level_await_keyword: logger.Range, + top_level_await_keyword: logger.Range = logger.Range.None, /// These are stored at the AST level instead of on individual AST nodes so /// they can be manipulated efficiently without a full AST traversal diff --git a/test/bundler/esbuild/default.test.ts b/test/bundler/esbuild/default.test.ts index 79a475d1b0..1305fe330c 100644 --- a/test/bundler/esbuild/default.test.ts +++ b/test/bundler/esbuild/default.test.ts @@ -3512,7 +3512,8 @@ describe("bundler", () => { "/entry.js": [ 'This require call is not allowed because the transitive dependency "c.js" contains a top-level await', 'This require call is not allowed because the transitive dependency "c.js" contains a top-level await', - 'This require call is not allowed because the transitive dependency "entry.js" contains a top-level await', + 'This require call is not allowed because the transitive dependency "c.js" contains a top-level await', + 'This require call is not allowed because the imported file "entry.js" contains a top-level await', ], }, });