diff options
-rw-r--r-- | src/bundler.zig | 31 | ||||
-rw-r--r-- | src/http.zig | 2 | ||||
-rw-r--r-- | src/javascript/jsc/javascript.zig | 2 | ||||
-rw-r--r-- | src/linker.zig | 10 |
4 files changed, 32 insertions, 13 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index 7657317d8..6eb2e9d03 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -2434,9 +2434,8 @@ pub const Bundler = struct { return BuildResolveResultPair{ .written = 0, .input_fd = result.input_fd, .empty = true }; } - try bundler.linker.link(file_path, &result, origin, import_path_format, false); - if (bundler.options.platform.isBun()) { + try bundler.linker.link(file_path, &result, origin, import_path_format, false, true); return BuildResolveResultPair{ .written = switch (result.ast.exports_kind) { .esm => try bundler.printWithSourceMapMaybe( @@ -2461,6 +2460,8 @@ pub const Bundler = struct { }; } + try bundler.linker.link(file_path, &result, origin, import_path_format, false, false); + return BuildResolveResultPair{ .written = switch (result.ast.exports_kind) { .none, .esm => try bundler.printWithSourceMapMaybe( @@ -2546,14 +2547,24 @@ pub const Bundler = struct { ) orelse { return null; }; - - try bundler.linker.link( - file_path, - &result, - bundler.options.origin, - import_path_format, - false, - ); + if (!bundler.options.platform.isBun()) + try bundler.linker.link( + file_path, + &result, + bundler.options.origin, + import_path_format, + false, + false, + ) + else + try bundler.linker.link( + file_path, + &result, + bundler.options.origin, + import_path_format, + false, + true, + ); output_file.size = switch (bundler.options.platform) { .neutral, .browser, .node => try bundler.print( diff --git a/src/http.zig b/src/http.zig index 4a93da2b3..1948cdecf 100644 --- a/src/http.zig +++ b/src/http.zig @@ -351,6 +351,7 @@ pub const RequestContext = struct { .absolute_url, false, false, + false, ); var buffer_writer = try JSPrinter.BufferWriter.init(default_allocator); @@ -1031,6 +1032,7 @@ pub const RequestContext = struct { this.origin, .absolute_url, false, + false, ) catch return WatchBuildResult{ .value = .{ .fail = .{ diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 0e00bf0ec..e63c94b3b 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -1001,6 +1001,7 @@ pub const VirtualMachine = struct { jsc_vm.origin, .absolute_path, false, + true, ); var printer = source_code_printer.?.*; var written: usize = undefined; @@ -1152,6 +1153,7 @@ pub const VirtualMachine = struct { jsc_vm.origin, .absolute_path, false, + true, ); if (!jsc_vm.macro_mode) 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; |