@angular-architects/native-federation-v4 20.3.1 → 20.3.4
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/package.json +3 -3
- package/src/builders/build/builder.d.ts.map +1 -1
- package/src/builders/build/builder.js +4 -3
- package/src/builders/build/schema.d.ts +1 -0
- package/src/builders/build/schema.json +20 -1
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
- package/src/utils/angular-esbuild-adapter.js +4 -4
- package/src/utils/i18n.d.ts +1 -1
- package/src/utils/i18n.d.ts.map +1 -1
- package/src/utils/i18n.js +3 -2
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.4",
|
|
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-RC5",
|
|
14
|
+
"@softarc/native-federation-runtime": "4.0.0-RC5",
|
|
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":"AAOA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAGnB,MAAM,2BAA2B,CAAC;AAkCnC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAsCnD,wBAAuB,UAAU,CAC/B,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,cAAc,GACtB,aAAa,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../src/builders/build/builder.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAGnB,MAAM,2BAA2B,CAAC;AAkCnC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAsCnD,wBAAuB,UAAU,CAC/B,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,cAAc,GACtB,aAAa,CAAC,aAAa,CAAC,CA+X9B;wBA6C2C,GAAG;AAA/C,wBAAgD"}
|
|
@@ -11,7 +11,7 @@ import { createAngularBuildAdapter, setMemResultHandler, } from '../../utils/ang
|
|
|
11
11
|
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
12
12
|
import { fstart } from '../../tools/fstart-as-data-url.js';
|
|
13
13
|
import { EsBuildResult, MemResults, NgCliAssetResult } from '../../utils/mem-resuts.js';
|
|
14
|
-
import { getI18nConfig,
|
|
14
|
+
import { getI18nConfig, translateFederationArtifacts } from '../../utils/i18n.js';
|
|
15
15
|
import { RebuildHubs } from '../../utils/rebuild-events.js';
|
|
16
16
|
import { createSharedMappingsPlugin } from '../../utils/shared-mappings-plugin.js';
|
|
17
17
|
import { updateScriptTags } from '../../utils/updateIndexHtml.js';
|
|
@@ -126,6 +126,7 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
126
126
|
verbose: options.verbose,
|
|
127
127
|
watch: false, // options.watch,
|
|
128
128
|
dev: !!nfOptions.dev,
|
|
129
|
+
chunks: !nfOptions.chunks ? false : nfOptions.chunks,
|
|
129
130
|
entryPoint,
|
|
130
131
|
buildNotifications: nfOptions.buildNotifications,
|
|
131
132
|
cacheExternalArtifacts: nfOptions.cacheExternalArtifacts,
|
|
@@ -217,7 +218,7 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
217
218
|
const hasLocales = i18n?.locales && Object.keys(i18n.locales).length > 0;
|
|
218
219
|
if (hasLocales && localeFilter) {
|
|
219
220
|
const start = process.hrtime();
|
|
220
|
-
|
|
221
|
+
translateFederationArtifacts(i18n, localeFilter, outputOptions.base, federationResult);
|
|
221
222
|
logger.measure(start, 'To translate the artifacts.');
|
|
222
223
|
}
|
|
223
224
|
options.deleteOutputPath = false;
|
|
@@ -276,7 +277,7 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
276
277
|
throw new AbortedError('[builder] After federation build.');
|
|
277
278
|
}
|
|
278
279
|
if (hasLocales && localeFilter) {
|
|
279
|
-
|
|
280
|
+
translateFederationArtifacts(i18n, localeFilter, outputOptions.base, federationResult);
|
|
280
281
|
}
|
|
281
282
|
if (signal?.aborted) {
|
|
282
283
|
throw new AbortedError('[builder] After federation translations.');
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"rebuildDelay": {
|
|
33
33
|
"type": "number",
|
|
34
34
|
"default": 2000,
|
|
35
|
-
"description": "The delay for rebuilding federation
|
|
35
|
+
"description": "The delay for rebuilding federation artifacts. This allows to have more resources for refreshing your micro frontend in the browser."
|
|
36
36
|
},
|
|
37
37
|
"shell": {
|
|
38
38
|
"type": "string",
|
|
@@ -65,6 +65,25 @@
|
|
|
65
65
|
"type": "boolean",
|
|
66
66
|
"description": "can be used to disable the dev server when dev=true"
|
|
67
67
|
},
|
|
68
|
+
"cacheExternalArtifacts": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "Will cache the shared externals so they can be re-used between builds"
|
|
71
|
+
},
|
|
72
|
+
"chunks": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"enable": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"default": true,
|
|
78
|
+
"description": "Enable chunking (code splitting)."
|
|
79
|
+
},
|
|
80
|
+
"dense": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false,
|
|
83
|
+
"description": "Allows for a more compact remoteEntry.json."
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
68
87
|
"buildNotifications": {
|
|
69
88
|
"type": "object",
|
|
70
89
|
"properties": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-esbuild-adapter.d.ts","sourceRoot":"","sources":["../../../src/utils/angular-esbuild-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAWnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAMtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAKzF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEnE;AAED,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,yBAAyB,EACzC,OAAO,EAAE,cAAc,EACvB,gBAAgB,GAAE,aAAiC,GAClD,cAAc,
|
|
1
|
+
{"version":3,"file":"angular-esbuild-adapter.d.ts","sourceRoot":"","sources":["../../../src/utils/angular-esbuild-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAWnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAMtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAKzF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEnE;AAED,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,yBAAyB,EACzC,OAAO,EAAE,cAAc,EACvB,gBAAgB,GAAE,aAAiC,GAClD,cAAc,CA2FhB;AAkSD,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAErE"}
|
|
@@ -19,9 +19,9 @@ export function setMemResultHandler(handler) {
|
|
|
19
19
|
}
|
|
20
20
|
export function createAngularBuildAdapter(builderOptions, context, rebuildRequested = new RebuildHubs()) {
|
|
21
21
|
return async (options) => {
|
|
22
|
-
const { entryPoints, tsConfigPath, external, outdir, mappedPaths, kind, watch, dev, hash, platform, optimizedMappings, signal, } = options;
|
|
22
|
+
const { entryPoints, tsConfigPath, external, outdir, mappedPaths, kind, watch, dev, hash, chunks, platform, optimizedMappings, signal, } = options;
|
|
23
23
|
setNgServerMode();
|
|
24
|
-
const files = await runEsbuild(builderOptions, context, entryPoints, external, outdir, tsConfigPath, mappedPaths, watch, rebuildRequested, dev, kind, hash, undefined, undefined, undefined, platform, optimizedMappings, signal);
|
|
24
|
+
const files = await runEsbuild(builderOptions, context, entryPoints, external, outdir, tsConfigPath, mappedPaths, watch, rebuildRequested, dev, kind, chunks, hash, undefined, undefined, undefined, platform, optimizedMappings, signal);
|
|
25
25
|
if (kind === 'shared-package') {
|
|
26
26
|
const scriptFiles = files.filter(f => f.endsWith('.js') || f.endsWith('.mjs'));
|
|
27
27
|
for (const file of scriptFiles) {
|
|
@@ -62,7 +62,7 @@ export function createAngularBuildAdapter(builderOptions, context, rebuildReques
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async function runEsbuild(builderOptions, context, entryPoints, external, outdir, tsConfigPath, mappedPaths, watch, rebuildRequested = new RebuildHubs(), dev, kind, hash = false, plugins = null, absWorkingDir = undefined, logLevel = 'warning', platform, optimizedMappings, signal) {
|
|
65
|
+
async function runEsbuild(builderOptions, context, entryPoints, external, outdir, tsConfigPath, mappedPaths, watch, rebuildRequested = new RebuildHubs(), dev, kind, chunks, hash = false, plugins = null, absWorkingDir = undefined, logLevel = 'warning', platform, optimizedMappings, signal) {
|
|
66
66
|
if (signal?.aborted) {
|
|
67
67
|
throw new AbortedError('[angular-esbuild-adapter] Before building');
|
|
68
68
|
}
|
|
@@ -130,7 +130,7 @@ async function runEsbuild(builderOptions, context, entryPoints, external, outdir
|
|
|
130
130
|
'async-await': false,
|
|
131
131
|
'object-rest-spread': false,
|
|
132
132
|
},
|
|
133
|
-
splitting:
|
|
133
|
+
splitting: chunks, //kind === 'mapping-or-exposed',
|
|
134
134
|
platform: platform ?? 'browser',
|
|
135
135
|
format: 'esm',
|
|
136
136
|
target: target,
|
package/src/utils/i18n.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export type SourceLocaleObject = {
|
|
|
19
19
|
subPath?: string;
|
|
20
20
|
};
|
|
21
21
|
export declare function getI18nConfig(context: BuilderContext): Promise<I18nConfig | undefined>;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function translateFederationArtifacts(i18n: I18nConfig, localize: boolean | string[], outputPath: string, federationResult: FederationInfo): Promise<void>;
|
|
23
23
|
//# sourceMappingURL=i18n.d.ts.map
|
package/src/utils/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,MAAM,eAAe,GAAG;IAC5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,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAO5F;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,EAC5B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,cAAc,iBAiDjC"}
|
package/src/utils/i18n.js
CHANGED
|
@@ -7,7 +7,7 @@ export async function getI18nConfig(context) {
|
|
|
7
7
|
const i18nConfig = workspaceConfig?.i18n;
|
|
8
8
|
return i18nConfig;
|
|
9
9
|
}
|
|
10
|
-
export async function
|
|
10
|
+
export async function translateFederationArtifacts(i18n, localize, outputPath, federationResult) {
|
|
11
11
|
const neededLocales = Array.isArray(localize) ? localize : Object.keys(i18n.locales);
|
|
12
12
|
const locales = Object.keys(i18n.locales).filter(locale => neededLocales.includes(locale));
|
|
13
13
|
if (locales.length === 0) {
|
|
@@ -25,13 +25,14 @@ export async function translateFederationArtefacts(i18n, localize, outputPath, f
|
|
|
25
25
|
const federationFiles = [
|
|
26
26
|
...federationResult.shared.map(s => s.outFileName),
|
|
27
27
|
...federationResult.exposes.map(e => e.outFileName),
|
|
28
|
+
...Object.values(federationResult.chunks ?? {}).flat(),
|
|
28
29
|
];
|
|
29
30
|
// Here, we use a glob with an exhaustive list i/o `"*.js"`
|
|
30
31
|
// to improve performance
|
|
31
32
|
const sourcePattern = '{' + federationFiles.join(',') + '}';
|
|
32
33
|
const sourceLocalePath = path.join(outputPath, 'browser', sourceLocale);
|
|
33
34
|
const localizeTranslate = path.resolve('node_modules/.bin/localize-translate');
|
|
34
|
-
const cmd =
|
|
35
|
+
const cmd = `"${localizeTranslate}" -r "${sourceLocalePath}" -s "${sourcePattern}" -t ${translationFiles} -o "${translationOutPath}" --target-locales ${targetLocales} -l ${sourceLocale}`;
|
|
35
36
|
ensureDistFolders(locales, outputPath);
|
|
36
37
|
copyRemoteEntry(locales, outputPath, sourceLocalePath);
|
|
37
38
|
logger.debug('Running: ' + cmd);
|