@opentf/afw-cli 1.31.0 → 1.32.0
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/package.json +1 -1
- package/src/shared.js +23 -6
package/package.json
CHANGED
package/src/shared.js
CHANGED
|
@@ -368,6 +368,26 @@ export async function runLlmsFiles(root, appDir, pages, config, siteDir, baseUrl
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Resolve-aliases pinning every `@opentf/afw` import of a server bundle to the package
|
|
373
|
+
* beside `afwEntry` (its `index.js`), one entry per subpath in the package's `exports`.
|
|
374
|
+
* An alias also covers the subpaths under its key, so a lone `"@opentf/afw": index.js`
|
|
375
|
+
* turned the compiler's `@opentf/afw/signals` import into `index.js/signals`. Longer keys
|
|
376
|
+
* come first; types-only exports (`./jsx-runtime`) have no runtime file to alias.
|
|
377
|
+
*/
|
|
378
|
+
export async function afwAliases(afwEntry) {
|
|
379
|
+
const dir = dirname(afwEntry);
|
|
380
|
+
const { exports = {} } = JSON.parse(await readText(join(dir, "package.json")));
|
|
381
|
+
const aliases = {};
|
|
382
|
+
for (const [key, target] of Object.entries(exports).sort((a, b) => b[0].length - a[0].length)) {
|
|
383
|
+
if (key === "." || !key.startsWith("./")) continue;
|
|
384
|
+
const file = typeof target === "string" ? target : target?.default ?? target?.import;
|
|
385
|
+
if (typeof file === "string" && !file.endsWith(".d.ts")) aliases[`@opentf/afw/${key.slice(2)}`] = join(dir, file);
|
|
386
|
+
}
|
|
387
|
+
aliases["@opentf/afw"] = afwEntry;
|
|
388
|
+
return aliases;
|
|
389
|
+
}
|
|
390
|
+
|
|
371
391
|
/**
|
|
372
392
|
* Discover file-based routes under `app/`: every page/layout and the 404. This list is
|
|
373
393
|
* what gets prerendered, so drafts and scheduled Markdown pages (`isUnpublishedPage`)
|
|
@@ -584,12 +604,11 @@ export async function emitApiBundle({ root, appDir, afwEntry, exclude, i18n, out
|
|
|
584
604
|
const entry = join(tmp, "api-entry.js");
|
|
585
605
|
await writeFile(entry, apiEntrySource(discovered, appDir, i18n));
|
|
586
606
|
|
|
587
|
-
const serverApi = join(dirname(afwEntry), "server", "index.js");
|
|
588
607
|
await mkdirp(outDir);
|
|
589
608
|
const bundle = await build({
|
|
590
609
|
input: entry,
|
|
591
610
|
platform: "node",
|
|
592
|
-
resolve: { alias:
|
|
611
|
+
resolve: { alias: await afwAliases(afwEntry), extensions: EXTENSIONS },
|
|
593
612
|
external: (id) => !id.startsWith(".") && !id.startsWith("/") && !id.startsWith("@opentf/afw"),
|
|
594
613
|
});
|
|
595
614
|
try {
|
|
@@ -636,12 +655,11 @@ export async function emitLoaderBundle({ root, appDir, afwEntry, exclude, i18n,
|
|
|
636
655
|
const entry = join(tmp, "loaders-entry.js");
|
|
637
656
|
await writeFile(entry, loaderEntrySource(files, appDir, i18n));
|
|
638
657
|
|
|
639
|
-
const serverApi = join(dirname(afwEntry), "server", "index.js");
|
|
640
658
|
await mkdirp(outDir);
|
|
641
659
|
const bundle = await build({
|
|
642
660
|
input: entry,
|
|
643
661
|
platform: "node",
|
|
644
|
-
resolve: { alias:
|
|
662
|
+
resolve: { alias: await afwAliases(afwEntry), extensions: EXTENSIONS },
|
|
645
663
|
external: (id) => !id.startsWith(".") && !id.startsWith("/") && !id.startsWith("@opentf/afw"),
|
|
646
664
|
});
|
|
647
665
|
try {
|
|
@@ -727,11 +745,10 @@ export async function buildServerBundle({
|
|
|
727
745
|
const entry = join(tmp, "ssg-entry.js");
|
|
728
746
|
await writeFile(entry, serverEntrySource(pages, i18n));
|
|
729
747
|
|
|
730
|
-
const serverApi = join(dirname(afwEntry), "server", "index.js");
|
|
731
748
|
const bundle = await build({
|
|
732
749
|
input: entry,
|
|
733
750
|
resolve: {
|
|
734
|
-
alias:
|
|
751
|
+
alias: await afwAliases(afwEntry),
|
|
735
752
|
extensions: EXTENSIONS,
|
|
736
753
|
},
|
|
737
754
|
// The runtime guards its dev diagnostics on `process.env.NODE_ENV`, and there is
|