@cubing/dev-config 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/package.json.ts +44 -1
- package/package.json +1 -1
package/bin/package.json.ts
CHANGED
|
@@ -526,6 +526,7 @@ if (packageJSON.exports) {
|
|
|
526
526
|
// biome-ignore lint/complexity/noUselessContinue: Explicit control flow.
|
|
527
527
|
continue;
|
|
528
528
|
} else if (typeof value === "string") {
|
|
529
|
+
// TODO: error?
|
|
529
530
|
checkPath(["exports", [exportPath]], {
|
|
530
531
|
expectPrefix: ResolutionPrefix.Relative,
|
|
531
532
|
});
|
|
@@ -537,7 +538,49 @@ if (packageJSON.exports) {
|
|
|
537
538
|
"❌ .exports — Must use an object (instead of an array).",
|
|
538
539
|
);
|
|
539
540
|
} else {
|
|
540
|
-
|
|
541
|
+
const keys = Object.keys(value as Record<string, string>);
|
|
542
|
+
|
|
543
|
+
checks.push(
|
|
544
|
+
(async () => {
|
|
545
|
+
const { breadcrumbString } = traverse(["exports", [exportPath]]);
|
|
546
|
+
const orderingErrorLines = [];
|
|
547
|
+
/**
|
|
548
|
+
* https://nodejs.org/api/packages.html#conditional-exports
|
|
549
|
+
*/
|
|
550
|
+
if (keys.includes("types")) {
|
|
551
|
+
if (keys[0] !== "types") {
|
|
552
|
+
orderingErrorLines.push(
|
|
553
|
+
` ↪ "types" must be the first export if present.`,
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (keys.includes("default")) {
|
|
558
|
+
if (keys.at(-1) !== "default") {
|
|
559
|
+
orderingErrorLines.push(
|
|
560
|
+
` ↪ "default" must be the last export if present.`,
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
for (const key of keys) {
|
|
565
|
+
// Note `"require"` is *emphatically not allowed*.
|
|
566
|
+
if (!["types", "import", "default"].includes(key)) {
|
|
567
|
+
orderingErrorLines.push(
|
|
568
|
+
` ↪ Key must not be present: ${JSON.stringify(key)}`,
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (orderingErrorLines) {
|
|
573
|
+
exitCode = 0;
|
|
574
|
+
return [
|
|
575
|
+
`❌ ${breadcrumbString} — Invalid keys:`,
|
|
576
|
+
...orderingErrorLines,
|
|
577
|
+
].join("\n");
|
|
578
|
+
} else {
|
|
579
|
+
return `✅ ${breadcrumbString} — Key set and ordering is okay..`;
|
|
580
|
+
}
|
|
581
|
+
})(),
|
|
582
|
+
);
|
|
583
|
+
for (const secondaryKey of keys) {
|
|
541
584
|
checkPath(["exports", [exportPath], secondaryKey], {
|
|
542
585
|
expectPrefix: ResolutionPrefix.Relative,
|
|
543
586
|
});
|