@ws-test-realm/admin-kit 0.2.1-ng16 → 0.2.3-ng16
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 +22 -2
- package/lib/deploy-remotes.js +7 -4
- package/lib/generate-module.js +47 -10
- package/package.json +3 -3
- package/template/package.json +2 -2
- package/template-module/federation.config.js +12 -4
- package/template-module/ng-package.json +8 -0
- package/template-module/package.json +2 -0
- package/template-module/src/exposed-module.ts +1 -0
- package/template-module/tsconfig.lib.json +14 -0
- package/template-module/tsconfig.lib.prod.json +9 -0
package/lib/build-modules.js
CHANGED
|
@@ -39,14 +39,34 @@ function partitionByKind(workspaceDir, names) {
|
|
|
39
39
|
return { remotes, libraries };
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// For each project in topo order, run two builds when applicable:
|
|
43
|
+
// 1. build-lib (ng-packagr) — emits the typed library output at dist/<name>/
|
|
44
|
+
// 2. build (native-federation) — emits the runtime artifact at dist/<name>-remote/
|
|
45
|
+
//
|
|
46
|
+
// The lib pass must complete before any sibling's federation pass starts,
|
|
47
|
+
// because the sibling compiles against the lib's `.d.ts` files. Topo order
|
|
48
|
+
// gives us that for free at the project level; per-project we just sequence
|
|
49
|
+
// the two passes.
|
|
50
|
+
//
|
|
51
|
+
// If a project's angular.json lacks `architect.build-lib` (legacy single-build
|
|
52
|
+
// project), the lib pass is skipped silently — the federation pass alone runs.
|
|
42
53
|
function buildLibs({ workspaceDir, restrictTo = [], withDeps = false }) {
|
|
43
|
-
const { order } = loadOrder({ workspaceDir, restrictTo, withDeps });
|
|
54
|
+
const { order, angularJson } = loadOrder({ workspaceDir, restrictTo, withDeps });
|
|
44
55
|
|
|
45
56
|
console.log(`\n=== Build order ===`);
|
|
46
57
|
order.forEach((n, i) => console.log(` ${i + 1}. ${n}`));
|
|
47
58
|
|
|
48
59
|
for (const name of order) {
|
|
49
|
-
|
|
60
|
+
const architect =
|
|
61
|
+
(angularJson.projects[name] && angularJson.projects[name].architect) || {};
|
|
62
|
+
if (architect["build-lib"]) {
|
|
63
|
+
console.log(`\n=== ng run ${name}:build-lib (lib pass) ===`);
|
|
64
|
+
execSync(`npx ng run ${name}:build-lib`, {
|
|
65
|
+
cwd: workspaceDir,
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
console.log(`\n=== ng build ${name} (federation pass) ===`);
|
|
50
70
|
execSync(`npx ng build ${name}`, {
|
|
51
71
|
cwd: workspaceDir,
|
|
52
72
|
stdio: "inherit",
|
package/lib/deploy-remotes.js
CHANGED
|
@@ -7,12 +7,15 @@ const { loadDeployContext, resolveTarget } = require("./target-resolution");
|
|
|
7
7
|
const { emitDescriptor } = require("./emit-descriptor");
|
|
8
8
|
const { readIdentity } = require("./identity");
|
|
9
9
|
|
|
10
|
-
// Resolve the
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
10
|
+
// Resolve the federation-pass output for a remote. Under the dual-build
|
|
11
|
+
// convention `dist/<id>-remote/` is the canonical output (kept separate from
|
|
12
|
+
// the lib pass at `dist/<id>/` so ng-packagr's typed output doesn't collide
|
|
13
|
+
// with the bundler's). Older single-build configurations wrote to
|
|
14
|
+
// `dist/<id>/browser/` (application builder) or `dist/<id>/` (browser-esbuild
|
|
15
|
+
// with no nested `browser/`); kept as fallbacks for back-compat.
|
|
14
16
|
function resolveBuildOutput(workspaceDir, id) {
|
|
15
17
|
const candidates = [
|
|
18
|
+
path.join(workspaceDir, "dist", `${id}-remote`),
|
|
16
19
|
path.join(workspaceDir, "dist", id, "browser"),
|
|
17
20
|
path.join(workspaceDir, "dist", id),
|
|
18
21
|
];
|
package/lib/generate-module.js
CHANGED
|
@@ -51,11 +51,26 @@ function copyAndSubstitute(src, dest, tokens) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// Register the project as a
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
54
|
+
// Register the project as a dual-build admin module in angular.json. Three
|
|
55
|
+
// architect targets per project:
|
|
56
|
+
//
|
|
57
|
+
// build-lib → @angular-devkit/build-angular:ng-packagr. Produces the typed
|
|
58
|
+
// library at dist/<name>/ (with .d.ts + package.json + fesm2015).
|
|
59
|
+
// Consumed at COMPILE time by sibling projects in this workspace
|
|
60
|
+
// (and by the host) via tsconfig.federation.json `paths`.
|
|
61
|
+
//
|
|
62
|
+
// build → @angular-architects/native-federation:build. Wraps the
|
|
63
|
+
// `esbuild` target and emits remoteEntry.json + chunks at
|
|
64
|
+
// dist/<name>-remote/. Deployed to the fiddle; consumed at
|
|
65
|
+
// RUNTIME via the host's initFederation + import map.
|
|
66
|
+
//
|
|
67
|
+
// esbuild → @angular-devkit/build-angular:browser-esbuild. The bundle
|
|
68
|
+
// target the native-federation builder wraps. Output dir
|
|
69
|
+
// dist/<name>-remote/ keeps it separate from the lib output.
|
|
70
|
+
//
|
|
71
|
+
// Every module is dual-build by default — any project could grow a type-level
|
|
72
|
+
// consumer (pluggable slots, base components), and the dual invariant
|
|
73
|
+
// guarantees the typed surface is always there.
|
|
59
74
|
function registerInAngularJson(workspaceDir, name) {
|
|
60
75
|
const angularJsonPath = path.join(workspaceDir, "angular.json");
|
|
61
76
|
const angular = JSON.parse(fs.readFileSync(angularJsonPath, "utf8"));
|
|
@@ -67,20 +82,42 @@ function registerInAngularJson(workspaceDir, name) {
|
|
|
67
82
|
sourceRoot: `projects/${name}/src`,
|
|
68
83
|
prefix: "ws",
|
|
69
84
|
architect: {
|
|
85
|
+
"build-lib": {
|
|
86
|
+
builder: "@angular-devkit/build-angular:ng-packagr",
|
|
87
|
+
options: { project: `projects/${name}/ng-package.json` },
|
|
88
|
+
configurations: {
|
|
89
|
+
production: {
|
|
90
|
+
tsConfig: `projects/${name}/tsconfig.lib.prod.json`,
|
|
91
|
+
},
|
|
92
|
+
development: { tsConfig: `projects/${name}/tsconfig.lib.json` },
|
|
93
|
+
},
|
|
94
|
+
defaultConfiguration: "production",
|
|
95
|
+
},
|
|
70
96
|
build: {
|
|
71
97
|
builder: "@angular-architects/native-federation:build",
|
|
72
98
|
options: { target: `${name}:esbuild` },
|
|
99
|
+
configurations: {
|
|
100
|
+
production: { target: `${name}:esbuild:production` },
|
|
101
|
+
development: { target: `${name}:esbuild:development` },
|
|
102
|
+
},
|
|
103
|
+
defaultConfiguration: "production",
|
|
73
104
|
},
|
|
74
105
|
esbuild: {
|
|
75
|
-
builder: "@angular-devkit/build-angular:
|
|
106
|
+
builder: "@angular-devkit/build-angular:browser-esbuild",
|
|
76
107
|
options: {
|
|
77
|
-
outputPath: `dist/${name}`,
|
|
108
|
+
outputPath: `dist/${name}-remote`,
|
|
78
109
|
index: `projects/${name}/src/index.html`,
|
|
79
|
-
|
|
80
|
-
polyfills: [
|
|
110
|
+
main: `projects/${name}/src/main.ts`,
|
|
111
|
+
polyfills: [],
|
|
81
112
|
tsConfig: `projects/${name}/tsconfig.app.json`,
|
|
82
|
-
|
|
113
|
+
styles: [],
|
|
114
|
+
scripts: [],
|
|
115
|
+
},
|
|
116
|
+
configurations: {
|
|
117
|
+
production: { optimization: true, sourceMap: false },
|
|
118
|
+
development: { optimization: false, sourceMap: true },
|
|
83
119
|
},
|
|
120
|
+
defaultConfiguration: "production",
|
|
84
121
|
},
|
|
85
122
|
},
|
|
86
123
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ws-test-realm/admin-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3-ng16",
|
|
4
4
|
"description": "Workflow CLI + scaffolding for Wiresphere admin-modules workspaces (Angular 16 + 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": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@angular-architects/native-federation": "^16.0.0",
|
|
29
|
-
"@ws-test-realm/devkit": "
|
|
30
|
-
"@ws-test-realm/shared": "
|
|
29
|
+
"@ws-test-realm/devkit": "^0.4.0-ng16",
|
|
30
|
+
"@ws-test-realm/shared": "^0.4.1-ng16",
|
|
31
31
|
"adm-zip": "^0.5.10",
|
|
32
32
|
"fast-xml-parser": "^4.3.0"
|
|
33
33
|
}
|
package/template/package.json
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"prettier": "@ws-test-realm/devkit/prettier.config.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ws-test-realm/shared": "^0.4.
|
|
20
|
+
"@ws-test-realm/shared": "^0.4.1-ng16",
|
|
21
21
|
"@ws-test-realm/ws-core": "^0.1.0-ng16"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@ws-test-realm/admin-kit": "^0.2.
|
|
24
|
+
"@ws-test-realm/admin-kit": "^0.2.3-ng16",
|
|
25
25
|
"@ws-test-realm/devkit": "^0.4.0-ng16"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
const { withNativeFederation } = require('@angular-architects/native-federation/config');
|
|
2
|
-
const { sharedDescriptors } = require('@ws-test-realm/shared');
|
|
1
|
+
const { withNativeFederation, share } = require('@angular-architects/native-federation/config');
|
|
2
|
+
const { sharedDescriptors, WORKSPACE_LIBS } = require('@ws-test-realm/shared');
|
|
3
3
|
|
|
4
4
|
module.exports = withNativeFederation({
|
|
5
5
|
name: '__camelName__Module',
|
|
6
6
|
exposes: {
|
|
7
|
-
|
|
7
|
+
// 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.
|
|
11
|
+
'./Module': './src/exposed-module.ts',
|
|
8
12
|
},
|
|
9
|
-
|
|
13
|
+
// share() expands includeSecondaries against each package's exports field.
|
|
14
|
+
// withNativeFederation's own share() invocation is commented out upstream.
|
|
15
|
+
// Self-share this package so siblings consuming it via bare specifiers
|
|
16
|
+
// resolve to the same singleton chunk at runtime.
|
|
17
|
+
shared: { ...share(sharedDescriptors()), __name__: WORKSPACE_LIBS },
|
|
10
18
|
skip: ['rxjs/ajax', 'rxjs/fetch', 'rxjs/testing', 'rxjs/webSocket'],
|
|
11
19
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '__name__';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/lib",
|
|
5
|
+
"target": "es2022",
|
|
6
|
+
"useDefineForClassFields": false,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"types": [],
|
|
11
|
+
"lib": ["dom", "es2022"]
|
|
12
|
+
},
|
|
13
|
+
"exclude": ["src/test.ts", "**/*.spec.ts"]
|
|
14
|
+
}
|