Skip to content

Commit 985c00f

Browse files
committed
Sort proxy directories
1 parent eae544d commit 985c00f

File tree

2 files changed

+240
-233
lines changed

2 files changed

+240
-233
lines changed

packages/core/src/checkPackage.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,20 @@ function getEntrypoints(fs: Package, exportsObject: any, options: CheckPackageOp
5757
return options.entrypoints.map((e) => formatEntrypointString(e, fs.packageName));
5858
}
5959
if (exportsObject === undefined && fs) {
60-
return getProxyDirectories(`/node_modules/${fs.packageName}`, fs);
60+
const proxies = getProxyDirectories(`/node_modules/${fs.packageName}`, fs);
61+
if (proxies.length === 0) {
62+
return ["."];
63+
}
64+
return proxies;
6165
}
6266
const detectedSubpaths = getSubpaths(exportsObject);
6367
if (detectedSubpaths.length === 0) {
6468
detectedSubpaths.push(".");
6569
}
66-
const included = Array.from(
67-
new Set([
68-
...detectedSubpaths,
69-
...(options?.includeEntrypoints?.map((e) => formatEntrypointString(e, fs.packageName)) ?? []),
70-
])
71-
);
70+
const included = unique([
71+
...detectedSubpaths,
72+
...(options?.includeEntrypoints?.map((e) => formatEntrypointString(e, fs.packageName)) ?? []),
73+
]);
7274
if (!options?.excludeEntrypoints) {
7375
return included;
7476
}
@@ -118,7 +120,8 @@ function getProxyDirectories(rootDir: string, fs: Package) {
118120
}
119121
})
120122
.map((f) => "." + f.slice(rootDir.length).slice(0, -`/package.json`.length))
121-
.filter((f) => f !== "./");
123+
.filter((f) => f !== "./")
124+
.sort();
122125
}
123126

124127
function getEntrypointInfo(
@@ -200,3 +203,7 @@ function getEntrypointResolution(
200203
};
201204
}
202205
}
206+
207+
function unique<T>(array: readonly T[]): T[] {
208+
return array.filter((value, index) => array.indexOf(value) === index);
209+
}

0 commit comments

Comments
 (0)