diff options
-rw-r--r-- | src/bundler.zig | 108 | ||||
-rw-r--r-- | src/linker.zig | 7 |
2 files changed, 62 insertions, 53 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index 094251ce9..ddcc5fd58 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -1625,11 +1625,13 @@ pub const Bundler = struct { ); } else |err| { if (comptime isDebug) { - Output.prettyErrorln("\n<r><red>{s}<r> on resolving \"{s}\" from \"{s}\"", .{ - @errorName(err), - import_record.path.text, - file_path.text, - }); + if (!import_record.handles_import_errors) { + Output.prettyErrorln("\n<r><red>{s}<r> on resolving \"{s}\" from \"{s}\"", .{ + @errorName(err), + import_record.path.text, + file_path.text, + }); + } } // Disable failing packages from being printed. @@ -1640,37 +1642,39 @@ pub const Bundler = struct { switch (err) { error.ModuleNotFound => { - if (isPackagePath(import_record.path.text)) { - if (this.bundler.options.platform.isWebLike() and options.ExternalModules.isNodeBuiltin(import_record.path.text)) { - try log.addResolveErrorWithTextDupe( - &source, - import_record.range, - this.allocator, - "Could not resolve Node.js builtin: \"{s}\".", - .{import_record.path.text}, - import_record.kind, - ); + if (!import_record.handles_import_errors) { + if (isPackagePath(import_record.path.text)) { + if (this.bundler.options.platform.isWebLike() and options.ExternalModules.isNodeBuiltin(import_record.path.text)) { + try log.addResolveErrorWithTextDupe( + &source, + import_record.range, + this.allocator, + "Could not resolve Node.js builtin: \"{s}\".", + .{import_record.path.text}, + import_record.kind, + ); + } else { + try log.addResolveErrorWithTextDupe( + &source, + import_record.range, + this.allocator, + "Could not resolve: \"{s}\". Maybe you need to \"npm install\" (or yarn/pnpm)?", + .{import_record.path.text}, + import_record.kind, + ); + } } else { try log.addResolveErrorWithTextDupe( &source, import_record.range, this.allocator, - "Could not resolve: \"{s}\". Maybe you need to \"npm install\" (or yarn/pnpm)?", - .{import_record.path.text}, + "Could not resolve: \"{s}\"", + .{ + import_record.path.text, + }, import_record.kind, ); } - } else { - try log.addResolveErrorWithTextDupe( - &source, - import_record.range, - this.allocator, - "Could not resolve: \"{s}\"", - .{ - import_record.path.text, - }, - import_record.kind, - ); } }, // assume other errors are already in the log @@ -2063,37 +2067,39 @@ pub const Bundler = struct { } else |err| { switch (err) { error.ModuleNotFound => { - if (isPackagePath(import_record.path.text)) { - if (this.bundler.options.platform.isWebLike() and options.ExternalModules.isNodeBuiltin(import_record.path.text)) { - try log.addResolveErrorWithTextDupe( - &source, - import_record.range, - this.allocator, - "Could not resolve Node.js builtin: \"{s}\".", - .{import_record.path.text}, - import_record.kind, - ); + if (!import_record.handles_import_errors) { + if (isPackagePath(import_record.path.text)) { + if (this.bundler.options.platform.isWebLike() and options.ExternalModules.isNodeBuiltin(import_record.path.text)) { + try log.addResolveErrorWithTextDupe( + &source, + import_record.range, + this.allocator, + "Could not resolve Node.js builtin: \"{s}\".", + .{import_record.path.text}, + import_record.kind, + ); + } else { + try log.addResolveErrorWithTextDupe( + &source, + import_record.range, + this.allocator, + "Could not resolve: \"{s}\". Maybe you need to \"npm install\" (or yarn/pnpm)?", + .{import_record.path.text}, + import_record.kind, + ); + } } else { try log.addResolveErrorWithTextDupe( &source, import_record.range, this.allocator, - "Could not resolve: \"{s}\". Maybe you need to \"npm install\" (or yarn/pnpm)?", - .{import_record.path.text}, + "Could not resolve: \"{s}\"", + .{ + import_record.path.text, + }, import_record.kind, ); } - } else { - try log.addResolveErrorWithTextDupe( - &source, - import_record.range, - this.allocator, - "Could not resolve: \"{s}\"", - .{ - import_record.path.text, - }, - import_record.kind, - ); } }, // assume other errors are already in the log diff --git a/src/linker.zig b/src/linker.zig index b031952b2..533ffb544 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -329,10 +329,11 @@ pub const Linker = struct { import_record.module_id = @truncate(u32, std.hash.Wyhash.hash(0, path.pretty)); } } else |err| { - had_resolve_errors = true; - switch (err) { error.ModuleNotFound => { + if (import_record.handles_import_errors) continue; + had_resolve_errors = true; + if (import_record.path.text.len > 0 and Resolver.isPackagePath(import_record.path.text)) { if (linker.options.platform.isWebLike() and Options.ExternalModules.isNodeBuiltin(import_record.path.text)) { try linker.log.addResolveError( @@ -370,6 +371,8 @@ pub const Linker = struct { } }, else => { + had_resolve_errors = true; + try linker.log.addResolveError( &result.source, import_record.range, |