@angular-architects/native-federation-v4 20.3.7 → 20.3.8
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/collection.json +5 -0
- package/migration-collection.json +6 -0
- package/package.json +3 -3
- package/src/builders/build/builder.d.ts.map +1 -1
- package/src/builders/build/builder.js +45 -49
- package/src/builders/build/schema.d.ts +3 -5
- package/src/builders/build/schema.json +8 -29
- package/src/config/angular-skip-list.d.ts +3 -0
- package/src/config/angular-skip-list.d.ts.map +1 -0
- package/src/config/angular-skip-list.js +13 -0
- package/src/config/share-utils.d.ts +9 -0
- package/src/config/share-utils.d.ts.map +1 -0
- package/src/config/share-utils.js +32 -0
- package/src/config.d.ts +2 -2
- package/src/config.d.ts.map +1 -1
- package/src/config.js +2 -2
- package/src/schematics/init/files/federation.config.js__tmpl__ +19 -7
- package/src/schematics/init/schema.d.ts +0 -1
- package/src/schematics/init/schema.json +2 -6
- package/src/schematics/init/schematic.d.ts.map +1 -1
- package/src/schematics/init/schematic.js +50 -25
- package/src/schematics/update-v4/schema.d.ts +4 -0
- package/src/schematics/update-v4/schema.json +23 -0
- package/src/schematics/update-v4/schematic.d.ts +4 -0
- package/src/schematics/update-v4/schematic.d.ts.map +1 -0
- package/src/schematics/update-v4/schematic.js +225 -0
- package/src/utils/angular-bundler.d.ts +3 -8
- package/src/utils/angular-bundler.d.ts.map +1 -1
- package/src/utils/angular-bundler.js +11 -58
- package/src/utils/angular-esbuild-adapter.d.ts +5 -4
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
- package/src/utils/angular-esbuild-adapter.js +14 -17
- package/src/utils/angular-locales.d.ts.map +1 -1
- package/src/utils/create-federation-tsconfig.d.ts +6 -0
- package/src/utils/create-federation-tsconfig.d.ts.map +1 -0
- package/src/utils/create-federation-tsconfig.js +49 -0
- package/src/utils/get-fallback-platform.d.ts +3 -0
- package/src/utils/get-fallback-platform.d.ts.map +1 -0
- package/src/utils/get-fallback-platform.js +13 -0
- package/src/utils/node-modules-bundler.d.ts +5 -6
- package/src/utils/node-modules-bundler.d.ts.map +1 -1
- package/src/utils/node-modules-bundler.js +6 -9
- package/src/utils/normalize-context-options.d.ts +23 -0
- package/src/utils/normalize-context-options.d.ts.map +1 -0
- package/src/utils/normalize-context-options.js +18 -0
- package/src/utils/shared-mappings-plugin.d.ts +2 -2
- package/src/utils/shared-mappings-plugin.d.ts.map +1 -1
- package/src/utils/shared-mappings-plugin.js +4 -4
package/collection.json
CHANGED
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"factory": "./src/schematics/appbuilder/schematic",
|
|
23
23
|
"schema": "./src/schematics/appbuilder/schema.json",
|
|
24
24
|
"description": "Migrates for using the appbuilder"
|
|
25
|
+
},
|
|
26
|
+
"update-v4": {
|
|
27
|
+
"factory": "./src/schematics/update-v4/schematic",
|
|
28
|
+
"schema": "./src/schematics/update-v4/schema.json",
|
|
29
|
+
"description": "Migrates from native-federation v3 to v4"
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"factory": "./src/schematics/update18/schematic",
|
|
9
9
|
"schema": "./src/schematics/update18/schema.json",
|
|
10
10
|
"description": "migrating to v18"
|
|
11
|
+
},
|
|
12
|
+
"update-v4": {
|
|
13
|
+
"version": "21.2.0-beta.0",
|
|
14
|
+
"factory": "./src/schematics/update-v4/schematic",
|
|
15
|
+
"schema": "./src/schematics/update-v4/schema.json",
|
|
16
|
+
"description": "migrating from native-federation v3 to v4"
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-architects/native-federation-v4",
|
|
3
|
-
"version": "20.3.
|
|
3
|
+
"version": "20.3.8",
|
|
4
4
|
"generators": "./collection.json",
|
|
5
5
|
"builders": "./builders.json",
|
|
6
6
|
"schematics": "./collection.json",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"url": "http://www.angulararchitects.io"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@softarc/native-federation": "4.0.0-
|
|
14
|
-
"@softarc/native-federation-runtime": "4.0.0-
|
|
13
|
+
"@softarc/native-federation": "4.0.0-RC9",
|
|
14
|
+
"@softarc/native-federation-runtime": "4.0.0-RC9",
|
|
15
15
|
"@angular-devkit/architect": "^0.2003.1",
|
|
16
16
|
"@angular-devkit/build-angular": "~20.3.1",
|
|
17
17
|
"@angular-devkit/core": "~20.3.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../src/builders/build/builder.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAS1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAGnB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../src/builders/build/builder.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAS1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAGnB,MAAM,2BAA2B,CAAC;AA+BnC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AA2CnD,wBAAuB,UAAU,CAC/B,gBAAgB,EAAE,eAAe,EACjC,OAAO,EAAE,cAAc,GACtB,aAAa,CAAC,aAAa,CAAC,CA8X9B;wBA6C2C,GAAG;AAA/C,wBAAgD"}
|
|
@@ -6,13 +6,13 @@ import { buildApplication } from '@angular/build';
|
|
|
6
6
|
import { buildApplicationInternal, serveWithVite, SourceFileCache } from '@angular/build/private';
|
|
7
7
|
import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
|
|
8
8
|
import { normalizeOptions } from '@angular-devkit/build-angular/src/builders/dev-server/options.js';
|
|
9
|
-
import { buildForFederation, rebuildForFederation, getExternals,
|
|
9
|
+
import { buildForFederation, rebuildForFederation, getExternals, normalizeFederationOptions, setBuildAdapter, createFederationCache, } from '@softarc/native-federation';
|
|
10
10
|
import { logger, setLogLevel, RebuildQueue, AbortedError, getDefaultCachePath, } from '@softarc/native-federation/internal';
|
|
11
11
|
import { createAngularBuildAdapter } from '../../utils/angular-esbuild-adapter.js';
|
|
12
12
|
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
13
13
|
import { fstart } from '../../tools/fstart-as-data-url.js';
|
|
14
14
|
import { getI18nConfig, translateFederationArtifacts } from '../../utils/i18n.js';
|
|
15
|
-
import { createSharedMappingsPlugin } from '../../utils/shared-mappings-plugin.js';
|
|
15
|
+
// import { createSharedMappingsPlugin } from '../../utils/shared-mappings-plugin.js';
|
|
16
16
|
import { updateScriptTags } from '../../utils/updateIndexHtml.js';
|
|
17
17
|
import { federationBuildNotifier } from './federation-build-notifier.js';
|
|
18
18
|
const originalWrite = process.stderr.write.bind(process.stderr);
|
|
@@ -70,7 +70,7 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
70
70
|
const runServer = typeof nfBuilderOptions.devServer !== 'undefined'
|
|
71
71
|
? !!nfBuilderOptions.devServer
|
|
72
72
|
: target.target.includes('serve');
|
|
73
|
-
let
|
|
73
|
+
let ngBuilderOptions = (await context.validateOptions(runServer
|
|
74
74
|
? {
|
|
75
75
|
...targetOptions,
|
|
76
76
|
port: nfBuilderOptions.port || targetOptions['port'],
|
|
@@ -78,27 +78,27 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
78
78
|
: targetOptions, builder));
|
|
79
79
|
let serverOptions = null;
|
|
80
80
|
const watch = nfBuilderOptions.watch;
|
|
81
|
-
if (
|
|
82
|
-
serverOptions = await normalizeOptions(context, context.target.project,
|
|
83
|
-
target = targetFromTargetString(
|
|
81
|
+
if (ngBuilderOptions['buildTarget']) {
|
|
82
|
+
serverOptions = await normalizeOptions(context, context.target.project, ngBuilderOptions);
|
|
83
|
+
target = targetFromTargetString(ngBuilderOptions['buildTarget']);
|
|
84
84
|
targetOptions = (await context.getTargetOptions(target));
|
|
85
85
|
builder = await context.getBuilderNameForTarget(target);
|
|
86
|
-
|
|
86
|
+
ngBuilderOptions = (await context.validateOptions(targetOptions, builder));
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
ngBuilderOptions.watch = watch;
|
|
89
89
|
if (nfBuilderOptions.baseHref) {
|
|
90
|
-
|
|
90
|
+
ngBuilderOptions.baseHref = nfBuilderOptions.baseHref;
|
|
91
91
|
}
|
|
92
92
|
if (nfBuilderOptions.outputPath) {
|
|
93
|
-
|
|
93
|
+
ngBuilderOptions.outputPath = nfBuilderOptions.outputPath;
|
|
94
94
|
}
|
|
95
|
-
const adapter = createAngularBuildAdapter(
|
|
95
|
+
const adapter = createAngularBuildAdapter(ngBuilderOptions, context);
|
|
96
96
|
setBuildAdapter(adapter);
|
|
97
|
-
setLogLevel(
|
|
98
|
-
if (!
|
|
99
|
-
|
|
97
|
+
setLogLevel(ngBuilderOptions.verbose ? 'verbose' : 'info');
|
|
98
|
+
if (!ngBuilderOptions.outputPath) {
|
|
99
|
+
ngBuilderOptions.outputPath = `dist/${context.target.project}`;
|
|
100
100
|
}
|
|
101
|
-
const outputPath =
|
|
101
|
+
const outputPath = ngBuilderOptions.outputPath;
|
|
102
102
|
const outputOptions = {
|
|
103
103
|
browser: 'browser',
|
|
104
104
|
server: 'server',
|
|
@@ -107,37 +107,37 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
107
107
|
base: typeof outputPath === 'string' ? outputPath : outputPath.base,
|
|
108
108
|
};
|
|
109
109
|
const i18n = await getI18nConfig(context);
|
|
110
|
-
const localeFilter = getLocaleFilter(
|
|
110
|
+
const localeFilter = getLocaleFilter(ngBuilderOptions, runServer);
|
|
111
111
|
const sourceLocaleSegment = typeof i18n?.sourceLocale === 'string'
|
|
112
112
|
? i18n.sourceLocale
|
|
113
113
|
: i18n?.sourceLocale?.subPath || i18n?.sourceLocale?.code || '';
|
|
114
|
-
const browserOutputPath = path.join(outputOptions.base, outputOptions.browser,
|
|
114
|
+
const browserOutputPath = path.join(outputOptions.base, outputOptions.browser, ngBuilderOptions.localize ? sourceLocaleSegment : '');
|
|
115
115
|
const differentDevServerOutputPath = Array.isArray(localeFilter) && localeFilter.length === 1;
|
|
116
116
|
const devServerOutputPath = !differentDevServerOutputPath
|
|
117
117
|
? browserOutputPath
|
|
118
118
|
: path.join(outputOptions.base, outputOptions.browser, localeFilter[0]);
|
|
119
|
-
const
|
|
119
|
+
const entryPoints = nfBuilderOptions.entryPoints && nfBuilderOptions.entryPoints.length > 0
|
|
120
|
+
? nfBuilderOptions.entryPoints
|
|
121
|
+
: [path.join(path.dirname(ngBuilderOptions.tsConfig), 'src/main.ts')];
|
|
120
122
|
const cachePath = getDefaultCachePath(context.workspaceRoot);
|
|
121
|
-
const
|
|
123
|
+
const normalized = await normalizeFederationOptions({
|
|
124
|
+
projectName: nfBuilderOptions.projectName,
|
|
122
125
|
workspaceRoot: context.workspaceRoot,
|
|
123
126
|
outputPath: browserOutputPath,
|
|
124
|
-
federationConfig: inferConfigPath(
|
|
125
|
-
tsConfig:
|
|
126
|
-
verbose:
|
|
127
|
-
watch:
|
|
127
|
+
federationConfig: inferConfigPath(ngBuilderOptions.tsConfig),
|
|
128
|
+
tsConfig: ngBuilderOptions.tsConfig,
|
|
129
|
+
verbose: ngBuilderOptions.verbose,
|
|
130
|
+
watch: ngBuilderOptions.watch,
|
|
128
131
|
dev: !!nfBuilderOptions.dev,
|
|
129
|
-
|
|
130
|
-
entryPoint,
|
|
132
|
+
entryPoints,
|
|
131
133
|
buildNotifications: nfBuilderOptions.buildNotifications,
|
|
132
|
-
cacheExternalArtifacts: nfBuilderOptions.cacheExternalArtifacts,
|
|
134
|
+
cacheExternalArtifacts: nfBuilderOptions.cacheExternalArtifacts !== false,
|
|
133
135
|
}, createFederationCache(cachePath, new SourceFileCache(cachePath)));
|
|
134
136
|
const activateSsr = nfBuilderOptions.ssr && !nfBuilderOptions.dev;
|
|
135
137
|
const start = process.hrtime();
|
|
136
|
-
const config = await loadFederationConfig(nfOptions);
|
|
137
138
|
logger.measure(start, 'To load the federation config.');
|
|
138
|
-
const externals = getExternals(config);
|
|
139
|
+
const externals = getExternals(normalized.config);
|
|
139
140
|
const plugins = [
|
|
140
|
-
createSharedMappingsPlugin(config.sharedMappings),
|
|
141
141
|
{
|
|
142
142
|
name: 'externals',
|
|
143
143
|
setup(build) {
|
|
@@ -149,7 +149,7 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
149
149
|
];
|
|
150
150
|
// SSR build fails when externals are provided via the plugin
|
|
151
151
|
if (activateSsr) {
|
|
152
|
-
|
|
152
|
+
ngBuilderOptions.externalDependencies = externals;
|
|
153
153
|
}
|
|
154
154
|
const isLocalDevelopment = runServer && nfBuilderOptions.dev;
|
|
155
155
|
// Initialize SSE reloader only for local development
|
|
@@ -159,12 +159,12 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
159
159
|
const middleware = [
|
|
160
160
|
...(isLocalDevelopment
|
|
161
161
|
? [
|
|
162
|
-
federationBuildNotifier.createEventMiddleware(req => removeBaseHref(req,
|
|
162
|
+
federationBuildNotifier.createEventMiddleware(req => removeBaseHref(req, ngBuilderOptions.baseHref)),
|
|
163
163
|
]
|
|
164
164
|
: []),
|
|
165
165
|
(req, res, next) => {
|
|
166
|
-
const url = removeBaseHref(req,
|
|
167
|
-
const fileName = path.join(
|
|
166
|
+
const url = removeBaseHref(req, ngBuilderOptions.baseHref);
|
|
167
|
+
const fileName = path.join(normalized.options.workspaceRoot, devServerOutputPath, url);
|
|
168
168
|
const exists = fs.existsSync(fileName);
|
|
169
169
|
if (url !== '/' && url !== '' && exists) {
|
|
170
170
|
const lookup = mrmime.lookup;
|
|
@@ -187,24 +187,22 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
187
187
|
},
|
|
188
188
|
];
|
|
189
189
|
let first = true;
|
|
190
|
-
if (existsSync(
|
|
191
|
-
rmSync(
|
|
190
|
+
if (existsSync(normalized.options.outputPath)) {
|
|
191
|
+
rmSync(normalized.options.outputPath, { recursive: true });
|
|
192
192
|
}
|
|
193
|
-
if (!existsSync(
|
|
194
|
-
mkdirSync(
|
|
193
|
+
if (!existsSync(normalized.options.outputPath)) {
|
|
194
|
+
mkdirSync(normalized.options.outputPath, { recursive: true });
|
|
195
195
|
}
|
|
196
196
|
let federationResult;
|
|
197
197
|
try {
|
|
198
|
-
|
|
199
|
-
federationResult = await buildForFederation(config, nfOptions, externals);
|
|
200
|
-
logger.measure(start, 'To build the artifacts.');
|
|
198
|
+
federationResult = await buildForFederation(normalized.config, normalized.options, externals);
|
|
201
199
|
}
|
|
202
200
|
catch (e) {
|
|
203
201
|
logger.error(e?.message ?? 'Building the artifacts failed');
|
|
204
202
|
process.exit(1);
|
|
205
203
|
}
|
|
206
204
|
if (activateSsr) {
|
|
207
|
-
writeFstartScript(
|
|
205
|
+
writeFstartScript(normalized.options);
|
|
208
206
|
}
|
|
209
207
|
const hasLocales = i18n?.locales && Object.keys(i18n.locales).length > 0;
|
|
210
208
|
if (hasLocales && localeFilter) {
|
|
@@ -212,16 +210,16 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
212
210
|
translateFederationArtifacts(i18n, localeFilter, outputOptions.base, federationResult);
|
|
213
211
|
logger.measure(start, 'To translate the artifacts.');
|
|
214
212
|
}
|
|
215
|
-
|
|
213
|
+
ngBuilderOptions.deleteOutputPath = false;
|
|
216
214
|
const appBuilderName = '@angular/build:application';
|
|
217
215
|
const builderRun = runServer
|
|
218
|
-
? serveWithVite(serverOptions, appBuilderName, createInternalAngularBuilder(
|
|
216
|
+
? serveWithVite(serverOptions, appBuilderName, createInternalAngularBuilder(normalized.options), context, nfBuilderOptions.skipHtmlTransform
|
|
219
217
|
? {}
|
|
220
218
|
: { indexHtml: transformIndexHtml(nfBuilderOptions) }, {
|
|
221
219
|
buildPlugins: plugins,
|
|
222
220
|
middleware,
|
|
223
221
|
})
|
|
224
|
-
: buildApplication(
|
|
222
|
+
: buildApplication(ngBuilderOptions, context, {
|
|
225
223
|
codePlugins: plugins,
|
|
226
224
|
indexHtmlTransformer: transformIndexHtml(nfBuilderOptions),
|
|
227
225
|
});
|
|
@@ -257,11 +255,10 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
257
255
|
if (signal?.aborted) {
|
|
258
256
|
throw new AbortedError('[builder] Before federation build.');
|
|
259
257
|
}
|
|
260
|
-
const start = process.hrtime();
|
|
261
258
|
// Todo: Invalidate all source files, Angular doesn't provide a way to give the invalidated files yet.
|
|
262
259
|
// ref: https://github.com/angular/angular-cli/pull/32527
|
|
263
|
-
const keys = [...
|
|
264
|
-
federationResult = await rebuildForFederation(config,
|
|
260
|
+
const keys = [...normalized.options.federationCache.bundlerCache.keys()].filter(k => !k.includes('node_modules'));
|
|
261
|
+
federationResult = await rebuildForFederation(normalized.config, normalized.options, externals, keys, signal);
|
|
265
262
|
if (signal?.aborted) {
|
|
266
263
|
throw new AbortedError('[builder] After federation build.');
|
|
267
264
|
}
|
|
@@ -275,7 +272,6 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
275
272
|
if (isLocalDevelopment) {
|
|
276
273
|
federationBuildNotifier.broadcastBuildCompletion();
|
|
277
274
|
}
|
|
278
|
-
logger.measure(start, 'To rebuild the federation artifacts.');
|
|
279
275
|
return { success: true };
|
|
280
276
|
}
|
|
281
277
|
catch (error) {
|
|
@@ -285,7 +281,7 @@ export async function* runBuilder(nfBuilderOptions, context) {
|
|
|
285
281
|
return { success: false, cancelled: true };
|
|
286
282
|
}
|
|
287
283
|
logger.error('Federation rebuild failed!');
|
|
288
|
-
if (
|
|
284
|
+
if (ngBuilderOptions.verbose)
|
|
289
285
|
console.error(error);
|
|
290
286
|
if (isLocalDevelopment) {
|
|
291
287
|
federationBuildNotifier.broadcastBuildError(error);
|
|
@@ -6,18 +6,16 @@ export interface NfBuilderSchema extends JsonObject {
|
|
|
6
6
|
target: string;
|
|
7
7
|
dev: boolean;
|
|
8
8
|
port: number;
|
|
9
|
-
open: boolean;
|
|
10
9
|
rebuildDelay: number;
|
|
11
10
|
buildNotifications?: BuildNotificationOptions;
|
|
12
|
-
shell: string;
|
|
13
11
|
watch: boolean;
|
|
14
12
|
skipHtmlTransform: boolean;
|
|
15
13
|
esmsInitOptions: ESMSInitOptions;
|
|
16
14
|
baseHref?: string;
|
|
17
15
|
outputPath?: string;
|
|
16
|
+
projectName?: string;
|
|
18
17
|
ssr: boolean;
|
|
19
18
|
devServer?: boolean;
|
|
20
|
-
|
|
21
|
-
entryPoint?: string;
|
|
19
|
+
entryPoints?: string[];
|
|
22
20
|
cacheExternalArtifacts?: boolean;
|
|
23
|
-
}
|
|
21
|
+
}
|
|
@@ -23,25 +23,14 @@
|
|
|
23
23
|
"type": "number",
|
|
24
24
|
"default": 0
|
|
25
25
|
},
|
|
26
|
-
"
|
|
27
|
-
"type": "
|
|
28
|
-
},
|
|
29
|
-
"open": {
|
|
30
|
-
"type": "boolean",
|
|
31
|
-
"default": true,
|
|
32
|
-
"description": "Open browser?",
|
|
33
|
-
"alias": "o"
|
|
26
|
+
"entryPoints": {
|
|
27
|
+
"type": "array"
|
|
34
28
|
},
|
|
35
29
|
"rebuildDelay": {
|
|
36
30
|
"type": "number",
|
|
37
31
|
"default": 2000,
|
|
38
32
|
"description": "The delay for rebuilding federation artifacts. This allows to have more resources for refreshing your micro frontend in the browser."
|
|
39
33
|
},
|
|
40
|
-
"shell": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"description": "Experimental",
|
|
43
|
-
"default": ""
|
|
44
|
-
},
|
|
45
34
|
"skipHtmlTransform": {
|
|
46
35
|
"type": "boolean",
|
|
47
36
|
"default": false
|
|
@@ -49,6 +38,9 @@
|
|
|
49
38
|
"baseHref": {
|
|
50
39
|
"type": "string"
|
|
51
40
|
},
|
|
41
|
+
"projectName": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
52
44
|
"outputPath": {
|
|
53
45
|
"type": "string"
|
|
54
46
|
},
|
|
@@ -70,22 +62,9 @@
|
|
|
70
62
|
},
|
|
71
63
|
"cacheExternalArtifacts": {
|
|
72
64
|
"type": "boolean",
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"type": "object",
|
|
77
|
-
"properties": {
|
|
78
|
-
"enable": {
|
|
79
|
-
"type": "boolean",
|
|
80
|
-
"default": true,
|
|
81
|
-
"description": "Enable chunking (code splitting)."
|
|
82
|
-
},
|
|
83
|
-
"dense": {
|
|
84
|
-
"type": "boolean",
|
|
85
|
-
"default": false,
|
|
86
|
-
"description": "Allows for a more compact remoteEntry.json."
|
|
87
|
-
}
|
|
88
|
-
}
|
|
65
|
+
"default": true,
|
|
66
|
+
"description": "Will cache the shared externals so they can be re-used between builds",
|
|
67
|
+
"alias": "cache"
|
|
89
68
|
},
|
|
90
69
|
"buildNotifications": {
|
|
91
70
|
"type": "object",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-skip-list.d.ts","sourceRoot":"","sources":["../../../src/config/angular-skip-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,mCAAmC,CAAC;AAErF,eAAO,MAAM,YAAY,EAAE,QAW1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DEFAULT_SKIP_LIST } from '@softarc/native-federation/config';
|
|
2
|
+
export const NG_SKIP_LIST = [
|
|
3
|
+
...DEFAULT_SKIP_LIST,
|
|
4
|
+
'@angular-architects/native-federation',
|
|
5
|
+
'zone.js',
|
|
6
|
+
'@angular/localize',
|
|
7
|
+
'@angular/localize/init',
|
|
8
|
+
'@angular/localize/tools',
|
|
9
|
+
'@angular/router/upgrade',
|
|
10
|
+
'@angular/common/upgrade',
|
|
11
|
+
/^@nx\/angular/,
|
|
12
|
+
pkg => pkg.startsWith('@angular/') && !!pkg.match(/\/testing(\/|$)/),
|
|
13
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ShareAllExternalsOptions, ShareExternalsOptions, SkipList, FederationConfig } from '@softarc/native-federation/domain';
|
|
2
|
+
export declare function shareAll(config: ShareAllExternalsOptions, opts?: {
|
|
3
|
+
skipList?: SkipList;
|
|
4
|
+
projectPath?: string;
|
|
5
|
+
overrides?: ShareExternalsOptions;
|
|
6
|
+
}): ShareExternalsOptions | null;
|
|
7
|
+
export declare function share(configuredShareObjects: ShareExternalsOptions, projectPath?: string, skipList?: SkipList): ShareExternalsOptions;
|
|
8
|
+
export declare function withNativeFederation(cfg: FederationConfig): import("@softarc/native-federation/internal").NormalizedFederationConfig;
|
|
9
|
+
//# sourceMappingURL=share-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-utils.d.ts","sourceRoot":"","sources":["../../../src/config/share-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAS3C,wBAAgB,QAAQ,CACtB,MAAM,EAAE,wBAAwB,EAChC,IAAI,GAAE;IACJ,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,qBAAqB,CAAC;CAC9B,GACL,qBAAqB,GAAG,IAAI,CAG9B;AAED,wBAAgB,KAAK,CACnB,sBAAsB,EAAE,qBAAqB,EAC7C,WAAW,SAAK,EAChB,QAAQ,WAAe,GACtB,qBAAqB,CAEvB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,4EAWzD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { share as coreShare, shareAll as coreShareAll, withNativeFederation as coreWithNativeFederation, } from '@softarc/native-federation/config';
|
|
2
|
+
import { NG_SKIP_LIST } from './angular-skip-list.js';
|
|
3
|
+
export function shareAll(config, opts = {}) {
|
|
4
|
+
if (!opts.skipList)
|
|
5
|
+
opts.skipList = NG_SKIP_LIST;
|
|
6
|
+
return coreShareAll(config, opts);
|
|
7
|
+
}
|
|
8
|
+
export function share(configuredShareObjects, projectPath = '', skipList = NG_SKIP_LIST) {
|
|
9
|
+
return coreShare(configuredShareObjects, projectPath, skipList);
|
|
10
|
+
}
|
|
11
|
+
export function withNativeFederation(cfg) {
|
|
12
|
+
if (!cfg.platform)
|
|
13
|
+
cfg.platform = getDefaultPlatform(Object.keys(cfg.shared ?? {}));
|
|
14
|
+
const normalized = coreWithNativeFederation(cfg);
|
|
15
|
+
// This is for being backwards compatible
|
|
16
|
+
if (!normalized.features.ignoreUnusedDeps) {
|
|
17
|
+
normalized.shared = removeNgLocales(normalized.shared);
|
|
18
|
+
}
|
|
19
|
+
return normalized;
|
|
20
|
+
}
|
|
21
|
+
function getDefaultPlatform(deps) {
|
|
22
|
+
const server = deps.find(e => ['@angular/platform-server', '@angular/ssr'].find(f => e.startsWith(f)));
|
|
23
|
+
return server ? 'node' : 'browser';
|
|
24
|
+
}
|
|
25
|
+
function removeNgLocales(shared) {
|
|
26
|
+
const keys = Object.keys(shared).filter(k => !k.startsWith('@angular/common/locales'));
|
|
27
|
+
const filtered = keys.reduce((acc, curr) => ({
|
|
28
|
+
...acc,
|
|
29
|
+
[curr]: shared[curr],
|
|
30
|
+
}), {});
|
|
31
|
+
return filtered;
|
|
32
|
+
}
|
package/src/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export { share, shareAll, withNativeFederation } from './config/share-utils.js';
|
|
2
|
+
export { NG_SKIP_LIST } from './config/angular-skip-list.js';
|
|
3
3
|
export { shareAngularLocales } from './utils/angular-locales.js';
|
|
4
4
|
//# sourceMappingURL=config.d.ts.map
|
package/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/src/config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export { share, shareAll, withNativeFederation } from './config/share-utils.js';
|
|
2
|
+
export { NG_SKIP_LIST } from './config/angular-skip-list.js';
|
|
3
3
|
export { shareAngularLocales } from './utils/angular-locales.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { withNativeFederation, shareAll } from '@angular-architects/native-federation-v4/config';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default withNativeFederation({
|
|
4
4
|
name: '<%=project%>',
|
|
5
5
|
|
|
6
6
|
<% if (type === 'remote') { %>
|
|
@@ -10,7 +10,18 @@ module.exports = withNativeFederation({
|
|
|
10
10
|
},
|
|
11
11
|
<% } %>
|
|
12
12
|
shared: {
|
|
13
|
-
...shareAll({
|
|
13
|
+
...shareAll({
|
|
14
|
+
singleton: true, strictVersion: true, requiredVersion: 'auto'
|
|
15
|
+
}, {
|
|
16
|
+
overrides: {
|
|
17
|
+
'@angular/core': {
|
|
18
|
+
singleton: true, strictVersion: true, requiredVersion: 'auto', build: 'package', chunks: true, includeSecondaries: {keepAll: true},
|
|
19
|
+
},
|
|
20
|
+
'@angular/common': {
|
|
21
|
+
singleton: true, strictVersion: true, requiredVersion: 'auto', build: 'package',chunks: true, includeSecondaries: {keepAll: true},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
14
25
|
},
|
|
15
26
|
|
|
16
27
|
skip: [
|
|
@@ -25,9 +36,10 @@ module.exports = withNativeFederation({
|
|
|
25
36
|
// https://shorturl.at/jmzH0
|
|
26
37
|
|
|
27
38
|
features: {
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
// ignoreUnusedDeps is enabled by default now
|
|
40
|
+
// ignoreUnusedDeps: true,
|
|
41
|
+
|
|
42
|
+
// Opt-in: groups chunks in remoteEntry.json for smaller metadata file
|
|
43
|
+
denseChunking: true
|
|
32
44
|
}
|
|
33
45
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "
|
|
3
|
+
"$id": "nf",
|
|
4
4
|
"title": "",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
7
|
"project": {
|
|
8
8
|
"type": "string",
|
|
9
|
-
"description": "The project to add
|
|
9
|
+
"description": "The project to add native-federation federation",
|
|
10
10
|
"$default": {
|
|
11
11
|
"$source": "argv",
|
|
12
12
|
"index": 0
|
|
@@ -25,10 +25,6 @@
|
|
|
25
25
|
"enum": ["host", "dynamic-host", "remote"],
|
|
26
26
|
"type": "string",
|
|
27
27
|
"default": "remote"
|
|
28
|
-
},
|
|
29
|
-
"nxBuilders": {
|
|
30
|
-
"type": "boolean",
|
|
31
|
-
"description": "Use builders provided by Nx instead of ngx-build-plus? Defaults to true for Nx workspaces and false for CLI workspaces."
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematic.d.ts","sourceRoot":"","sources":["../../../../src/schematics/init/schematic.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAET,KAAK,IAAI,EAEV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA+BrD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA0BlD;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"schematic.d.ts","sourceRoot":"","sources":["../../../../src/schematics/init/schematic.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAET,KAAK,IAAI,EAEV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA+BrD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA0BlD;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAwG/D;AAUD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,QAiB3C;AAkYD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAUvD"}
|