Skip to content

Commit 69c36aa

Browse files
committed
fix(externals): skip bare scopes as unresolvable
1 parent 1104023 commit 69c36aa

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/build/plugins/externals.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ export function resolveTraceDeps(
286286
// resolve time and traced explicitly. Force-tracing by name also fixes pnpm,
287287
// where a nested dependency only resolves from the dependent package's real
288288
// `.pnpm` location.
289+
// Bare scopes (`@scope`) are prefix selectors for the include pattern only:
290+
// they are not resolvable package names, so nf3 would warn on them.
289291
const traceInclude = userTraceDeps.filter(
290-
(d): d is string => typeof d === "string" && !negated.has(d)
292+
(d): d is string =>
293+
typeof d === "string" && !negated.has(d) && !(d.startsWith("@") && !d.includes("/"))
291294
);
292295
return {
293296
includePattern: tracePattern

test/unit/trace-deps.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ describe("resolveTraceDeps", () => {
6161
expect(result.traceInclude!.every((d) => typeof d === "string")).toBe(true);
6262
});
6363

64+
it("excludes bare scopes from traceInclude but keeps them in the pattern", () => {
65+
const result = resolveTraceDeps(["@scope", "@scope/pkg"], defaults);
66+
// `@scope` is a prefix selector, not a resolvable package name
67+
expect(result.traceInclude).toEqual(["@scope/pkg"]);
68+
expect(result.includePattern!.test("/x/node_modules/@scope/other/index.js")).toBe(true);
69+
});
70+
6471
it("returns undefined traceInclude when no user deps are declared", () => {
6572
const result = resolveTraceDeps([], defaults);
6673
expect(result.traceInclude).toBeUndefined();

0 commit comments

Comments
 (0)