module-federation-angular-adapter 0.2200.0

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.
Files changed (144) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +115 -0
  3. package/builders.json +15 -0
  4. package/collection.json +27 -0
  5. package/generators.json +12 -0
  6. package/migration-collection.json +6 -0
  7. package/package.json +69 -0
  8. package/src/builders/build/builder.d.ts +7 -0
  9. package/src/builders/build/builder.d.ts.map +1 -0
  10. package/src/builders/build/builder.js +413 -0
  11. package/src/builders/build/federation-build-notifier.d.ts +70 -0
  12. package/src/builders/build/federation-build-notifier.d.ts.map +1 -0
  13. package/src/builders/build/federation-build-notifier.js +186 -0
  14. package/src/builders/build/get-externals.d.ts +18 -0
  15. package/src/builders/build/get-externals.d.ts.map +1 -0
  16. package/src/builders/build/get-externals.js +19 -0
  17. package/src/builders/build/i18n.d.ts +21 -0
  18. package/src/builders/build/i18n.d.ts.map +1 -0
  19. package/src/builders/build/i18n.js +73 -0
  20. package/src/builders/build/schema.d.ts +35 -0
  21. package/src/builders/build/schema.json +93 -0
  22. package/src/builders/build/setup-builder-env-variables.d.ts +1 -0
  23. package/src/builders/build/setup-builder-env-variables.d.ts.map +1 -0
  24. package/src/builders/build/setup-builder-env-variables.js +9 -0
  25. package/src/builders/build/update-index-html.d.ts +5 -0
  26. package/src/builders/build/update-index-html.d.ts.map +1 -0
  27. package/src/builders/build/update-index-html.js +33 -0
  28. package/src/builders/remote/assets.d.ts +14 -0
  29. package/src/builders/remote/assets.d.ts.map +1 -0
  30. package/src/builders/remote/assets.js +49 -0
  31. package/src/builders/remote/builder.d.ts +13 -0
  32. package/src/builders/remote/builder.d.ts.map +1 -0
  33. package/src/builders/remote/builder.js +153 -0
  34. package/src/builders/remote/change-watcher.d.ts +10 -0
  35. package/src/builders/remote/change-watcher.d.ts.map +1 -0
  36. package/src/builders/remote/change-watcher.js +35 -0
  37. package/src/builders/remote/infer-config-path.d.ts +2 -0
  38. package/src/builders/remote/infer-config-path.d.ts.map +1 -0
  39. package/src/builders/remote/infer-config-path.js +10 -0
  40. package/src/builders/remote/resolve-ng-options.d.ts +24 -0
  41. package/src/builders/remote/resolve-ng-options.d.ts.map +1 -0
  42. package/src/builders/remote/resolve-ng-options.js +28 -0
  43. package/src/builders/remote/schema.d.ts +26 -0
  44. package/src/builders/remote/schema.json +116 -0
  45. package/src/config/angular-locales.d.ts +6 -0
  46. package/src/config/angular-locales.d.ts.map +1 -0
  47. package/src/config/angular-locales.js +23 -0
  48. package/src/config/angular-skip-list.d.ts +3 -0
  49. package/src/config/angular-skip-list.d.ts.map +1 -0
  50. package/src/config/angular-skip-list.js +23 -0
  51. package/src/config/with-module-federation.d.ts +72 -0
  52. package/src/config/with-module-federation.d.ts.map +1 -0
  53. package/src/config/with-module-federation.js +72 -0
  54. package/src/config.d.ts +4 -0
  55. package/src/config.d.ts.map +1 -0
  56. package/src/config.js +3 -0
  57. package/src/generators/native-federation/files/src/index.ts__template__ +1 -0
  58. package/src/generators/native-federation/generator.d.ts +4 -0
  59. package/src/generators/native-federation/generator.d.ts.map +1 -0
  60. package/src/generators/native-federation/generator.js +45 -0
  61. package/src/generators/native-federation/schema.d.ts +5 -0
  62. package/src/generators/native-federation/schema.json +29 -0
  63. package/src/index.d.ts +82 -0
  64. package/src/index.d.ts.map +1 -0
  65. package/src/index.js +132 -0
  66. package/src/internal.d.ts +2 -0
  67. package/src/internal.d.ts.map +1 -0
  68. package/src/internal.js +1 -0
  69. package/src/schematics/appbuilder/schema.d.ts +3 -0
  70. package/src/schematics/appbuilder/schema.json +17 -0
  71. package/src/schematics/appbuilder/schematic.d.ts +5 -0
  72. package/src/schematics/appbuilder/schematic.d.ts.map +1 -0
  73. package/src/schematics/appbuilder/schematic.js +80 -0
  74. package/src/schematics/init/files/federation.config.mjs__tmpl__ +35 -0
  75. package/src/schematics/init/schema.d.ts +5 -0
  76. package/src/schematics/init/schema.json +30 -0
  77. package/src/schematics/init/schematic.d.ts +6 -0
  78. package/src/schematics/init/schematic.d.ts.map +1 -0
  79. package/src/schematics/init/schematic.js +38 -0
  80. package/src/schematics/init/steps/add-dependencies.d.ts +3 -0
  81. package/src/schematics/init/steps/add-dependencies.d.ts.map +1 -0
  82. package/src/schematics/init/steps/add-dependencies.js +25 -0
  83. package/src/schematics/init/steps/generate-federation-config.d.ts +4 -0
  84. package/src/schematics/init/steps/generate-federation-config.d.ts.map +1 -0
  85. package/src/schematics/init/steps/generate-federation-config.js +15 -0
  86. package/src/schematics/init/steps/generate-remote-map.d.ts +2 -0
  87. package/src/schematics/init/steps/generate-remote-map.d.ts.map +1 -0
  88. package/src/schematics/init/steps/generate-remote-map.js +20 -0
  89. package/src/schematics/init/steps/make-main-async.d.ts +4 -0
  90. package/src/schematics/init/steps/make-main-async.d.ts.map +1 -0
  91. package/src/schematics/init/steps/make-main-async.js +35 -0
  92. package/src/schematics/init/steps/normalize-options.d.ts +20 -0
  93. package/src/schematics/init/steps/normalize-options.d.ts.map +1 -0
  94. package/src/schematics/init/steps/normalize-options.js +64 -0
  95. package/src/schematics/init/steps/update-package-json.d.ts +3 -0
  96. package/src/schematics/init/steps/update-package-json.d.ts.map +1 -0
  97. package/src/schematics/init/steps/update-package-json.js +19 -0
  98. package/src/schematics/init/steps/update-polyfills.d.ts +3 -0
  99. package/src/schematics/init/steps/update-polyfills.d.ts.map +1 -0
  100. package/src/schematics/init/steps/update-polyfills.js +21 -0
  101. package/src/schematics/init/steps/update-workspace-config.d.ts +4 -0
  102. package/src/schematics/init/steps/update-workspace-config.d.ts.map +1 -0
  103. package/src/schematics/init/steps/update-workspace-config.js +76 -0
  104. package/src/schematics/remove/schema.d.ts +3 -0
  105. package/src/schematics/remove/schema.json +17 -0
  106. package/src/schematics/remove/schematic.d.ts +5 -0
  107. package/src/schematics/remove/schematic.d.ts.map +1 -0
  108. package/src/schematics/remove/schematic.js +106 -0
  109. package/src/tools/esbuild/angular-bundler.d.ts +10 -0
  110. package/src/tools/esbuild/angular-bundler.d.ts.map +1 -0
  111. package/src/tools/esbuild/angular-bundler.js +134 -0
  112. package/src/tools/esbuild/create-awaitable-compiler-plugin.d.ts +6 -0
  113. package/src/tools/esbuild/create-awaitable-compiler-plugin.d.ts.map +1 -0
  114. package/src/tools/esbuild/create-awaitable-compiler-plugin.js +29 -0
  115. package/src/tools/esbuild/create-federation-tsconfig.d.ts +7 -0
  116. package/src/tools/esbuild/create-federation-tsconfig.d.ts.map +1 -0
  117. package/src/tools/esbuild/create-federation-tsconfig.js +46 -0
  118. package/src/tools/esbuild/shared-mappings-plugin.d.ts +4 -0
  119. package/src/tools/esbuild/shared-mappings-plugin.d.ts.map +1 -0
  120. package/src/tools/esbuild/shared-mappings-plugin.js +33 -0
  121. package/src/tools/mf/build-for-federation.d.ts +70 -0
  122. package/src/tools/mf/build-for-federation.d.ts.map +1 -0
  123. package/src/tools/mf/build-for-federation.js +75 -0
  124. package/src/tools/mf/federation-entry-points.d.ts +23 -0
  125. package/src/tools/mf/federation-entry-points.d.ts.map +1 -0
  126. package/src/tools/mf/federation-entry-points.js +13 -0
  127. package/src/tools/mf/federation-plugin.d.ts +11 -0
  128. package/src/tools/mf/federation-plugin.d.ts.map +1 -0
  129. package/src/tools/mf/federation-plugin.js +12 -0
  130. package/src/tools/mf/federation-side-build.d.ts +21 -0
  131. package/src/tools/mf/federation-side-build.d.ts.map +1 -0
  132. package/src/tools/mf/federation-side-build.js +27 -0
  133. package/src/tools/mf/to-plugin-config.d.ts +37 -0
  134. package/src/tools/mf/to-plugin-config.d.ts.map +1 -0
  135. package/src/tools/mf/to-plugin-config.js +33 -0
  136. package/src/utils/check-for-invalid-imports.d.ts +2 -0
  137. package/src/utils/check-for-invalid-imports.d.ts.map +1 -0
  138. package/src/utils/check-for-invalid-imports.js +29 -0
  139. package/src/utils/normalize-build-options.d.ts +22 -0
  140. package/src/utils/normalize-build-options.d.ts.map +1 -0
  141. package/src/utils/normalize-build-options.js +45 -0
  142. package/src/utils/normalize-context-options.d.ts +24 -0
  143. package/src/utils/normalize-context-options.d.ts.map +1 -0
  144. package/src/utils/normalize-context-options.js +18 -0
@@ -0,0 +1,24 @@
1
+ import type { ApplicationBuilderOptions } from '@angular/build';
2
+ import type { BuilderContext } from '@angular-devkit/architect';
3
+ import type { NfRemoteBuilderSchema } from './schema.js';
4
+ export interface ResolvedNgOptions {
5
+ ngBuilderOptions: ApplicationBuilderOptions;
6
+ projectRoot: string;
7
+ projectSourceRoot: string | undefined;
8
+ }
9
+ /**
10
+ * Builds the subset of ApplicationBuilderOptions that the esbuild adapter actually
11
+ * reads (see angular-bundler.ts / node-modules-bundler.ts).
12
+ *
13
+ * Unlike the `build` builder — which runs a full Angular target and has its options
14
+ * validated and defaulted by context.validateOptions — the remote builder has no
15
+ * Angular target to delegate to, so it forwards only these compile-level options
16
+ * straight from its own schema. `optimization`/`sourceMap` are normalized later at
17
+ * the point of use by the bundler.
18
+ *
19
+ * tsConfig, outputPath and assets are intentionally omitted: the federation adapter
20
+ * supplies the tsconfig path and output dir, and assets are copied by the remote
21
+ * builder's own pipeline (see assets.ts) — none are read off ApplicationBuilderOptions.
22
+ */
23
+ export declare function resolveNgBuilderOptions(remote: NfRemoteBuilderSchema, context: BuilderContext): Promise<ResolvedNgOptions>;
24
+ //# sourceMappingURL=resolve-ng-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-ng-options.d.ts","sourceRoot":"","sources":["../../../../src/builders/remote/resolve-ng-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAe5B"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Builds the subset of ApplicationBuilderOptions that the esbuild adapter actually
3
+ * reads (see angular-bundler.ts / node-modules-bundler.ts).
4
+ *
5
+ * Unlike the `build` builder — which runs a full Angular target and has its options
6
+ * validated and defaulted by context.validateOptions — the remote builder has no
7
+ * Angular target to delegate to, so it forwards only these compile-level options
8
+ * straight from its own schema. `optimization`/`sourceMap` are normalized later at
9
+ * the point of use by the bundler.
10
+ *
11
+ * tsConfig, outputPath and assets are intentionally omitted: the federation adapter
12
+ * supplies the tsconfig path and output dir, and assets are copied by the remote
13
+ * builder's own pipeline (see assets.ts) — none are read off ApplicationBuilderOptions.
14
+ */
15
+ export async function resolveNgBuilderOptions(remote, context) {
16
+ const projectMetadata = await context.getProjectMetadata(context.target.project);
17
+ const projectRoot = projectMetadata['root'] ?? '';
18
+ const projectSourceRoot = projectMetadata['sourceRoot'];
19
+ const ngBuilderOptions = {
20
+ stylePreprocessorOptions: remote.stylePreprocessorOptions,
21
+ inlineStyleLanguage: remote.inlineStyleLanguage,
22
+ fileReplacements: remote.fileReplacements,
23
+ sourceMap: remote.sourceMap,
24
+ optimization: remote.optimization,
25
+ preserveSymlinks: remote.preserveSymlinks,
26
+ };
27
+ return { ngBuilderOptions, projectRoot, projectSourceRoot };
28
+ }
@@ -0,0 +1,26 @@
1
+ import type { JsonObject } from '@angular-devkit/core';
2
+ import type { Plugin } from 'esbuild';
3
+ import type { ApplicationBuilderOptions } from '@angular/build';
4
+
5
+ export interface NfRemoteBuilderSchema extends JsonObject {
6
+ tsConfig: string;
7
+ dev: boolean;
8
+ rebuildDelay: number;
9
+ watch: boolean;
10
+ outputPath?: string;
11
+ projectName?: string;
12
+ verbose?: boolean;
13
+ entryPoints?: string[];
14
+ cacheExternalArtifacts?: boolean;
15
+
16
+ // Passthroughs to the Angular esbuild pipeline / asset copier.
17
+ assets?: ApplicationBuilderOptions['assets'];
18
+ stylePreprocessorOptions?: ApplicationBuilderOptions['stylePreprocessorOptions'];
19
+ inlineStyleLanguage?: ApplicationBuilderOptions['inlineStyleLanguage'];
20
+ fileReplacements?: ApplicationBuilderOptions['fileReplacements'];
21
+ sourceMap?: ApplicationBuilderOptions['sourceMap'];
22
+ optimization?: ApplicationBuilderOptions['optimization'];
23
+ preserveSymlinks?: ApplicationBuilderOptions['preserveSymlinks'];
24
+ }
25
+
26
+ export type NfRemoteInternalOptions = { plugins: Plugin[] };
@@ -0,0 +1,116 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "$schema": "http://json-schema.org/draft-07/schema",
5
+ "title": "native federation remote builder",
6
+ "description": "builder for native federation remotes that only produces the federation artifacts (remoteEntry.json + referenced files) plus copied assets. No Angular application build and no dev server; serving is handled externally.",
7
+ "type": "object",
8
+ "properties": {
9
+ "tsConfig": {
10
+ "type": "string",
11
+ "description": "Path to the tsconfig used to compile the exposed modules and shared mappings."
12
+ },
13
+ "dev": {
14
+ "type": "boolean",
15
+ "description": "Set this to true to start the builder in dev mode",
16
+ "default": false
17
+ },
18
+ "watch": {
19
+ "type": "boolean",
20
+ "default": false
21
+ },
22
+ "entryPoints": {
23
+ "type": "array"
24
+ },
25
+ "rebuildDelay": {
26
+ "type": "number",
27
+ "default": 2000,
28
+ "description": "Debounce delay (ms) before rebuilding federation artifacts after a file change in watch mode."
29
+ },
30
+ "projectName": {
31
+ "type": "string"
32
+ },
33
+ "outputPath": {
34
+ "type": "string"
35
+ },
36
+ "verbose": {
37
+ "type": "boolean",
38
+ "default": false
39
+ },
40
+ "cacheExternalArtifacts": {
41
+ "type": "boolean",
42
+ "default": true,
43
+ "description": "Will cache the shared externals so they can be re-used between builds",
44
+ "alias": "cache"
45
+ },
46
+ "assets": {
47
+ "type": "array",
48
+ "description": "Assets to copy into the output directory. Same shape as @angular/build:application 'assets'.",
49
+ "items": {
50
+ "oneOf": [
51
+ { "type": "string" },
52
+ {
53
+ "type": "object",
54
+ "properties": {
55
+ "glob": { "type": "string" },
56
+ "input": { "type": "string" },
57
+ "output": { "type": "string" },
58
+ "ignore": { "type": "array", "items": { "type": "string" } },
59
+ "followSymlinks": { "type": "boolean" }
60
+ },
61
+ "required": ["glob", "input"]
62
+ }
63
+ ]
64
+ }
65
+ },
66
+ "stylePreprocessorOptions": {
67
+ "type": "object",
68
+ "description": "Options passed to style preprocessors (e.g. Sass includePaths).",
69
+ "properties": {
70
+ "includePaths": { "type": "array", "items": { "type": "string" } },
71
+ "sass": { "type": "object" }
72
+ }
73
+ },
74
+ "inlineStyleLanguage": {
75
+ "type": "string",
76
+ "description": "Preprocessor language for inline component styles.",
77
+ "enum": ["css", "less", "sass", "scss"]
78
+ },
79
+ "fileReplacements": {
80
+ "type": "array",
81
+ "description": "Replace files listed in the build at compile time.",
82
+ "items": {
83
+ "type": "object",
84
+ "properties": {
85
+ "replace": { "type": "string" },
86
+ "with": { "type": "string" }
87
+ },
88
+ "required": ["replace", "with"]
89
+ }
90
+ },
91
+ "sourceMap": {
92
+ "description": "Enable or configure source maps.",
93
+ "oneOf": [
94
+ { "type": "boolean" },
95
+ {
96
+ "type": "object",
97
+ "properties": {
98
+ "scripts": { "type": "boolean" },
99
+ "styles": { "type": "boolean" },
100
+ "hidden": { "type": "boolean" },
101
+ "vendor": { "type": "boolean" }
102
+ }
103
+ }
104
+ ]
105
+ },
106
+ "optimization": {
107
+ "description": "Enable or configure optimizations.",
108
+ "oneOf": [{ "type": "boolean" }, { "type": "object" }]
109
+ },
110
+ "preserveSymlinks": {
111
+ "type": "boolean",
112
+ "description": "Do not use the real path when resolving modules."
113
+ }
114
+ },
115
+ "required": ["tsConfig"]
116
+ }
@@ -0,0 +1,6 @@
1
+ import { type ExternalConfig } from '@softarc/native-federation/config';
2
+ export declare function shareAngularLocales(keys: string[], opts?: {
3
+ config?: ExternalConfig;
4
+ legacy?: boolean;
5
+ }): import("@softarc/native-federation").ShareExternalsOptions;
6
+ //# sourceMappingURL=angular-locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-locales.d.ts","sourceRoot":"","sources":["../../../src/config/angular-locales.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAE/E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,8DA0BzD"}
@@ -0,0 +1,23 @@
1
+ import { share } from '@softarc/native-federation/config';
2
+ export function shareAngularLocales(keys, opts = {}) {
3
+ if (!opts.config) {
4
+ opts.config = {
5
+ singleton: true,
6
+ strictVersion: true,
7
+ requiredVersion: 'auto',
8
+ };
9
+ }
10
+ const ext = opts.legacy ? '.mjs' : '.js';
11
+ const locales = keys.reduce((acc, key) => {
12
+ acc[`@angular/common/locales/${key}`] = {
13
+ ...opts.config,
14
+ packageInfo: {
15
+ esm: true,
16
+ entryPoint: `node_modules/@angular/common/locales/${key}${ext}`,
17
+ ...opts.config.packageInfo,
18
+ },
19
+ };
20
+ return acc;
21
+ }, {});
22
+ return share(locales);
23
+ }
@@ -0,0 +1,3 @@
1
+ import { type SkipList } from "@module-federation/esbuild/dist/lib/core/default-skip-list.js";
2
+ export declare const NG_SKIP_LIST: SkipList;
3
+ //# sourceMappingURL=angular-skip-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-skip-list.d.ts","sourceRoot":"","sources":["../../../src/config/angular-skip-list.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,+DAA+D,CAAC;AAEvE,eAAO,MAAM,YAAY,EAAE,QAa1B,CAAC"}
@@ -0,0 +1,23 @@
1
+ // M3.2 — Angular skip-list, MF-native. Two NF couplings broken vs the old file:
2
+ // (1) `SkipList` type + `DEFAULT_SKIP_LIST` base now come from
3
+ // `@module-federation/esbuild` (deep import, Breakage-A-free, like M3.1)
4
+ // instead of `@softarc/native-federation/config`;
5
+ // (2) the self-listed package paths are the **renamed** package, not the old
6
+ // `@angular-architects/native-federation*`.
7
+ // The `@angular/localize*`, `*/upgrade`, `*/testing`, `@nx/angular`, and `zone.js`
8
+ // entries carry over unchanged.
9
+ import { DEFAULT_SKIP_LIST, } from "@module-federation/esbuild/dist/lib/core/default-skip-list.js";
10
+ export const NG_SKIP_LIST = [
11
+ ...DEFAULT_SKIP_LIST,
12
+ "module-federation-angular-adapter",
13
+ "module-federation-angular-adapter/config",
14
+ "module-federation-angular-adapter/internal",
15
+ "zone.js",
16
+ "@angular/localize",
17
+ "@angular/localize/init",
18
+ "@angular/localize/tools",
19
+ "@angular/router/upgrade",
20
+ "@angular/common/upgrade",
21
+ /^@nx\/angular/,
22
+ (pkg) => pkg.startsWith("@angular/") && !!pkg.match(/\/testing(\/|$)/),
23
+ ];
@@ -0,0 +1,72 @@
1
+ import { NG_SKIP_LIST } from './angular-skip-list.js';
2
+ /**
3
+ * Package-name prefixes that imply a server (Node) build. Matched with
4
+ * `startsWith`, so secondary entry points (e.g. `@angular/ssr/node`) match too.
5
+ * (Carried over from NF's `share-utils.ts` unchanged.)
6
+ */
7
+ export declare const SERVER_DEPENDENCIES: string[];
8
+ /**
9
+ * Infers the default federation platform from the shared dependency keys:
10
+ * `'node'` if any is an Angular server package, else `'browser'`.
11
+ *
12
+ * ⚠️ MF has **no `platform` shared-key** (M3.1 table) — this stays an Angular-side
13
+ * build hint (drives the SSR side build + shared-set selection, Phase 4), not an
14
+ * MF `shared` field.
15
+ */
16
+ export declare function getDefaultPlatform(deps: string[]): 'browser' | 'node';
17
+ /** MF shared-config entry (mirrors `@module-federation/esbuild`'s `SharedConfig`). */
18
+ export interface MfSharedConfig {
19
+ requiredVersion?: string;
20
+ singleton?: boolean;
21
+ strictVersion?: boolean;
22
+ version?: string;
23
+ eager?: boolean;
24
+ includeSecondaries?: boolean | {
25
+ skip?: string | string[];
26
+ };
27
+ }
28
+ /**
29
+ * Share specific packages as MF singletons. Thin pass-through to MF-esbuild's
30
+ * `share` (which resolves `requiredVersion: 'auto'`-style versions via
31
+ * `lookupVersion` at config-build time — the M3.1 table's `'auto'` mapping).
32
+ */
33
+ export declare function share(shareObjects: Record<string, MfSharedConfig>, projectPath?: string): Record<string, MfSharedConfig>;
34
+ /**
35
+ * Share all dependencies from `package.json` as MF singletons. Delegates to
36
+ * MF-esbuild's `shareAll`; `skip` defaults to the Angular skip-list
37
+ * ({@link NG_SKIP_LIST}, M3.2) so Angular framework/testing/locale packages and
38
+ * this adapter itself are not auto-shared.
39
+ */
40
+ export declare function shareAll(config: MfSharedConfig, skip?: typeof NG_SKIP_LIST, projectPath?: string): Record<string, MfSharedConfig>;
41
+ /** Normalized output of {@link withModuleFederation} (consumed by the side build). */
42
+ export interface NormalizedModuleFederationConfig {
43
+ name: string;
44
+ filename: string;
45
+ exposes: Record<string, string>;
46
+ remotes: Record<string, string>;
47
+ shared: Record<string, MfSharedConfig>;
48
+ /** Angular-side build hint, not an MF shared key. */
49
+ platform: 'browser' | 'node';
50
+ }
51
+ /** Angular federation config input (mirrors NF's `FederationConfig` surface). */
52
+ export interface ModuleFederationConfig {
53
+ name?: string;
54
+ filename?: string;
55
+ exposes?: Record<string, string>;
56
+ remotes?: Record<string, string>;
57
+ shared?: Record<string, MfSharedConfig>;
58
+ skip?: string[];
59
+ /** Angular-side build hint (browser|node); auto-filled from shared deps if omitted. */
60
+ platform?: 'browser' | 'node';
61
+ }
62
+ /**
63
+ * Angular `withModuleFederation` (M3.1). Auto-fills the Angular-side `platform`
64
+ * hint (NF parity), then normalizes via MF-esbuild's own `withFederation`.
65
+ *
66
+ * NF→MF field decisions (M3.1 table): `singleton`/`strictVersion`/`requiredVersion`/
67
+ * `version`/`eager`/`includeSecondaries` all map 1:1 (the MF plugin supports
68
+ * `includeSecondaries` — finding #4). NF-only `build`/`features.{denseChunking,
69
+ * ignoreUnusedDeps}` are **dropped** (no MF equivalent; MF shares only what's listed).
70
+ */
71
+ export declare function withModuleFederation(cfg: ModuleFederationConfig): NormalizedModuleFederationConfig;
72
+ //# sourceMappingURL=with-module-federation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-module-federation.d.ts","sourceRoot":"","sources":["../../../src/config/with-module-federation.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,UAA+C,CAAC;AAEhF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAIrE;AAED,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;CAC7D;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC5C,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAEhC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,EACtB,IAAI,GAAE,OAAO,YAA2B,EACxC,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAMhC;AAED,sFAAsF;AACtF,MAAM,WAAW,gCAAgC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,qDAAqD;IACrD,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC;CAC9B;AAED,iFAAiF;AACjF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,sBAAsB,GAC1B,gCAAgC,CAgBlC"}
@@ -0,0 +1,72 @@
1
+ // M3.1 — `withModuleFederation` mirroring NF's `withNativeFederation`, built as a
2
+ // thin Angular wrapper over `@module-federation/esbuild`'s OWN config layer
3
+ // (finding #4). Imported from the deep `dist/lib/config/*` path because the
4
+ // high-level `./build` entry throws on import (Breakage A, the `json5` defect);
5
+ // the deep path is allowed by the package's `"./*"` export and is Breakage-A-free.
6
+ // ⚠️ Deep-import fragility: pinned to @module-federation/esbuild@0.0.109 internals;
7
+ // re-verify these paths on any version bump (tracked with the dominant 0.0.x risk).
8
+ import { share as coreShare, shareAll as coreShareAll, } from '@module-federation/esbuild/dist/lib/config/share-utils.js';
9
+ import { withFederation as coreWithFederation } from '@module-federation/esbuild/dist/lib/config/with-native-federation.js';
10
+ import { NG_SKIP_LIST } from './angular-skip-list.js';
11
+ /**
12
+ * Package-name prefixes that imply a server (Node) build. Matched with
13
+ * `startsWith`, so secondary entry points (e.g. `@angular/ssr/node`) match too.
14
+ * (Carried over from NF's `share-utils.ts` unchanged.)
15
+ */
16
+ export const SERVER_DEPENDENCIES = ['@angular/platform-server', '@angular/ssr'];
17
+ /**
18
+ * Infers the default federation platform from the shared dependency keys:
19
+ * `'node'` if any is an Angular server package, else `'browser'`.
20
+ *
21
+ * ⚠️ MF has **no `platform` shared-key** (M3.1 table) — this stays an Angular-side
22
+ * build hint (drives the SSR side build + shared-set selection, Phase 4), not an
23
+ * MF `shared` field.
24
+ */
25
+ export function getDefaultPlatform(deps) {
26
+ return deps.some((dep) => SERVER_DEPENDENCIES.some((s) => dep.startsWith(s)))
27
+ ? 'node'
28
+ : 'browser';
29
+ }
30
+ /**
31
+ * Share specific packages as MF singletons. Thin pass-through to MF-esbuild's
32
+ * `share` (which resolves `requiredVersion: 'auto'`-style versions via
33
+ * `lookupVersion` at config-build time — the M3.1 table's `'auto'` mapping).
34
+ */
35
+ export function share(shareObjects, projectPath) {
36
+ return coreShare(shareObjects, projectPath);
37
+ }
38
+ /**
39
+ * Share all dependencies from `package.json` as MF singletons. Delegates to
40
+ * MF-esbuild's `shareAll`; `skip` defaults to the Angular skip-list
41
+ * ({@link NG_SKIP_LIST}, M3.2) so Angular framework/testing/locale packages and
42
+ * this adapter itself are not auto-shared.
43
+ */
44
+ export function shareAll(config, skip = NG_SKIP_LIST, projectPath) {
45
+ return coreShareAll(config, skip, projectPath);
46
+ }
47
+ /**
48
+ * Angular `withModuleFederation` (M3.1). Auto-fills the Angular-side `platform`
49
+ * hint (NF parity), then normalizes via MF-esbuild's own `withFederation`.
50
+ *
51
+ * NF→MF field decisions (M3.1 table): `singleton`/`strictVersion`/`requiredVersion`/
52
+ * `version`/`eager`/`includeSecondaries` all map 1:1 (the MF plugin supports
53
+ * `includeSecondaries` — finding #4). NF-only `build`/`features.{denseChunking,
54
+ * ignoreUnusedDeps}` are **dropped** (no MF equivalent; MF shares only what's listed).
55
+ */
56
+ export function withModuleFederation(cfg) {
57
+ const platform = cfg.platform ?? getDefaultPlatform(Object.keys(cfg.shared ?? {}));
58
+ const { name, filename, exposes, remotes, shared, skip } = cfg;
59
+ // Cast: upstream `withFederation` types `includeSecondaries` as `boolean` only,
60
+ // while its own `share-utils` accepts the `{ skip }` object form too — the
61
+ // runtime handles both. (Type defs disagree across the two upstream modules.)
62
+ const normalized = coreWithFederation({
63
+ name,
64
+ filename,
65
+ exposes,
66
+ remotes,
67
+ shared,
68
+ skip,
69
+ });
70
+ // `platform` is re-attached as an Angular-side hint (not an MF shared key).
71
+ return { ...normalized, platform };
72
+ }
@@ -0,0 +1,4 @@
1
+ export { share, shareAll, withModuleFederation, getDefaultPlatform, SERVER_DEPENDENCIES, type ModuleFederationConfig, type MfSharedConfig, } from './config/with-module-federation.js';
2
+ export { NG_SKIP_LIST } from './config/angular-skip-list.js';
3
+ export { shareAngularLocales } from './config/angular-locales.js';
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
package/src/config.js ADDED
@@ -0,0 +1,3 @@
1
+ export { share, shareAll, withModuleFederation, getDefaultPlatform, SERVER_DEPENDENCIES, } from './config/with-module-federation.js';
2
+ export { NG_SKIP_LIST } from './config/angular-skip-list.js';
3
+ export { shareAngularLocales } from './config/angular-locales.js';
@@ -0,0 +1 @@
1
+ const variable = "<%= projectName %>";
@@ -0,0 +1,4 @@
1
+ import { type Tree } from "@nx/devkit";
2
+ import type { NativeFederationGeneratorSchema } from "./schema.js";
3
+ export default function (tree: Tree, options: NativeFederationGeneratorSchema): Promise<void>;
4
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/generators/native-federation/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AA+CnE,yBACE,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,+BAA+B,iBAgBzC"}
@@ -0,0 +1,45 @@
1
+ import { addProjectConfiguration, formatFiles, generateFiles, getWorkspaceLayout, names, offsetFromRoot, } from "@nx/devkit";
2
+ import * as path from "path";
3
+ function normalizeOptions(tree, options) {
4
+ const name = names(options.name).fileName;
5
+ const projectDirectory = options.directory
6
+ ? `${names(options.directory).fileName}/${name}`
7
+ : name;
8
+ const projectName = projectDirectory.replace(new RegExp("/", "g"), "-");
9
+ const projectRoot = `${getWorkspaceLayout(tree).libsDir}/${projectDirectory}`;
10
+ const parsedTags = options.tags
11
+ ? options.tags.split(",").map((s) => s.trim())
12
+ : [];
13
+ return {
14
+ ...options,
15
+ projectName,
16
+ projectRoot,
17
+ projectDirectory,
18
+ parsedTags,
19
+ };
20
+ }
21
+ function addFiles(tree, options) {
22
+ const templateOptions = {
23
+ ...options,
24
+ ...names(options.name),
25
+ offsetFromRoot: offsetFromRoot(options.projectRoot),
26
+ template: "",
27
+ };
28
+ generateFiles(tree, path.join(__dirname, "files"), options.projectRoot, templateOptions);
29
+ }
30
+ export default async function (tree, options) {
31
+ const normalizedOptions = normalizeOptions(tree, options);
32
+ addProjectConfiguration(tree, normalizedOptions.projectName, {
33
+ root: normalizedOptions.projectRoot,
34
+ projectType: "library",
35
+ sourceRoot: `${normalizedOptions.projectRoot}/src`,
36
+ targets: {
37
+ build: {
38
+ executor: "module-federation-angular-adapter:build",
39
+ },
40
+ },
41
+ tags: normalizedOptions.parsedTags,
42
+ });
43
+ addFiles(tree, normalizedOptions);
44
+ await formatFiles(tree);
45
+ }
@@ -0,0 +1,5 @@
1
+ export interface NativeFederationGeneratorSchema {
2
+ name: string;
3
+ tags?: string;
4
+ directory?: string;
5
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NativeFederation",
5
+ "title": "",
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ },
15
+ "x-prompt": "What name would you like to use?"
16
+ },
17
+ "tags": {
18
+ "type": "string",
19
+ "description": "Add tags to the project (used for linting)",
20
+ "alias": "t"
21
+ },
22
+ "directory": {
23
+ "type": "string",
24
+ "description": "A directory where the project is placed",
25
+ "alias": "d"
26
+ }
27
+ },
28
+ "required": ["name"]
29
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ import { createInstance, type ModuleFederation, type ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ /**
3
+ * Options for {@link FederationInstance.loadRemoteModule}.
4
+ *
5
+ * @property remoteName - Name of the remote as registered in
6
+ * {@link initFederation}, or derived from `remoteEntry`.
7
+ * @property remoteEntry - URL to the remote's `remoteEntry.js` / `mf-manifest.json`.
8
+ * Enables lazy-loading remotes not registered up front (wired in M1.3).
9
+ * @property exposedModule - Key exposed by the remote (e.g. `'./Component'`).
10
+ * @property fallback - Value returned on failure. Truthy-only — `null`/`0`/`''`
11
+ * count as "no fallback".
12
+ */
13
+ export type LoadRemoteModuleOptions<T = any> = {
14
+ remoteEntry?: string;
15
+ remoteName?: string;
16
+ exposedModule: string;
17
+ fallback?: T;
18
+ };
19
+ /** MF runtime `shared` map, derived from `createInstance` so we don't reach into the transitive `runtime-core`. */
20
+ export type SharedConfig = NonNullable<Parameters<typeof createInstance>[0]['shared']>;
21
+ /**
22
+ * Framework packages that MUST resolve to a single instance, or Angular trips
23
+ * `NG0203`. Registered as MF singletons (M0.2's mandated config).
24
+ *
25
+ * `requiredVersion: false` for now — the singleton is enforced but the version
26
+ * check is relaxed, because resolving the installed version (NF's
27
+ * `requiredVersion: 'auto'`) is a config-build-time concern owned by
28
+ * `withModuleFederation` in **M3.1**; once that lands it feeds concrete ranges
29
+ * here. The actual module sharing flows through es-module-shims import maps at
30
+ * runtime (finding #6) — this map only declares the singleton/version contract.
31
+ */
32
+ export declare const DEFAULT_ANGULAR_SHARED: SharedConfig;
33
+ /**
34
+ * Options for {@link initFederation}. NF-native knobs (`shimMode`, `sse`,
35
+ * `cacheTag`, `logging`) are intentionally dropped — MF manages its import map
36
+ * internally and exposes behaviour through runtime plugins instead.
37
+ */
38
+ export interface InitFederationOptions {
39
+ /** Instance name registered with the MF share scope (default `'host'`). */
40
+ name?: string;
41
+ /** MF runtime plugins (replaces NF's `shimMode`/`esmsInitOptions`). */
42
+ runtimePlugins?: ModuleFederationRuntimePlugin[];
43
+ /** Override the default MF share scope name. */
44
+ shareScope?: string;
45
+ /**
46
+ * Shared singletons to register. Merged over {@link DEFAULT_ANGULAR_SHARED}
47
+ * (pass `{}` and spread a filtered default to opt out of a framework dep).
48
+ */
49
+ shared?: SharedConfig;
50
+ }
51
+ /**
52
+ * Handle returned by {@link initFederation}. Holds the live MF instance and the
53
+ * `loadRemoteModule` bound to it. (The NF-era module-scoped standalone
54
+ * `loadRemoteModule` export was dropped in M1.3 — destructure from here instead.)
55
+ */
56
+ export interface FederationInstance {
57
+ /** Load an exposed module from a registered remote. */
58
+ loadRemoteModule<T = unknown>(remoteName: string, exposedModule: string): Promise<T>;
59
+ loadRemoteModule<T = unknown>(options: LoadRemoteModuleOptions<T>): Promise<T>;
60
+ /** The underlying `@module-federation/runtime` instance, for advanced use. */
61
+ readonly instance: ModuleFederation;
62
+ }
63
+ /** name → remoteEntry/manifest URL (the MF-native `entry` of each remote). */
64
+ type RemotesMap = Record<string, string>;
65
+ /**
66
+ * Initialise Module Federation for an Angular host.
67
+ *
68
+ * Unlike NF's promise-returning init, this is **synchronous** — MF's
69
+ * `createInstance` is sync and remotes load lazily on first `loadRemoteModule`.
70
+ *
71
+ * ```ts
72
+ * const { loadRemoteModule } = initFederation({ mfe1: 'http://localhost:4201/remoteEntry.js' });
73
+ * const m = await loadRemoteModule('mfe1', './Component');
74
+ * ```
75
+ *
76
+ * @param remotes - name → remoteEntry/manifest URL map. (A bare manifest-URL
77
+ * string, like NF's `remotesOrManifestUrl`, is deferred to M1.7.)
78
+ * @param options - {@link InitFederationOptions}.
79
+ */
80
+ export declare function initFederation(remotes?: RemotesMap, options?: InitFederationOptions): FederationInstance;
81
+ export {};
82
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EACnC,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,uBAAuB,CAAC,CAAC,GAAG,GAAG,IAAI;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,mHAAmH;AACnH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEvF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAQpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,cAAc,CAAC,EAAE,6BAA6B,EAAE,CAAC;IACjD,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,CAAC,CAAC,CAAC;IACd,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/E,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;CACrC;AAED,8EAA8E;AAC9E,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AA4FzC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE,UAAe,EACxB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,kBAAkB,CA0BpB"}