Support repository-root WebUI packages
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
# WebUI Module Package Layout
|
||||||
|
|
||||||
|
Core discovers a module contribution from `src/module.ts` when `node_modules`
|
||||||
|
links directly to a module's `webui` package. Tagged release dependencies are
|
||||||
|
installed from repository-root packages and expose the same contribution at
|
||||||
|
`webui/src/module.ts`. The Vite registry accepts both layouts and imports the
|
||||||
|
contribution descriptor directly so route-level lazy loading is preserved.
|
||||||
|
|
||||||
|
A release package is invalid if neither entry exists. The module-permutation CI
|
||||||
|
matrix builds source-linked and installed release compositions; it must not fall
|
||||||
|
back to a package root barrel because that would eagerly pull module pages into
|
||||||
|
the shell bundle.
|
||||||
+16
-3
@@ -75,6 +75,17 @@ function availableWebModuleSpecifiers(): string[] {
|
|||||||
return configuredWebModulePackages().filter(packageInstalled);
|
return configuredWebModulePackages().filter(packageInstalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function webModuleEntry(specifier: string): string | null {
|
||||||
|
const root = packageDirectory(specifier);
|
||||||
|
for (const candidate of [
|
||||||
|
join(root, "src", "module.ts"),
|
||||||
|
join(root, "webui", "src", "module.ts")
|
||||||
|
]) {
|
||||||
|
if (existsSync(candidate)) return candidate;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function deferredVendorChunk(id: string): string | undefined {
|
function deferredVendorChunk(id: string): string | undefined {
|
||||||
const normalized = id.replaceAll("\\", "/");
|
const normalized = id.replaceAll("\\", "/");
|
||||||
if (!normalized.includes("/node_modules/")) return undefined;
|
if (!normalized.includes("/node_modules/")) return undefined;
|
||||||
@@ -167,9 +178,11 @@ function govoplanInstalledModulesPlugin(): Plugin {
|
|||||||
const publicVirtualId = id.slice(1);
|
const publicVirtualId = id.slice(1);
|
||||||
const specifier = specifierByModuleVirtualId.get(publicVirtualId);
|
const specifier = specifierByModuleVirtualId.get(publicVirtualId);
|
||||||
if (!specifier) return null;
|
if (!specifier) return null;
|
||||||
const moduleEntry = join(packageDirectory(specifier), "src", "module.ts");
|
const moduleEntry = webModuleEntry(specifier);
|
||||||
if (!existsSync(moduleEntry)) {
|
if (!moduleEntry) {
|
||||||
throw new Error(`${specifier} does not expose src/module.ts`);
|
throw new Error(
|
||||||
|
`${specifier} does not expose src/module.ts or webui/src/module.ts`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Import the contribution descriptor directly. Package root barrels may
|
// Import the contribution descriptor directly. Package root barrels may
|
||||||
// intentionally re-export pages and would otherwise defeat route splitting.
|
// intentionally re-export pages and would otherwise defeat route splitting.
|
||||||
|
|||||||
Reference in New Issue
Block a user