diff options
| -rw-r--r-- | src/linker.zig | 12 | ||||
| -rw-r--r-- | src/node_module_bundle.zig | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/linker.zig b/src/linker.zig index 4e90d0072..9afb6af60 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -252,7 +252,7 @@ pub fn NewLinker(comptime BundlerType: type) type { const package = &node_modules_bundle.bundle.packages[pkg_id]; - if (isDebug) { + if (comptime isDebug) { std.debug.assert(strings.eql(node_modules_bundle.str(package.name), package_json.name)); } @@ -275,6 +275,16 @@ pub fn NewLinker(comptime BundlerType: type) type { return error.RebuildJSB; }; + if (comptime isDebug) { + const module_path = node_modules_bundle.str(found_module.path); + std.debug.assert( + strings.eql( + module_path, + package_relative_path, + ), + ); + } + import_record.is_bundled = true; import_record.path.text = linker.nodeModuleBundleImportPath(); import_record.module_id = found_module.id; diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index 94bbe5258..274e552de 100644 --- a/src/node_module_bundle.zig +++ b/src/node_module_bundle.zig @@ -201,9 +201,9 @@ pub const NodeModuleBundle = struct { package: *const Api.JavascriptBundledPackage, _query: string, ) ?u32 { - for (this.bundle.modules[package.modules_offset..][0..package.modules_length]) |mod, i| { + for (modulesIn(&this.bundle, package)) |mod, i| { if (strings.eql(this.str(mod.path), _query)) { - return @truncate(u32, i); + return @truncate(u32, i + package.modules_offset); } } @@ -263,7 +263,7 @@ pub const NodeModuleBundle = struct { modules, finder, ModuleFinder.cmpAsc, - ) orelse return null); + ) orelse return null) + package.modules_offset; } pub fn init(container: Api.JavascriptBundleContainer, allocator: *std.mem.Allocator) NodeModuleBundle { |
