@angular-architects/native-federation-v4 20.3.4 → 20.3.7
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/README.md +7 -7
- package/migration-collection.json +1 -1
- package/package.json +3 -3
- package/src/builders/build/builder.d.ts +2 -1
- package/src/builders/build/builder.d.ts.map +1 -1
- package/src/builders/build/builder.js +117 -113
- package/src/builders/build/schema.d.ts +1 -0
- package/src/builders/build/schema.json +3 -0
- package/src/builders/build/setup-builder-env-variables.d.ts +2 -0
- package/src/builders/build/setup-builder-env-variables.d.ts.map +1 -0
- package/src/builders/build/setup-builder-env-variables.js +9 -0
- package/src/plugin/externals-skip-list.js +1 -1
- package/src/utils/angular-bundler.d.ts +12 -0
- package/src/utils/angular-bundler.d.ts.map +1 -0
- package/src/utils/angular-bundler.js +167 -0
- package/src/utils/angular-esbuild-adapter.d.ts +5 -5
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
- package/src/utils/angular-esbuild-adapter.js +81 -261
- package/src/utils/node-modules-bundler.d.ts +12 -0
- package/src/utils/node-modules-bundler.d.ts.map +1 -0
- package/src/utils/node-modules-bundler.js +101 -0
- package/src/utils/create-compiler-options.d.ts +0 -5
- package/src/utils/create-compiler-options.d.ts.map +0 -1
- package/src/utils/create-compiler-options.js +0 -42
- package/src/utils/event-source.d.ts +0 -10
- package/src/utils/event-source.d.ts.map +0 -1
- package/src/utils/event-source.js +0 -10
- package/src/utils/mem-resuts.d.ts +0 -29
- package/src/utils/mem-resuts.d.ts.map +0 -1
- package/src/utils/mem-resuts.js +0 -50
- package/src/utils/rebuild-events.d.ts +0 -8
- package/src/utils/rebuild-events.d.ts.map +0 -1
- package/src/utils/rebuild-events.js +0 -4
package/README.md
CHANGED
|
@@ -239,9 +239,9 @@ When bootstrapping the host (shell), Native Federation (`projects\shell\src\main
|
|
|
239
239
|
import { initFederation } from '@angular-architects/native-federation';
|
|
240
240
|
|
|
241
241
|
initFederation('/assets/federation.manifest.json')
|
|
242
|
-
.catch(
|
|
243
|
-
.then(
|
|
244
|
-
.catch(
|
|
242
|
+
.catch(err => console.error(err))
|
|
243
|
+
.then(_ => import('./bootstrap'))
|
|
244
|
+
.catch(err => console.error(err));
|
|
245
245
|
```
|
|
246
246
|
|
|
247
247
|
> This file is generated by the schematic described above.
|
|
@@ -270,9 +270,9 @@ When bootstrapping your remote (`projects\mfe1\src\main.ts`), Native Federation
|
|
|
270
270
|
import { initFederation } from '@angular-architects/native-federation';
|
|
271
271
|
|
|
272
272
|
initFederation()
|
|
273
|
-
.catch(
|
|
274
|
-
.then(
|
|
275
|
-
.catch(
|
|
273
|
+
.catch(err => console.error(err))
|
|
274
|
+
.then(_ => import('./bootstrap'))
|
|
275
|
+
.catch(err => console.error(err));
|
|
276
276
|
```
|
|
277
277
|
|
|
278
278
|
> Our `init` schematic shown above also generates this file.
|
|
@@ -301,7 +301,7 @@ export const APP_ROUTES: Routes = [
|
|
|
301
301
|
// Add this route:
|
|
302
302
|
{
|
|
303
303
|
path: 'flights',
|
|
304
|
-
loadComponent: () => loadRemoteModule('mfe1', './Component').then(
|
|
304
|
+
loadComponent: () => loadRemoteModule('mfe1', './Component').then(m => m.AppComponent),
|
|
305
305
|
},
|
|
306
306
|
|
|
307
307
|
{
|
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.7",
|
|
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-RC8",
|
|
14
|
+
"@softarc/native-federation-runtime": "4.0.0-RC8",
|
|
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,6 +1,7 @@
|
|
|
1
|
+
import './setup-builder-env-variables.js';
|
|
1
2
|
import { type BuilderContext, type BuilderOutput } from '@angular-devkit/architect';
|
|
2
3
|
import { type NfBuilderSchema } from './schema.js';
|
|
3
|
-
export declare function runBuilder(
|
|
4
|
+
export declare function runBuilder(nfBuilderOptions: NfBuilderSchema, context: BuilderContext): AsyncIterable<BuilderOutput>;
|
|
4
5
|
declare const _default: any;
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../src/builders/build/builder.ts"],"names":[],"mappings":"
|
|
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;AAgCnC,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,CAkY9B;wBA6C2C,GAAG;AAA/C,wBAAgD"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import './setup-builder-env-variables.js';
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
import * as mrmime from 'mrmime';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
import { buildApplication } from '@angular/build';
|
|
5
|
-
import { buildApplicationInternal, serveWithVite } from '@angular/build/private';
|
|
6
|
+
import { buildApplicationInternal, serveWithVite, SourceFileCache } from '@angular/build/private';
|
|
6
7
|
import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
|
|
7
8
|
import { normalizeOptions } from '@angular-devkit/build-angular/src/builders/dev-server/options.js';
|
|
8
|
-
import { buildForFederation, getExternals, loadFederationConfig, setBuildAdapter, } from '@softarc/native-federation';
|
|
9
|
-
import { logger, setLogLevel, RebuildQueue, AbortedError, } from '@softarc/native-federation/internal';
|
|
10
|
-
import { createAngularBuildAdapter
|
|
9
|
+
import { buildForFederation, rebuildForFederation, getExternals, loadFederationConfig, normalizeFederationOptions, setBuildAdapter, createFederationCache, } from '@softarc/native-federation';
|
|
10
|
+
import { logger, setLogLevel, RebuildQueue, AbortedError, getDefaultCachePath, } from '@softarc/native-federation/internal';
|
|
11
|
+
import { createAngularBuildAdapter } from '../../utils/angular-esbuild-adapter.js';
|
|
11
12
|
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
12
13
|
import { fstart } from '../../tools/fstart-as-data-url.js';
|
|
13
|
-
import { EsBuildResult, MemResults, NgCliAssetResult } from '../../utils/mem-resuts.js';
|
|
14
14
|
import { getI18nConfig, translateFederationArtifacts } from '../../utils/i18n.js';
|
|
15
|
-
import { RebuildHubs } from '../../utils/rebuild-events.js';
|
|
16
15
|
import { createSharedMappingsPlugin } from '../../utils/shared-mappings-plugin.js';
|
|
17
16
|
import { updateScriptTags } from '../../utils/updateIndexHtml.js';
|
|
18
17
|
import { federationBuildNotifier } from './federation-build-notifier.js';
|
|
@@ -27,7 +26,7 @@ process.stderr.write = function (chunk, encodingOrCallback, callback) {
|
|
|
27
26
|
}
|
|
28
27
|
return originalWrite(chunk, encodingOrCallback, callback);
|
|
29
28
|
};
|
|
30
|
-
|
|
29
|
+
const createInternalAngularBuilder = (_) => (options, context, pluginsOrExtensions) => {
|
|
31
30
|
let extensions;
|
|
32
31
|
if (pluginsOrExtensions && Array.isArray(pluginsOrExtensions)) {
|
|
33
32
|
extensions = {
|
|
@@ -37,10 +36,12 @@ function _buildApplication(options, context, pluginsOrExtensions) {
|
|
|
37
36
|
else {
|
|
38
37
|
extensions = pluginsOrExtensions;
|
|
39
38
|
}
|
|
39
|
+
// Todo: share cache with Angular builder: https://github.com/angular/angular-cli/pull/32527
|
|
40
|
+
// options.codeBundleCache = nfOptions.federationCache.bundlerCache;
|
|
40
41
|
return buildApplicationInternal(options, context, extensions);
|
|
41
|
-
}
|
|
42
|
-
export async function* runBuilder(
|
|
43
|
-
let target = targetFromTargetString(
|
|
42
|
+
};
|
|
43
|
+
export async function* runBuilder(nfBuilderOptions, context) {
|
|
44
|
+
let target = targetFromTargetString(nfBuilderOptions.target);
|
|
44
45
|
let targetOptions = (await context.getTargetOptions(target));
|
|
45
46
|
let builder = await context.getBuilderNameForTarget(target);
|
|
46
47
|
if (builder === '@angular-devkit/build-angular:browser-esbuild') {
|
|
@@ -66,18 +67,17 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
66
67
|
/**
|
|
67
68
|
* Explicitly defined as devServer or if the target contains "serve"
|
|
68
69
|
*/
|
|
69
|
-
const runServer = typeof
|
|
70
|
-
? !!
|
|
70
|
+
const runServer = typeof nfBuilderOptions.devServer !== 'undefined'
|
|
71
|
+
? !!nfBuilderOptions.devServer
|
|
71
72
|
: target.target.includes('serve');
|
|
72
73
|
let options = (await context.validateOptions(runServer
|
|
73
74
|
? {
|
|
74
75
|
...targetOptions,
|
|
75
|
-
port:
|
|
76
|
+
port: nfBuilderOptions.port || targetOptions['port'],
|
|
76
77
|
}
|
|
77
78
|
: targetOptions, builder));
|
|
78
79
|
let serverOptions = null;
|
|
79
|
-
const
|
|
80
|
-
const watch = nfOptions.watch;
|
|
80
|
+
const watch = nfBuilderOptions.watch;
|
|
81
81
|
if (options['buildTarget']) {
|
|
82
82
|
serverOptions = await normalizeOptions(context, context.target.project, options);
|
|
83
83
|
target = targetFromTargetString(options['buildTarget']);
|
|
@@ -86,14 +86,13 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
86
86
|
options = (await context.validateOptions(targetOptions, builder));
|
|
87
87
|
}
|
|
88
88
|
options.watch = watch;
|
|
89
|
-
if (
|
|
90
|
-
options.baseHref =
|
|
89
|
+
if (nfBuilderOptions.baseHref) {
|
|
90
|
+
options.baseHref = nfBuilderOptions.baseHref;
|
|
91
91
|
}
|
|
92
|
-
if (
|
|
93
|
-
options.outputPath =
|
|
92
|
+
if (nfBuilderOptions.outputPath) {
|
|
93
|
+
options.outputPath = nfBuilderOptions.outputPath;
|
|
94
94
|
}
|
|
95
|
-
const
|
|
96
|
-
const adapter = createAngularBuildAdapter(options, context, rebuildEvents);
|
|
95
|
+
const adapter = createAngularBuildAdapter(options, context);
|
|
97
96
|
setBuildAdapter(adapter);
|
|
98
97
|
setLogLevel(options.verbose ? 'verbose' : 'info');
|
|
99
98
|
if (!options.outputPath) {
|
|
@@ -117,23 +116,24 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
117
116
|
const devServerOutputPath = !differentDevServerOutputPath
|
|
118
117
|
? browserOutputPath
|
|
119
118
|
: path.join(outputOptions.base, outputOptions.browser, localeFilter[0]);
|
|
120
|
-
const entryPoint = path.join(path.dirname(options.tsConfig), 'src/main.ts');
|
|
121
|
-
const
|
|
119
|
+
const entryPoint = nfBuilderOptions.entryPoint ?? path.join(path.dirname(options.tsConfig), 'src/main.ts');
|
|
120
|
+
const cachePath = getDefaultCachePath(context.workspaceRoot);
|
|
121
|
+
const nfOptions = normalizeFederationOptions({
|
|
122
122
|
workspaceRoot: context.workspaceRoot,
|
|
123
123
|
outputPath: browserOutputPath,
|
|
124
124
|
federationConfig: inferConfigPath(options.tsConfig),
|
|
125
125
|
tsConfig: options.tsConfig,
|
|
126
126
|
verbose: options.verbose,
|
|
127
|
-
watch:
|
|
128
|
-
dev: !!
|
|
129
|
-
chunks: !
|
|
127
|
+
watch: options.watch,
|
|
128
|
+
dev: !!nfBuilderOptions.dev,
|
|
129
|
+
chunks: !nfBuilderOptions.chunks ? false : nfBuilderOptions.chunks,
|
|
130
130
|
entryPoint,
|
|
131
|
-
buildNotifications:
|
|
132
|
-
cacheExternalArtifacts:
|
|
133
|
-
};
|
|
134
|
-
const activateSsr =
|
|
131
|
+
buildNotifications: nfBuilderOptions.buildNotifications,
|
|
132
|
+
cacheExternalArtifacts: nfBuilderOptions.cacheExternalArtifacts,
|
|
133
|
+
}, createFederationCache(cachePath, new SourceFileCache(cachePath)));
|
|
134
|
+
const activateSsr = nfBuilderOptions.ssr && !nfBuilderOptions.dev;
|
|
135
135
|
const start = process.hrtime();
|
|
136
|
-
const config = await loadFederationConfig(
|
|
136
|
+
const config = await loadFederationConfig(nfOptions);
|
|
137
137
|
logger.measure(start, 'To load the federation config.');
|
|
138
138
|
const externals = getExternals(config);
|
|
139
139
|
const plugins = [
|
|
@@ -151,10 +151,10 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
151
151
|
if (activateSsr) {
|
|
152
152
|
options.externalDependencies = externals;
|
|
153
153
|
}
|
|
154
|
-
const isLocalDevelopment = runServer &&
|
|
154
|
+
const isLocalDevelopment = runServer && nfBuilderOptions.dev;
|
|
155
155
|
// Initialize SSE reloader only for local development
|
|
156
|
-
if (isLocalDevelopment &&
|
|
157
|
-
federationBuildNotifier.initialize(
|
|
156
|
+
if (isLocalDevelopment && nfBuilderOptions.buildNotifications?.enable) {
|
|
157
|
+
federationBuildNotifier.initialize(nfBuilderOptions.buildNotifications.endpoint);
|
|
158
158
|
}
|
|
159
159
|
const middleware = [
|
|
160
160
|
...(isLocalDevelopment
|
|
@@ -164,7 +164,7 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
164
164
|
: []),
|
|
165
165
|
(req, res, next) => {
|
|
166
166
|
const url = removeBaseHref(req, options.baseHref);
|
|
167
|
-
const fileName = path.join(
|
|
167
|
+
const fileName = path.join(nfOptions.workspaceRoot, devServerOutputPath, url);
|
|
168
168
|
const exists = fs.existsSync(fileName);
|
|
169
169
|
if (url !== '/' && url !== '' && exists) {
|
|
170
170
|
const lookup = mrmime.lookup;
|
|
@@ -186,26 +186,17 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
];
|
|
189
|
-
const memResults = new MemResults();
|
|
190
189
|
let first = true;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
rmSync(fedOptions.outputPath, { recursive: true });
|
|
190
|
+
if (existsSync(nfOptions.outputPath)) {
|
|
191
|
+
rmSync(nfOptions.outputPath, { recursive: true });
|
|
194
192
|
}
|
|
195
|
-
if (!existsSync(
|
|
196
|
-
mkdirSync(
|
|
197
|
-
}
|
|
198
|
-
if (!write) {
|
|
199
|
-
// todo: Hardcoded disabled?
|
|
200
|
-
setMemResultHandler((outFiles, outDir) => {
|
|
201
|
-
const fullOutDir = outDir ? path.join(fedOptions.workspaceRoot, outDir) : undefined;
|
|
202
|
-
memResults.add(outFiles.map(f => new EsBuildResult(f, fullOutDir)));
|
|
203
|
-
});
|
|
193
|
+
if (!existsSync(nfOptions.outputPath)) {
|
|
194
|
+
mkdirSync(nfOptions.outputPath, { recursive: true });
|
|
204
195
|
}
|
|
205
196
|
let federationResult;
|
|
206
197
|
try {
|
|
207
198
|
const start = process.hrtime();
|
|
208
|
-
federationResult = await buildForFederation(config,
|
|
199
|
+
federationResult = await buildForFederation(config, nfOptions, externals);
|
|
209
200
|
logger.measure(start, 'To build the artifacts.');
|
|
210
201
|
}
|
|
211
202
|
catch (e) {
|
|
@@ -213,7 +204,7 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
213
204
|
process.exit(1);
|
|
214
205
|
}
|
|
215
206
|
if (activateSsr) {
|
|
216
|
-
writeFstartScript(
|
|
207
|
+
writeFstartScript(nfOptions);
|
|
217
208
|
}
|
|
218
209
|
const hasLocales = i18n?.locales && Object.keys(i18n.locales).length > 0;
|
|
219
210
|
if (hasLocales && localeFilter) {
|
|
@@ -224,95 +215,108 @@ export async function* runBuilder(nfOptions, context) {
|
|
|
224
215
|
options.deleteOutputPath = false;
|
|
225
216
|
const appBuilderName = '@angular/build:application';
|
|
226
217
|
const builderRun = runServer
|
|
227
|
-
? serveWithVite(serverOptions, appBuilderName,
|
|
218
|
+
? serveWithVite(serverOptions, appBuilderName, createInternalAngularBuilder(nfOptions), context, nfBuilderOptions.skipHtmlTransform
|
|
219
|
+
? {}
|
|
220
|
+
: { indexHtml: transformIndexHtml(nfBuilderOptions) }, {
|
|
228
221
|
buildPlugins: plugins,
|
|
229
222
|
middleware,
|
|
230
223
|
})
|
|
231
224
|
: buildApplication(options, context, {
|
|
232
225
|
codePlugins: plugins,
|
|
233
|
-
indexHtmlTransformer: transformIndexHtml(
|
|
226
|
+
indexHtmlTransformer: transformIndexHtml(nfBuilderOptions),
|
|
234
227
|
});
|
|
235
228
|
const rebuildQueue = new RebuildQueue();
|
|
229
|
+
const builderIterator = builderRun[Symbol.asyncIterator]();
|
|
230
|
+
let ngBuildStatus = { success: false };
|
|
236
231
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
232
|
+
let buildResult = await builderIterator.next();
|
|
233
|
+
while (!buildResult.done) {
|
|
234
|
+
if (buildResult.value)
|
|
235
|
+
ngBuildStatus = buildResult.value;
|
|
236
|
+
if (!ngBuildStatus.success) {
|
|
237
|
+
logger.warn('Skipping federation artifacts because Angular build failed.');
|
|
238
|
+
buildResult = await builderIterator.next();
|
|
244
239
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (!first && (nfOptions.dev || watch)) {
|
|
252
|
-
rebuildQueue
|
|
253
|
-
.enqueue(async (signal) => {
|
|
254
|
-
if (signal?.aborted) {
|
|
255
|
-
throw new AbortedError('Build canceled before starting');
|
|
256
|
-
}
|
|
257
|
-
await new Promise((resolve, reject) => {
|
|
258
|
-
const timeout = setTimeout(resolve, Math.max(10, nfOptions.rebuildDelay));
|
|
259
|
-
if (signal) {
|
|
260
|
-
const abortHandler = () => {
|
|
261
|
-
clearTimeout(timeout);
|
|
262
|
-
reject(new AbortedError('[builder] During delay.'));
|
|
263
|
-
};
|
|
264
|
-
signal.addEventListener('abort', abortHandler, { once: true });
|
|
240
|
+
else if (!first && (nfBuilderOptions.dev || watch)) {
|
|
241
|
+
const nextOutputPromise = builderIterator.next();
|
|
242
|
+
const trackResult = await rebuildQueue.track(async (signal) => {
|
|
243
|
+
try {
|
|
244
|
+
if (signal?.aborted) {
|
|
245
|
+
throw new AbortedError('Build canceled before starting');
|
|
265
246
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
logger.
|
|
294
|
-
|
|
247
|
+
await new Promise((resolve, reject) => {
|
|
248
|
+
const timeout = setTimeout(resolve, Math.max(10, nfBuilderOptions.rebuildDelay));
|
|
249
|
+
if (signal) {
|
|
250
|
+
const abortHandler = () => {
|
|
251
|
+
clearTimeout(timeout);
|
|
252
|
+
reject(new AbortedError('[builder] During delay.'));
|
|
253
|
+
};
|
|
254
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
if (signal?.aborted) {
|
|
258
|
+
throw new AbortedError('[builder] Before federation build.');
|
|
259
|
+
}
|
|
260
|
+
const start = process.hrtime();
|
|
261
|
+
// Todo: Invalidate all source files, Angular doesn't provide a way to give the invalidated files yet.
|
|
262
|
+
// ref: https://github.com/angular/angular-cli/pull/32527
|
|
263
|
+
const keys = [...nfOptions.federationCache.bundlerCache.keys()].filter(k => !k.includes('node_modules'));
|
|
264
|
+
federationResult = await rebuildForFederation(config, nfOptions, externals, keys, signal);
|
|
265
|
+
if (signal?.aborted) {
|
|
266
|
+
throw new AbortedError('[builder] After federation build.');
|
|
267
|
+
}
|
|
268
|
+
if (hasLocales && localeFilter) {
|
|
269
|
+
translateFederationArtifacts(i18n, localeFilter, outputOptions.base, federationResult);
|
|
270
|
+
}
|
|
271
|
+
if (signal?.aborted) {
|
|
272
|
+
throw new AbortedError('[builder] After federation translations.');
|
|
273
|
+
}
|
|
274
|
+
logger.info('Done!');
|
|
275
|
+
if (isLocalDevelopment) {
|
|
276
|
+
federationBuildNotifier.broadcastBuildCompletion();
|
|
277
|
+
}
|
|
278
|
+
logger.measure(start, 'To rebuild the federation artifacts.');
|
|
279
|
+
return { success: true };
|
|
295
280
|
}
|
|
296
|
-
|
|
281
|
+
catch (error) {
|
|
282
|
+
if (error instanceof AbortedError) {
|
|
283
|
+
logger.verbose('Rebuild was canceled. Cancellation point: ' + error?.message);
|
|
284
|
+
federationBuildNotifier.broadcastBuildCancellation();
|
|
285
|
+
return { success: false, cancelled: true };
|
|
286
|
+
}
|
|
297
287
|
logger.error('Federation rebuild failed!');
|
|
298
288
|
if (options.verbose)
|
|
299
289
|
console.error(error);
|
|
300
290
|
if (isLocalDevelopment) {
|
|
301
291
|
federationBuildNotifier.broadcastBuildError(error);
|
|
302
292
|
}
|
|
293
|
+
return { success: false };
|
|
303
294
|
}
|
|
304
|
-
});
|
|
295
|
+
}, nextOutputPromise);
|
|
296
|
+
if (trackResult.type === 'completed') {
|
|
297
|
+
if (!trackResult.result.cancelled) {
|
|
298
|
+
yield { success: trackResult.result.success };
|
|
299
|
+
}
|
|
300
|
+
buildResult = await nextOutputPromise;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
buildResult = trackResult.value;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
buildResult = await builderIterator.next();
|
|
305
308
|
}
|
|
306
309
|
first = false;
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
finally {
|
|
310
313
|
rebuildQueue.dispose();
|
|
314
|
+
await adapter.dispose();
|
|
311
315
|
if (isLocalDevelopment) {
|
|
312
316
|
federationBuildNotifier.stopEventServer();
|
|
313
317
|
}
|
|
314
318
|
}
|
|
315
|
-
yield
|
|
319
|
+
yield ngBuildStatus;
|
|
316
320
|
}
|
|
317
321
|
function removeBaseHref(req, baseHref) {
|
|
318
322
|
let url = req.url ?? '';
|
|
@@ -321,8 +325,8 @@ function removeBaseHref(req, baseHref) {
|
|
|
321
325
|
}
|
|
322
326
|
return url;
|
|
323
327
|
}
|
|
324
|
-
function writeFstartScript(
|
|
325
|
-
const serverOutpath = path.join(
|
|
328
|
+
function writeFstartScript(nfOptions) {
|
|
329
|
+
const serverOutpath = path.join(nfOptions.outputPath, '../server');
|
|
326
330
|
const fstartPath = path.join(serverOutpath, 'fstart.mjs');
|
|
327
331
|
const buffer = Buffer.from(fstart, 'base64');
|
|
328
332
|
fs.mkdirSync(serverOutpath, { recursive: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-builder-env-variables.d.ts","sourceRoot":"","sources":["../../../../src/builders/build/setup-builder-env-variables.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disables Angular's parallel caching and allows for
|
|
3
|
+
* a shared cache between the compilation steps which
|
|
4
|
+
* improves performance dramatically.
|
|
5
|
+
*/
|
|
6
|
+
if (!process.env['NG_BUILD_PARALLEL_TS']) {
|
|
7
|
+
process.env['NG_BUILD_PARALLEL_TS'] = '0';
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import { type SourceFileCache } from '@angular/build/private';
|
|
3
|
+
import type { BuilderContext } from '@angular-devkit/architect';
|
|
4
|
+
import type { ApplicationBuilderOptions } from '@angular/build';
|
|
5
|
+
import type { EntryPoint, FederationCache } from '@softarc/native-federation';
|
|
6
|
+
import type { MappedPath } from '@softarc/native-federation/internal';
|
|
7
|
+
export interface AngularBundleResult {
|
|
8
|
+
ctx: esbuild.BuildContext;
|
|
9
|
+
pluginDisposed: Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createAngularEsbuildContext(builderOptions: ApplicationBuilderOptions, context: BuilderContext, entryPoints: EntryPoint[], external: string[], outdir: string, tsConfigPath: string, mappedPaths: MappedPath[], cache: FederationCache<SourceFileCache>, dev?: boolean, hash?: boolean, chunks?: boolean, platform?: 'browser' | 'node', optimizedMappings?: boolean): Promise<AngularBundleResult>;
|
|
12
|
+
//# sourceMappingURL=angular-bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-bundler.d.ts","sourceRoot":"","sources":["../../../src/utils/angular-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAOnC,OAAO,EAML,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAOhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAOtE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,wBAAsB,2BAA2B,CAC/C,cAAc,EAAE,yBAAyB,EACzC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,UAAU,EAAE,EACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,UAAU,EAAE,EACzB,KAAK,EAAE,eAAe,CAAC,eAAe,CAAC,EACvC,GAAG,CAAC,EAAE,OAAO,EACb,IAAI,GAAE,OAAe,EACrB,MAAM,CAAC,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,EAC7B,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAkI9B"}
|