@ws-test-realm/admin-kit 0.6.5-ng20 → 0.6.7-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.
@@ -72,6 +72,50 @@ function deployExt({ workspaceDir, id, modulesDir, extDir, stagedDir }) {
72
72
  return { extDir, copiedFiles: fileCount };
73
73
  }
74
74
 
75
+ // Publish the LIB output (`dist/<id>/`) to the fiddle's
76
+ // `<adminDir>/.federation/<id>/`. Cross-workspace consumers' ng-packagr
77
+ // reads this directory (via the symlink `node_modules/<id>` → here) to
78
+ // resolve TypeScript imports. Without an up-to-date publish, consumers
79
+ // compile against stale typings — references to renamed/removed classes
80
+ // silently resolve against the old names, baking obsolete identifiers
81
+ // into the consumer's fesm. At runtime the consumer's chunk then imports
82
+ // a name the deployed remote no longer exports → `undefined.ɵcmp`.
83
+ //
84
+ // Both jar and ext targets need this. (The jar's META-INF/federation/<id>/
85
+ // only carries the RUNTIME bundle, not the LIB output.)
86
+ //
87
+ // Idempotent: wipes the destination first so removed files (e.g. classes
88
+ // renamed out of existence) don't linger.
89
+ function publishLibTypings({ workspaceDir, id, adminDir }) {
90
+ if (!adminDir) return null;
91
+ const libDir = path.join(workspaceDir, "dist", id);
92
+ if (!fs.existsSync(libDir)) return null;
93
+ // Only publish if it looks like an ng-packagr lib output (has package.json
94
+ // + index.d.ts). Skip otherwise to avoid clobbering with a weird tree.
95
+ if (
96
+ !fs.existsSync(path.join(libDir, "package.json")) ||
97
+ !fs.existsSync(path.join(libDir, "index.d.ts"))
98
+ ) {
99
+ return null;
100
+ }
101
+ const federationDir = path.join(adminDir, ".federation", id);
102
+ if (fs.existsSync(federationDir)) {
103
+ fs.rmSync(federationDir, { recursive: true, force: true });
104
+ }
105
+ fs.mkdirSync(federationDir, { recursive: true });
106
+ fs.cpSync(libDir, federationDir, { recursive: true });
107
+ let fileCount = 0;
108
+ const walk = (d) => {
109
+ for (const e of fs.readdirSync(d, { withFileTypes: true })) {
110
+ const p = path.join(d, e.name);
111
+ if (e.isDirectory()) walk(p);
112
+ else fileCount += 1;
113
+ }
114
+ };
115
+ walk(federationDir);
116
+ return { federationDir, fileCount };
117
+ }
118
+
75
119
  function deployOne({
76
120
  workspaceDir,
77
121
  id,
@@ -97,6 +141,8 @@ function deployOne({
97
141
  modulesFolder,
98
142
  });
99
143
 
144
+ const typings = publishLibTypings({ workspaceDir, id, adminDir });
145
+
100
146
  if (target.kind === "jar") {
101
147
  const packResult = packIntoJar({
102
148
  jarPath: target.jarPath,
@@ -108,6 +154,7 @@ function deployOne({
108
154
  jarPath: target.jarPath,
109
155
  pomPath: target.pomPath,
110
156
  artifactId: target.artifactId,
157
+ typings,
111
158
  ...packResult,
112
159
  };
113
160
  }
@@ -119,7 +166,7 @@ function deployOne({
119
166
  extDir: target.extDir,
120
167
  stagedDir,
121
168
  });
122
- return { kind: "ext", ...extResult };
169
+ return { kind: "ext", typings, ...extResult };
123
170
  }
124
171
 
125
172
  function deployRemotes({ workspaceDir, restrictTo = [], withDeps = false }) {
@@ -164,6 +211,9 @@ function deployRemotes({ workspaceDir, restrictTo = [], withDeps = false }) {
164
211
  console.log(` ext dir: ${r.extDir}`);
165
212
  console.log(` copied files: ${r.copiedFiles}`);
166
213
  }
214
+ if (r.typings) {
215
+ console.log(` typings: ${r.typings.federationDir} (${r.typings.fileCount} files)`);
216
+ }
167
217
  results.push({ id, ...r });
168
218
  }
169
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ws-test-realm/admin-kit",
3
- "version": "0.6.5-ng20",
3
+ "version": "0.6.7-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": {
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@angular-architects/native-federation": "^20.0.0",
30
30
  "@ws-test-realm/devkit": "^0.8.0-ng20",
31
- "@ws-test-realm/shared": "^0.8.1-ng20",
31
+ "@ws-test-realm/shared": "^0.8.2-ng20",
32
32
  "adm-zip": "^0.5.10",
33
33
  "fast-xml-parser": "^4.3.0"
34
34
  }
@@ -1,37 +1,39 @@
1
1
  const { withNativeFederation, share } = require('@angular-architects/native-federation/config');
2
- const { sharedDescriptors, WORKSPACE_LIBS } = require('@ws-test-realm/shared');
2
+ const { remoteShared, remoteExternals } = require('@ws-test-realm/shared');
3
+
4
+ // Consume-only federation. A new module bundles ONLY its own code by
5
+ // default. Everything else (BOM @angular/* etc., sibling remotes,
6
+ // contribution-owners' packages like tinymce or angular-jwt) is
7
+ // externalized — esbuild emits bare imports; the runtime federation
8
+ // import map (populated by host's initFederation before any module
9
+ // evaluates) resolves to the singleton chunk provided by host /
10
+ // contribution-owner. Missing share at runtime crashes explicitly.
11
+ // See PINNED.md "no module duplication".
12
+ //
13
+ // If THIS module brings in a peer dep that no other remote provides
14
+ // (e.g. db-login owns `@auth0/angular-jwt`), add it to `own` so this
15
+ // module becomes the contribution-owner — it gets bundled here and
16
+ // listed in remoteEntry.json as a share, then other remotes can
17
+ // externalize it.
18
+ const OWN = []; // e.g. ['@some/special-dep']
3
19
 
4
20
  module.exports = withNativeFederation({
5
21
  name: '__camelName__Module',
6
22
  exposes: {
7
23
  // Thin re-export shim so the exposed chunk delegates to the singleton
8
- // shared chunk for this package (declared in `shared` below). Without
9
- // the shim, esbuild would inline the whole library here and decorator
10
- // side effects would fire a second time on remote load.
24
+ // shared chunk for this package. Without the shim, esbuild would
25
+ // inline the whole library here and decorator side effects would
26
+ // fire a second time on remote load.
11
27
  './Module': './projects/__name__/src/exposed-module.ts',
12
28
  },
13
- // share() expands includeSecondaries against each package's exports field.
14
- // withNativeFederation's own share() invocation is commented out upstream.
15
- //
16
- // Three flavors of entries below the share() spread:
17
- //
18
- // 1. Self-share `'__name__': WORKSPACE_LIBS` — emits a chunk + import-map
19
- // entry for THIS module so siblings consuming it via bare specifiers
20
- // get the same instance at runtime.
21
- //
22
- // 2. Cross-workspace siblings (e.g. `'ws-framework': WORKSPACE_LIBS`) —
23
- // add when this module imports from another admin module that lives
24
- // in a different workspace. admin-kit symlinks `node_modules/<name>`
25
- // to the fiddle's `.federation/<name>/` so esbuild can resolve.
26
- //
27
- // 3. Module-carried federation contributions — runtime libs THIS module
28
- // introduces for the federation, that aren't in `sharedDescriptors()`'s
29
- // default slice. Example: db-login carries `@auth0/angular-jwt`. The
30
- // module's project package.json should list these as
31
- // `peerDependencies` (not `dependencies`); ng-packagr leaves them as
32
- // bare imports, native-federation emits the chunk + share entry, and
33
- // the runtime singleton mechanism dedupes if other consumers ever
34
- // import them.
35
- shared: { ...share(sharedDescriptors()), '__name__': WORKSPACE_LIBS },
36
- skip: ['rxjs/ajax', 'rxjs/fetch', 'rxjs/testing', 'rxjs/webSocket'],
29
+ shared: share(remoteShared({ self: '__name__', own: OWN })),
30
+ externals: remoteExternals({ self: '__name__', own: OWN }),
31
+ skip: [
32
+ 'rxjs/ajax',
33
+ 'rxjs/fetch',
34
+ 'rxjs/testing',
35
+ 'rxjs/webSocket',
36
+ '@angular/cdk/testing',
37
+ '@angular/material/testing',
38
+ ],
37
39
  });