@ws-test-realm/admin-kit 0.6.7-ng20 → 0.6.8-ng20
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/lib/build-modules.js +11 -0
- package/lib/patch-remote-entry.js +71 -0
- package/package.json +1 -1
package/lib/build-modules.js
CHANGED
|
@@ -2,6 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
4
|
const { buildDependencyGraph, topologicalSort } = require("./topo-sort");
|
|
5
|
+
const { patchRemoteEntryExpects } = require("./patch-remote-entry");
|
|
5
6
|
|
|
6
7
|
function loadOrder({ workspaceDir, restrictTo, withDeps = false }) {
|
|
7
8
|
const angularJsonPath = path.join(workspaceDir, "angular.json");
|
|
@@ -85,6 +86,16 @@ function buildLibs({ workspaceDir, restrictTo = [], withDeps = false }) {
|
|
|
85
86
|
cwd: workspaceDir,
|
|
86
87
|
stdio: "inherit",
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
// Federation wrapper Step 1: augment remoteEntry.json with `expects`.
|
|
91
|
+
// No-op (returns null) for library-kind projects with no federation
|
|
92
|
+
// artifact emitted.
|
|
93
|
+
const patched = patchRemoteEntryExpects({ workspaceDir, id: name });
|
|
94
|
+
if (patched) {
|
|
95
|
+
console.log(
|
|
96
|
+
` expects: ${patched.count} entries → ${path.relative(workspaceDir, patched.entryPath)}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
console.log(`\nBuilt ${order.length} project(s).`);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
// Augment a project's emitted remoteEntry.json with the `expects` field —
|
|
5
|
+
// the set of bare-specifier imports this remote consumes from other
|
|
6
|
+
// federation members (BOM packages, sibling remotes, contribution-owners).
|
|
7
|
+
// Source of truth: the project's federation.config.js#externals array.
|
|
8
|
+
//
|
|
9
|
+
// Step 1 of the federation wrapper. Native-federation's runtime puts each
|
|
10
|
+
// remote's shares into per-remote scopes keyed by base URL — only the host
|
|
11
|
+
// can put shares into root imports. A consumer remote can't resolve a
|
|
12
|
+
// sibling remote's contribution unless the host knows about it at build
|
|
13
|
+
// time. The wrapper closes the gap by reading every remote's `expects` at
|
|
14
|
+
// boot, building a topology, and synthesizing root-level import-map
|
|
15
|
+
// entries (steps 2 + 3). This step just emits the data.
|
|
16
|
+
//
|
|
17
|
+
// Called from the --build per-project loop right after the
|
|
18
|
+
// native-federation `ng build <name>` step writes
|
|
19
|
+
// `dist/<name>-remote/remoteEntry.json`, before pack/deploy copy it
|
|
20
|
+
// elsewhere.
|
|
21
|
+
function patchRemoteEntryExpects({ workspaceDir, id }) {
|
|
22
|
+
const cfgPath = path.join(
|
|
23
|
+
workspaceDir,
|
|
24
|
+
"projects",
|
|
25
|
+
id,
|
|
26
|
+
"federation.config.js"
|
|
27
|
+
);
|
|
28
|
+
if (!fs.existsSync(cfgPath)) return null;
|
|
29
|
+
|
|
30
|
+
// require() the federation config to get the normalized config object
|
|
31
|
+
// (output of withNativeFederation). `externals` is on it as an array.
|
|
32
|
+
// Clear the require cache so re-invocations during dev rebuilds pick up
|
|
33
|
+
// edits made to the federation.config since the last build.
|
|
34
|
+
delete require.cache[require.resolve(cfgPath)];
|
|
35
|
+
let cfg;
|
|
36
|
+
try {
|
|
37
|
+
cfg = require(cfgPath);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.warn(
|
|
40
|
+
` [warn] could not require ${path.relative(workspaceDir, cfgPath)}: ${e.message}`
|
|
41
|
+
);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const expects = Array.isArray(cfg.externals) ? [...cfg.externals] : [];
|
|
45
|
+
|
|
46
|
+
// Canonical output location under our dual-build convention.
|
|
47
|
+
const primary = path.join(
|
|
48
|
+
workspaceDir,
|
|
49
|
+
"dist",
|
|
50
|
+
`${id}-remote`,
|
|
51
|
+
"remoteEntry.json"
|
|
52
|
+
);
|
|
53
|
+
if (fs.existsSync(primary)) return patchAt(primary, expects);
|
|
54
|
+
|
|
55
|
+
// Legacy single-build fallbacks (browser-esbuild without nested 'browser/').
|
|
56
|
+
const fallback1 = path.join(workspaceDir, "dist", id, "browser", "remoteEntry.json");
|
|
57
|
+
if (fs.existsSync(fallback1)) return patchAt(fallback1, expects);
|
|
58
|
+
const fallback2 = path.join(workspaceDir, "dist", id, "remoteEntry.json");
|
|
59
|
+
if (fs.existsSync(fallback2)) return patchAt(fallback2, expects);
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function patchAt(entryPath, expects) {
|
|
65
|
+
const entry = JSON.parse(fs.readFileSync(entryPath, "utf8"));
|
|
66
|
+
entry.expects = expects;
|
|
67
|
+
fs.writeFileSync(entryPath, JSON.stringify(entry, null, 2));
|
|
68
|
+
return { entryPath, count: expects.length };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { patchRemoteEntryExpects };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ws-test-realm/admin-kit",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8-ng20",
|
|
4
4
|
"description": "Workflow CLI + scaffolding for Wiresphere admin-modules workspaces (Angular 20 + native-federation line). Ships `ws-init-workspace`, `ws-modules` (build+deploy driver), `ws-generate-module`/`ws-drop-module`, `ws-wire-host`, `ws-wire-pom`, `ws-sync-paths`, and `ws-purge`. Depends on @ws-test-realm/devkit (toolchain BOM) + @ws-test-realm/shared (runtime BOM + native-federation share map).",
|
|
5
5
|
"license": "Artistic-2.0",
|
|
6
6
|
"publishConfig": {
|