mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
Fix tsconfig path longest prefix matching (#8892)
This commit is contained in:
@@ -2877,8 +2877,8 @@ pub const Resolver = struct {
|
||||
// because we want the output to always be deterministic
|
||||
if (strings.startsWith(path, prefix) and
|
||||
strings.endsWith(path, suffix) and
|
||||
(prefix.len >= longest_match_prefix_length and
|
||||
suffix.len > longest_match_suffix_length))
|
||||
(prefix.len > longest_match_prefix_length or
|
||||
(prefix.len == longest_match_prefix_length and suffix.len > longest_match_suffix_length)))
|
||||
{
|
||||
longest_match_prefix_length = @as(i32, @intCast(prefix.len));
|
||||
longest_match_suffix_length = @as(i32, @intCast(suffix.len));
|
||||
|
||||
2
test/js/bun/resolve/bar/larger-index.js
Normal file
2
test/js/bun/resolve/bar/larger-index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// this file is used in resolve.test.js
|
||||
export default {};
|
||||
@@ -71,6 +71,7 @@ it("import.meta.resolve", async () => {
|
||||
expect(await import.meta.resolve("foo/bar")).toBe(join(import.meta.path, "../baz.js"));
|
||||
expect(await import.meta.resolve("@faasjs/baz")).toBe(join(import.meta.path, "../baz.js"));
|
||||
expect(await import.meta.resolve("@faasjs/bar")).toBe(join(import.meta.path, "../bar/src/index.js"));
|
||||
expect(await import.meta.resolve("@faasjs/larger/bar")).toBe(join(import.meta.path, "../bar/larger-index.js"));
|
||||
|
||||
// works with package.json "exports"
|
||||
expect(await import.meta.resolve("package-json-exports/baz")).toBe(
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
"node-harness": ["js/node/harness.ts"],
|
||||
"deno:harness": ["js/deno/harness.ts"],
|
||||
"foo/bar": ["js/bun/resolve/baz.js"],
|
||||
"@faasjs/*": ["js/bun/resolve/*.js", "js/bun/resolve/*/src/index.js"]
|
||||
"@faasjs/*": ["js/bun/resolve/*.js", "js/bun/resolve/*/src/index.js"],
|
||||
"@faasjs/larger/*": ["js/bun/resolve/*/larger-index.js"]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user