From 5ecf48a21dffc5aebabe439ec534fea7b91b16b8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 4 Aug 2021 13:02:16 -0700 Subject: [PATCH] Fix node_modules.jsb loading in JSC Former-commit-id: 43366ce3634ca35629e1f8234df86206f6411910 --- src/javascript/jsc/javascript.zig | 3 ++- src/node_module_bundle.zig | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 230bbcf834..3df351a248 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -113,7 +113,7 @@ pub const VirtualMachine = struct { threadlocal var source_code_printer: js_printer.BufferPrinter = undefined; threadlocal var source_code_printer_loaded: bool = false; - fn _fetch( + inline fn _fetch( global: *JSGlobalObject, specifier: string, source: string, @@ -130,6 +130,7 @@ pub const VirtualMachine = struct { // - file path + file descriptor for bytecode caching // - separate bundles for server build vs browser build OR at least separate sections const code = try vm.node_modules.?.readCodeAsStringSlow(vm.allocator); + return ResolvedSource{ .source_code = ZigString.init(code), .specifier = ZigString.init(vm.bundler.linker.nodeModuleBundleImportPath()), diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index f745581fe2..63bb678d7d 100644 --- a/src/node_module_bundle.zig +++ b/src/node_module_bundle.zig @@ -303,7 +303,7 @@ pub const NodeModuleBundle = struct { .bundle = container.bundle.?, .fd = stream.handle, // sorry you can't have 4 GB of node_modules - .code_end_pos = @truncate(u32, file_end) - @intCast(u32, jsbundle_prefix.len), + .code_end_pos = end - @intCast(u32, jsbundle_prefix.len), .bytes = read_bytes, .bytes_ptr = file_bytes, .package_id_map = undefined,