aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-16 17:57:44 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-16 17:57:44 -0800
commit50163e13855239983f5eb0390b9702c39426fe9f (patch)
tree2f627932e18dfe3dc0b459c6b6b5c92f241d9742
parentfde4cd4d1764994c4875507538d578c0ac576d74 (diff)
downloadbun-50163e13855239983f5eb0390b9702c39426fe9f.tar.gz
bun-50163e13855239983f5eb0390b9702c39426fe9f.tar.zst
bun-50163e13855239983f5eb0390b9702c39426fe9f.zip
Disable imports which are not found
-rw-r--r--src/import_record.zig7
-rw-r--r--src/linker.zig6
2 files changed, 12 insertions, 1 deletions
diff --git a/src/import_record.zig b/src/import_record.zig
index b7146215a..870159df4 100644
--- a/src/import_record.zig
+++ b/src/import_record.zig
@@ -31,6 +31,13 @@ pub const ImportKind = enum(u8) {
internal,
+ pub inline fn isCommonJS(this: ImportKind) bool {
+ return switch (this) {
+ .require, .require_resolve => true,
+ else => false,
+ };
+ }
+
pub fn jsonStringify(self: @This(), options: anytype, writer: anytype) !void {
return try std.json.stringify(@tagName(self), options, writer);
}
diff --git a/src/linker.zig b/src/linker.zig
index 533ffb544..48a715927 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -331,7 +331,11 @@ pub const Linker = struct {
} else |err| {
switch (err) {
error.ModuleNotFound => {
- if (import_record.handles_import_errors) continue;
+ if (import_record.handles_import_errors) {
+ import_record.path.is_disabled = true;
+ continue;
+ }
+
had_resolve_errors = true;
if (import_record.path.text.len > 0 and Resolver.isPackagePath(import_record.path.text)) {