Skip to content

Commit dbb6162

Browse files
committed
feat(nf): update for angular 19 + ssr/hydration
1 parent f2ad1f1 commit dbb6162

File tree

10 files changed

+49
-19
lines changed

10 files changed

+49
-19
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@softarc/native-federation",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"type": "commonjs",
55
"license": "MIT",
66
"dependencies": {
77
"json5": "^2.2.0",
88
"npmlog": "^6.0.2",
9-
"@softarc/native-federation-runtime": "2.0.12"
9+
"@softarc/native-federation-runtime": "2.0.13"
1010
}
1111
}

libs/native-federation-core/src/build.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export { DEFAULT_SKIP_LIST } from './lib/core/default-skip-list';
2+
13
export { NormalizedFederationConfig } from './lib/config/federation-config';
24
export { FederationOptions } from './lib/core/federation-options';
35
export { setBuildAdapter } from './lib/core/build-adapter';
@@ -29,3 +31,4 @@ export {
2931
export { logger, setLogLevel } from './lib/utils/logger';
3032
export { hashFile } from './lib/utils/hash-file';
3133
export * from './lib/utils/build-result-map';
34+

libs/native-federation-core/src/lib/config/share-utils.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DEFAULT_SKIP_LIST,
77
isInSkipList,
88
PREPARED_DEFAULT_SKIP_LIST,
9+
PreparedSkipList,
910
prepareSkipList,
1011
SkipList,
1112
} from '../core/default-skip-list';
@@ -321,7 +322,7 @@ export function shareAll(
321322
}
322323
}
323324

324-
return module.exports.share(share, projectPath);
325+
return module.exports.share(share, projectPath, skip);
325326
}
326327

327328
function inferProjectPath(projectPath: string) {
@@ -351,7 +352,8 @@ type TransientDependency = {
351352

352353
function findTransientDeps(
353354
packageNames: string[],
354-
projectRoot: string
355+
projectRoot: string,
356+
preparedSkipList: PreparedSkipList
355357
): TransientDependency[] {
356358
const discovered = new Set<string>();
357359
const result: TransientDependency[] = [];
@@ -363,7 +365,13 @@ function findTransientDeps(
363365
packageName,
364366
'package.json'
365367
);
366-
_findTransientDeps(packagePath, projectRoot, discovered, result);
368+
_findTransientDeps(
369+
packagePath,
370+
projectRoot,
371+
preparedSkipList,
372+
discovered,
373+
result
374+
);
367375
}
368376

369377
return result;
@@ -372,6 +380,7 @@ function findTransientDeps(
372380
function _findTransientDeps(
373381
packagePath: string,
374382
projectRoot: string,
383+
preparedSkipList: PreparedSkipList,
375384
discovered: Set<string>,
376385
result: TransientDependency[]
377386
) {
@@ -391,30 +400,47 @@ function _findTransientDeps(
391400
);
392401
const depPath = path.dirname(depPackageJson);
393402

394-
if (!discovered.has(depPackageJson)) {
403+
if (
404+
!discovered.has(depPackageJson) &&
405+
!isInSkipList(dep, preparedSkipList) &&
406+
fs.existsSync(depPackageJson)
407+
) {
395408
discovered.add(depPackageJson);
396409
const version = packageJson.dependencies[dep];
397410
result.push({
398411
packageName: dep,
399412
requiredVersion: version,
400413
packagePath: depPath,
401414
});
402-
_findTransientDeps(depPackageJson, projectRoot, discovered, result);
415+
_findTransientDeps(
416+
depPackageJson,
417+
projectRoot,
418+
preparedSkipList,
419+
discovered,
420+
result
421+
);
403422
}
404423
}
405424
}
406425

407426
export function share(
408427
configuredShareObjects: Config,
409-
projectPath = ''
428+
projectPath = '',
429+
skipList = DEFAULT_SKIP_LIST
410430
): Config {
411431
projectPath = inferProjectPath(projectPath);
412432
const packagePath = findPackageJson(projectPath);
413433

414434
const sharedPackageNames = Object.keys(configuredShareObjects);
415435
const packageDirectory = path.dirname(packagePath);
416436

417-
const transientDeps = findTransientDeps(sharedPackageNames, packageDirectory);
437+
const preparedSkipList = prepareSkipList(skipList);
438+
439+
const transientDeps = findTransientDeps(
440+
sharedPackageNames,
441+
packageDirectory,
442+
preparedSkipList
443+
);
418444

419445
const transientShareObject = transientDeps.reduce(
420446
(acc, curr) => ({

libs/native-federation-core/src/lib/core/default-skip-list.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export const DEFAULT_SKIP_LIST: SkipList = [
1818
'@angular/localize/tools',
1919
(pkg) => pkg.startsWith('@angular/common/locales'),
2020
(pkg) => pkg.startsWith('rxjs/internal'),
21-
'@angular/platform-server',
22-
'@angular/platform-server/init',
23-
'@angular/ssr',
21+
// '@angular/platform-server',
22+
// '@angular/platform-server/init',
23+
// '@angular/ssr',
2424
'express',
2525
/\/schematics(\/|$)/,
2626
/^@nx\/angular/,

libs/native-federation-esbuild/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@softarc/native-federation-esbuild",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"type": "commonjs",
55
"dependencies": {
66
"@rollup/plugin-commonjs": "^22.0.2",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "@softarc/native-federation-node",
3-
"version": "2.0.12"
3+
"version": "2.0.13"
44
}

libs/native-federation-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@softarc/native-federation-runtime",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"dependencies": {
55
"tslib": "^2.3.0"
66
},

libs/native-federation/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/native-federation",
3-
"version": "18.2.5",
3+
"version": "18.2.6",
44
"main": "src/index.js",
55
"generators": "./collection.json",
66
"builders": "./builders.json",
@@ -20,8 +20,8 @@
2020
},
2121
"dependencies": {
2222
"@babel/core": "^7.19.0",
23-
"@softarc/native-federation": "2.0.12",
24-
"@softarc/native-federation-runtime": "2.0.12",
23+
"@softarc/native-federation": "2.0.13",
24+
"@softarc/native-federation-runtime": "2.0.13",
2525
"@types/browser-sync": "^2.29.0",
2626
"@chialab/esbuild-plugin-commonjs": "^0.18.0",
2727
"browser-sync": "^3.0.2",

libs/native-federation/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export {
33
findRootTsConfigJson,
44
share,
55
shareAll,
6+
DEFAULT_SKIP_LIST
67
} from '@softarc/native-federation/build';

libs/native-federation/src/utils/angular-esbuild-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ async function runEsbuild(
271271
'object-rest-spread': false,
272272
},
273273
splitting: kind === 'mapping-or-exposed',
274-
platform: 'browser',
274+
platform: 'node',
275275
format: 'esm',
276276
target: ['esnext'],
277277
logLimit: kind === 'shared-package' ? 1 : 0,

0 commit comments

Comments
 (0)