mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
fix tests, don't return empty chunk when handling error in link
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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',
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user