diff options
author | 2023-08-03 16:27:45 -0700 | |
---|---|---|
committer | 2023-08-03 16:27:45 -0700 | |
commit | 9574db355f1435f60214726b21f1ca5bb9d13f6c (patch) | |
tree | be7c45db575a862c0d48724e894dac2a9804b74d /src | |
parent | a4d996c337605c40018e997900ee9638f3ea9edf (diff) | |
download | bun-9574db355f1435f60214726b21f1ca5bb9d13f6c.tar.gz bun-9574db355f1435f60214726b21f1ca5bb9d13f6c.tar.zst bun-9574db355f1435f60214726b21f1ca5bb9d13f6c.zip |
allow bundling builtins for browser (#3959)
* Update resolver.zig
* bundle resolve error for non-existent builtins
* tests
Diffstat (limited to 'src')
-rw-r--r-- | src/resolver/resolver.zig | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 8735981fc..e4d7686a4 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -32,6 +32,7 @@ const NodeFallbackModules = @import("../node_fallbacks.zig"); const Mutex = @import("../lock.zig").Lock; const StringBoolMap = bun.StringHashMap(bool); const FileDescriptorType = bun.FileDescriptor; +const JSC = bun.JSC; const allocators = @import("../allocators.zig"); const Msg = logger.Msg; @@ -1262,12 +1263,6 @@ pub const Resolver = struct { const had_node_prefix = strings.hasPrefixComptime(import_path, "node:"); const import_path_without_node_prefix = if (had_node_prefix) import_path["node:".len..] else import_path; - if (had_node_prefix) { - // because all node modules are already checked in ../linker.zig (JSC.HardcodedModule.Aliases.get) if module is not found here, it is not found at all - // so we can just return not_found - return .{ .not_found = {} }; - } - if (NodeFallbackModules.Map.get(import_path_without_node_prefix)) |*fallback_module| { result.path_pair.primary = fallback_module.path; result.module_type = .cjs; @@ -1278,6 +1273,8 @@ pub const Resolver = struct { // "fs" // "fs/*" // These are disabled! + } else if (had_node_prefix and !JSC.HardcodedModule.Aliases.has(import_path_without_node_prefix)) { + return .{ .not_found = {} }; } else if (had_node_prefix or (strings.hasPrefixComptime(import_path_without_node_prefix, "fs") and (import_path_without_node_prefix.len == 2 or |