diff options
Diffstat (limited to 'src/linker.zig')
| -rw-r--r-- | src/linker.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/linker.zig b/src/linker.zig index d0f48e8a1..44439a0ec 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -160,6 +160,12 @@ pub fn NewLinker(comptime BundlerType: type) type { unreachable; } + + pub inline fn nodeModuleBundleImportPath(this: *const ThisLinker) string { + return if (this.options.node_modules_bundle_url.len > 0) this.options.node_modules_bundle_url else this.options.node_modules_bundle.?.bundle.import_from_name; + } + + // pub const Scratch = struct { // threadlocal var externals: std.ArrayList(u32) = undefined; // threadlocal var has_externals: std.ArrayList(u32) = undefined; @@ -190,8 +196,8 @@ pub fn NewLinker(comptime BundlerType: type) type { if (comptime !ignore_runtime) { if (strings.eqlComptime(import_record.path.text, Runtime.Imports.Name)) { // runtime is included in the bundle, so we don't need to dynamically import it - if (linker.options.node_modules_bundle) |node_modules_bundle| { - import_record.path.text = if (linker.options.node_modules_bundle_url.len > 0) linker.options.node_modules_bundle_url else node_modules_bundle.bundle.import_from_name; + if (linker.options.node_modules_bundle != null) { + import_record.path.text = linker.nodeModuleBundleImportPath(); } else { import_record.path = try linker.generateImportPath( source_dir, @@ -272,7 +278,7 @@ pub fn NewLinker(comptime BundlerType: type) type { }; import_record.is_bundled = true; - import_record.path.text = if (linker.options.node_modules_bundle_url.len > 0) linker.options.node_modules_bundle_url else node_modules_bundle.bundle.import_from_name; + import_record.path.text = linker.nodeModuleBundleImportPath(); import_record.module_id = found_module.id; needs_bundle = true; continue; |
