@ethisyscore/vite-plugin 1.67.1 → 1.68.1
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/dist/index.cjs +27 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +27 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1557,12 +1557,16 @@ function computePlatformReactPages(input) {
|
|
|
1557
1557
|
const pageRouteById = Object.fromEntries(
|
|
1558
1558
|
input.routeMeta.filter((e) => e.pageId && (e.pattern.startsWith(routePrefix) || e.pattern === routeRoot)).map((e) => [e.pageId, e.pattern === routeRoot ? "" : e.pattern.slice(routePrefix.length)])
|
|
1559
1559
|
);
|
|
1560
|
-
const useViewRe =
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1560
|
+
const useViewRe = /useView\(\s*["']([\w-]+)["']\s*,\s*["']([A-Za-z0-9_]+)["']\s*,?\s*\)/g;
|
|
1561
|
+
if (input.moduleKeys !== void 0 && input.moduleKeys.length === 0) {
|
|
1562
|
+
throw new Error(
|
|
1563
|
+
"generate-manifest: moduleKeys was supplied but empty. Omit it to default to [module], or list every module key the page definer registers views under."
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
const registeredKeys = new Set(input.moduleKeys ?? [input.module]);
|
|
1564
1567
|
const entries = [];
|
|
1565
1568
|
const missingViews = [];
|
|
1569
|
+
const unregisteredViews = [];
|
|
1566
1570
|
for (const { file, content, moduleSpecifier } of input.pages) {
|
|
1567
1571
|
const name = path.basename(file, ".tsx");
|
|
1568
1572
|
const override = input.pageOverrides?.[file] ?? {};
|
|
@@ -1570,7 +1574,13 @@ function computePlatformReactPages(input) {
|
|
|
1570
1574
|
useViewRe.lastIndex = 0;
|
|
1571
1575
|
let m;
|
|
1572
1576
|
while ((m = useViewRe.exec(content)) !== null) {
|
|
1573
|
-
const v = m
|
|
1577
|
+
const [, moduleKey, v] = m;
|
|
1578
|
+
if (!registeredKeys.has(moduleKey)) {
|
|
1579
|
+
unregisteredViews.push(
|
|
1580
|
+
`${file}: useView("${moduleKey}", "${v}") names a module key the definer does not register (registered: ${[...registeredKeys].map((k) => `"${k}"`).join(", ")}), so the lookup renders "View not available" at runtime`
|
|
1581
|
+
);
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
1574
1584
|
if (input.viewFiles[v] !== void 0) {
|
|
1575
1585
|
views[v] = input.viewFiles[v];
|
|
1576
1586
|
} else {
|
|
@@ -1588,7 +1598,7 @@ function computePlatformReactPages(input) {
|
|
|
1588
1598
|
views
|
|
1589
1599
|
});
|
|
1590
1600
|
}
|
|
1591
|
-
return { entries, missingViews };
|
|
1601
|
+
return { entries, missingViews, unregisteredViews };
|
|
1592
1602
|
}
|
|
1593
1603
|
function walk2(dir) {
|
|
1594
1604
|
const out = [];
|
|
@@ -1645,8 +1655,9 @@ function generatePlatformReactManifest(config) {
|
|
|
1645
1655
|
});
|
|
1646
1656
|
}
|
|
1647
1657
|
}
|
|
1648
|
-
const { entries, missingViews } = computePlatformReactPages({
|
|
1658
|
+
const { entries, missingViews, unregisteredViews } = computePlatformReactPages({
|
|
1649
1659
|
module,
|
|
1660
|
+
moduleKeys: config.moduleKeys,
|
|
1650
1661
|
slug,
|
|
1651
1662
|
routeMeta,
|
|
1652
1663
|
pages,
|
|
@@ -1691,13 +1702,21 @@ function generatePlatformReactManifest(config) {
|
|
|
1691
1702
|
const overlayPath = path.resolve(root, overlayRel);
|
|
1692
1703
|
fs.writeFileSync(overlayPath, JSON.stringify(overlay, null, 2) + "\n");
|
|
1693
1704
|
const pagesWithoutView = entries.filter((e) => Object.keys(e.views).length === 0).map((e) => e.id);
|
|
1694
|
-
|
|
1705
|
+
const result = {
|
|
1695
1706
|
pageCount: entries.length,
|
|
1696
1707
|
pagesWithoutView,
|
|
1697
1708
|
missingViews,
|
|
1709
|
+
unregisteredViews,
|
|
1698
1710
|
featureManifestPath,
|
|
1699
1711
|
overlayPath
|
|
1700
1712
|
};
|
|
1713
|
+
if ((config.strict ?? true) && (missingViews.length > 0 || unregisteredViews.length > 0)) {
|
|
1714
|
+
throw new Error(
|
|
1715
|
+
`generate-manifest: ${missingViews.length + unregisteredViews.length} unresolvable useView call(s). Each renders "View not available" at runtime behind a green build:
|
|
1716
|
+
` + [...unregisteredViews, ...missingViews].map((d) => ` - ${d}`).join("\n")
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
return result;
|
|
1701
1720
|
}
|
|
1702
1721
|
var DEFAULT_MANIFEST = "feature.manifest.json";
|
|
1703
1722
|
var DEFAULT_OUTPUT_DIR = "dist/iframe-sandbox";
|