@angular-architects/native-federation-v4 21.1.4 → 21.1.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.
Files changed (33) hide show
  1. package/README.md +7 -7
  2. package/migration-collection.json +1 -1
  3. package/package.json +16 -8
  4. package/src/builders/build/builder.d.ts +2 -1
  5. package/src/builders/build/builder.d.ts.map +1 -1
  6. package/src/builders/build/builder.js +117 -113
  7. package/src/builders/build/schema.d.ts +1 -0
  8. package/src/builders/build/schema.json +3 -0
  9. package/src/builders/build/setup-builder-env-variables.d.ts +2 -0
  10. package/src/builders/build/setup-builder-env-variables.d.ts.map +1 -0
  11. package/src/builders/build/setup-builder-env-variables.js +9 -0
  12. package/src/plugin/externals-skip-list.js +1 -1
  13. package/src/utils/angular-bundler.d.ts +12 -0
  14. package/src/utils/angular-bundler.d.ts.map +1 -0
  15. package/src/utils/angular-bundler.js +167 -0
  16. package/src/utils/angular-esbuild-adapter.d.ts +5 -5
  17. package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
  18. package/src/utils/angular-esbuild-adapter.js +81 -261
  19. package/src/utils/node-modules-bundler.d.ts +12 -0
  20. package/src/utils/node-modules-bundler.d.ts.map +1 -0
  21. package/src/utils/node-modules-bundler.js +113 -0
  22. package/src/utils/create-compiler-options.d.ts +0 -5
  23. package/src/utils/create-compiler-options.d.ts.map +0 -1
  24. package/src/utils/create-compiler-options.js +0 -42
  25. package/src/utils/event-source.d.ts +0 -10
  26. package/src/utils/event-source.d.ts.map +0 -1
  27. package/src/utils/event-source.js +0 -10
  28. package/src/utils/mem-resuts.d.ts +0 -29
  29. package/src/utils/mem-resuts.d.ts.map +0 -1
  30. package/src/utils/mem-resuts.js +0 -50
  31. package/src/utils/rebuild-events.d.ts +0 -8
  32. package/src/utils/rebuild-events.d.ts.map +0 -1
  33. 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((err) => console.error(err))
243
- .then((_) => import('./bootstrap'))
244
- .catch((err) => console.error(err));
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((err) => console.error(err))
274
- .then((_) => import('./bootstrap'))
275
- .catch((err) => console.error(err));
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((m) => m.AppComponent),
304
+ loadComponent: () => loadRemoteModule('mfe1', './Component').then(m => m.AppComponent),
305
305
  },
306
306
 
307
307
  {
@@ -10,4 +10,4 @@
10
10
  "description": "migrating to v18"
11
11
  }
12
12
  }
13
- }
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-architects/native-federation-v4",
3
- "version": "21.1.4",
3
+ "version": "21.1.7",
4
4
  "generators": "./collection.json",
5
5
  "builders": "./builders.json",
6
6
  "schematics": "./collection.json",
@@ -9,14 +9,22 @@
9
9
  "name": "Manfred Steyer",
10
10
  "url": "http://www.angulararchitects.io"
11
11
  },
12
+ "peerDependencies": {
13
+ "@softarc/native-federation": "^4.0.0-RC8",
14
+ "@softarc/native-federation-runtime": "^4.0.0-RC8",
15
+ "@angular-devkit/architect": ">=0.2102.0",
16
+ "@angular-devkit/build-angular": ">=21.2.0",
17
+ "@angular-devkit/core": ">=21.2.0",
18
+ "@angular/build": ">=21.2.0"
19
+ },
12
20
  "dependencies": {
13
- "@softarc/native-federation": "4.0.0-RC5",
14
- "@softarc/native-federation-runtime": "4.0.0-RC5",
15
- "@angular-devkit/architect": "^0.2101.2",
16
- "@angular-devkit/build-angular": "^21.1.2",
17
- "@angular-devkit/core": "^21.1.2",
18
- "@angular-devkit/schematics": "^21.1.2",
19
- "@angular/build": "^21.1.2",
21
+ "@softarc/native-federation": "4.0.0-RC8",
22
+ "@softarc/native-federation-runtime": "4.0.0-RC8",
23
+ "@angular-devkit/architect": "^0.2102.0",
24
+ "@angular-devkit/build-angular": "^21.2.0",
25
+ "@angular-devkit/core": "^21.2.0",
26
+ "@angular-devkit/schematics": "^21.2.0",
27
+ "@angular/build": "^21.2.0",
20
28
  "@chialab/esbuild-plugin-commonjs": "^0.19.0"
21
29
  },
22
30
  "repository": {
@@ -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(nfOptions: NfBuilderSchema, context: BuilderContext): AsyncIterable<BuilderOutput>;
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":"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"}
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, setMemResultHandler, } from '../../utils/angular-esbuild-adapter.js';
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
- function _buildApplication(options, context, pluginsOrExtensions) {
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(nfOptions, context) {
43
- let target = targetFromTargetString(nfOptions.target);
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 nfOptions.devServer !== 'undefined'
70
- ? !!nfOptions.devServer
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: nfOptions.port || targetOptions['port'],
76
+ port: nfBuilderOptions.port || targetOptions['port'],
76
77
  }
77
78
  : targetOptions, builder));
78
79
  let serverOptions = null;
79
- const write = true;
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 (nfOptions.baseHref) {
90
- options.baseHref = nfOptions.baseHref;
89
+ if (nfBuilderOptions.baseHref) {
90
+ options.baseHref = nfBuilderOptions.baseHref;
91
91
  }
92
- if (nfOptions.outputPath) {
93
- options.outputPath = nfOptions.outputPath;
92
+ if (nfBuilderOptions.outputPath) {
93
+ options.outputPath = nfBuilderOptions.outputPath;
94
94
  }
95
- const rebuildEvents = new RebuildHubs();
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 fedOptions = {
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: false, // options.watch,
128
- dev: !!nfOptions.dev,
129
- chunks: !nfOptions.chunks ? false : nfOptions.chunks,
127
+ watch: options.watch,
128
+ dev: !!nfBuilderOptions.dev,
129
+ chunks: !nfBuilderOptions.chunks ? false : nfBuilderOptions.chunks,
130
130
  entryPoint,
131
- buildNotifications: nfOptions.buildNotifications,
132
- cacheExternalArtifacts: nfOptions.cacheExternalArtifacts,
133
- };
134
- const activateSsr = nfOptions.ssr && !nfOptions.dev;
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(fedOptions);
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 && nfOptions.dev;
154
+ const isLocalDevelopment = runServer && nfBuilderOptions.dev;
155
155
  // Initialize SSE reloader only for local development
156
- if (isLocalDevelopment && nfOptions.buildNotifications?.enable) {
157
- federationBuildNotifier.initialize(nfOptions.buildNotifications.endpoint);
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(fedOptions.workspaceRoot, devServerOutputPath, url);
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
- let lastResult;
192
- if (existsSync(fedOptions.outputPath)) {
193
- rmSync(fedOptions.outputPath, { recursive: true });
190
+ if (existsSync(nfOptions.outputPath)) {
191
+ rmSync(nfOptions.outputPath, { recursive: true });
194
192
  }
195
- if (!existsSync(fedOptions.outputPath)) {
196
- mkdirSync(fedOptions.outputPath, { recursive: true });
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, fedOptions, externals);
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(fedOptions);
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, _buildApplication, context, nfOptions.skipHtmlTransform ? {} : { indexHtml: transformIndexHtml(nfOptions) }, {
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(nfOptions),
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
- for await (const output of builderRun) {
238
- lastResult = output;
239
- if (!write && output['outputFiles']) {
240
- memResults.add(output['outputFiles'].map((file) => new EsBuildResult(file)));
241
- }
242
- if (!write && output['assetFiles']) {
243
- memResults.add(output['assetFiles'].map((file) => new NgCliAssetResult(file)));
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
- // if (write && !runServer && !nfOptions.skipHtmlTransform) {
246
- // updateIndexHtml(fedOptions, nfOptions);
247
- // }
248
- // if (!runServer) {
249
- // yield output;
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
- if (signal?.aborted) {
268
- throw new AbortedError('[builder] Before federation build.');
269
- }
270
- const start = process.hrtime();
271
- federationResult = await buildForFederation(config, fedOptions, externals, {
272
- skipMappingsAndExposed: false,
273
- skipShared: true,
274
- signal,
275
- });
276
- if (signal?.aborted) {
277
- throw new AbortedError('[builder] After federation build.');
278
- }
279
- if (hasLocales && localeFilter) {
280
- translateFederationArtifacts(i18n, localeFilter, outputOptions.base, federationResult);
281
- }
282
- if (signal?.aborted) {
283
- throw new AbortedError('[builder] After federation translations.');
284
- }
285
- logger.info('Done!');
286
- if (isLocalDevelopment) {
287
- federationBuildNotifier.broadcastBuildCompletion();
288
- }
289
- logger.measure(start, 'To rebuild the federation artifacts.');
290
- })
291
- .catch(error => {
292
- if (error instanceof AbortedError) {
293
- logger.verbose('Rebuild was canceled. Cancellation point: ' + error?.message);
294
- federationBuildNotifier.broadcastBuildCancellation();
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
- else {
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 lastResult || { success: false };
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(fedOptions) {
325
- const serverOutpath = path.join(fedOptions.outputPath, '../server');
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 });
@@ -18,5 +18,6 @@ export interface NfBuilderSchema extends JsonObject {
18
18
  ssr: boolean;
19
19
  devServer?: boolean;
20
20
  chunks?: { enable: boolean; dense: true };
21
+ entryPoint?: string;
21
22
  cacheExternalArtifacts?: boolean;
22
23
  } // eslint-disable-line
@@ -23,6 +23,9 @@
23
23
  "type": "number",
24
24
  "default": 0
25
25
  },
26
+ "entryPoint": {
27
+ "type": "string"
28
+ },
26
29
  "open": {
27
30
  "type": "boolean",
28
31
  "default": true,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setup-builder-env-variables.d.ts.map
@@ -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 {};
@@ -1,4 +1,4 @@
1
1
  export const externalsSkipList = new Set(['tslib']);
2
2
  export function filterExternals(deps) {
3
- return deps.filter((d) => !externalsSkipList.has(d));
3
+ return deps.filter(d => !externalsSkipList.has(d));
4
4
  }
@@ -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,EAGrB,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;AAKtE,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"}