diff options
author | 2022-04-10 19:45:43 -0700 | |
---|---|---|
committer | 2022-04-10 19:45:43 -0700 | |
commit | 34c478a4c47306734dc0f5ecc1d73addd735a48d (patch) | |
tree | 8d2e76edf43e2359a935bd601f24b5c7f634aa7b /src/linker.zig | |
parent | 98592fb85d6960873a5ef0028f32075978739c5c (diff) | |
download | bun-34c478a4c47306734dc0f5ecc1d73addd735a48d.tar.gz bun-34c478a4c47306734dc0f5ecc1d73addd735a48d.tar.zst bun-34c478a4c47306734dc0f5ecc1d73addd735a48d.zip |
make checking for bun modules a compile time step
Diffstat (limited to 'src/linker.zig')
-rw-r--r-- | src/linker.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/linker.zig b/src/linker.zig index 000460e25..9adccff33 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -194,8 +194,9 @@ pub const Linker = struct { origin: URL, comptime import_path_format: Options.BundleOptions.ImportPathFormat, comptime ignore_runtime: bool, + comptime is_bun: bool, ) !void { - return linkAllowImportingFromBundle(linker, file_path, result, origin, import_path_format, ignore_runtime, true); + return linkAllowImportingFromBundle(linker, file_path, result, origin, import_path_format, ignore_runtime, true, is_bun); } pub fn linkAllowImportingFromBundle( @@ -206,6 +207,7 @@ pub const Linker = struct { comptime import_path_format: Options.BundleOptions.ImportPathFormat, comptime ignore_runtime: bool, comptime allow_import_from_bundle: bool, + comptime is_bun: bool, ) !void { const source_dir = file_path.sourceDir(); var externals = std.ArrayList(u32).init(linker.allocator); @@ -258,16 +260,18 @@ pub const Linker = struct { } } - if (linker.options.platform.isBun()) { + if (comptime is_bun) { if (import_record.path.text.len > 5 and strings.eqlComptime(import_record.path.text[0.."node:".len], "node:")) { const is_fs = strings.eqlComptime(import_record.path.text[5..], "fs"); - const is_path = strings.eqlComptime(import_record.path.text[5..], "path"); + if (is_fs) { import_record.path.text = "node:fs"; externals.append(record_index) catch unreachable; continue; } + const is_path = strings.eqlComptime(import_record.path.text[5..], "path"); + if (is_path) { import_record.path.text = "node:path"; externals.append(record_index) catch unreachable; |