diff options
Diffstat (limited to 'src/resolver/resolver.zig')
-rw-r--r-- | src/resolver/resolver.zig | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 068b22dc4..e23f00c9a 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -1129,6 +1129,41 @@ pub const Resolver = struct { return .{ .not_found = {} }; } + if (strings.hasPrefixComptime(import_path, "file:///")) { + const path = import_path[7..]; + + if (r.opts.external.abs_paths.count() > 0 and r.opts.external.abs_paths.contains(path)) { + // If the string literal in the source text is an absolute path and has + // been marked as an external module, mark it as *not* an absolute path. + // That way we preserve the literal text in the output and don't generate + // a relative path from the output directory to that path. + if (r.debug_logs) |*debug| { + debug.addNoteFmt("The path \"{s}\" is marked as external by the user", .{path}); + } + + return .{ + .success = Result{ + .path_pair = .{ .primary = Path.init(import_path) }, + .is_external = true, + }, + }; + } + + if (r.loadAsFile(path, r.extension_order)) |file| { + return .{ + .success = Result{ + .dirname_fd = file.dirname_fd, + .path_pair = .{ .primary = Path.init(file.path) }, + .diff_case = file.diff_case, + .file_fd = file.file_fd, + .jsx = r.opts.jsx, + }, + }; + } + + return .{ .not_found = {} }; + } + // Check both relative and package paths for CSS URL tokens, with relative // paths taking precedence over package paths to match Webpack behavior. const is_package_path = isPackagePath(import_path); |