@softarc/native-federation 3.5.1 → 4.0.0-RC1
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 +33 -5
- package/src/config.d.ts +5 -1
- package/src/config.d.ts.map +1 -0
- package/src/config.js +4 -6
- package/src/domain.d.ts +3 -0
- package/src/domain.d.ts.map +1 -0
- package/src/domain.js +2 -0
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +8 -5
- package/src/internal.d.ts +12 -0
- package/src/internal.d.ts.map +1 -0
- package/src/internal.js +8 -0
- package/src/lib/config/configuration-context.d.ts +1 -0
- package/src/lib/config/configuration-context.d.ts.map +1 -0
- package/src/lib/config/configuration-context.js +3 -9
- package/src/lib/config/default-skip-list.d.ts +5 -0
- package/src/lib/config/default-skip-list.d.ts.map +1 -0
- package/src/lib/{core → config}/default-skip-list.js +10 -16
- package/src/lib/config/share-utils.d.ts +7 -17
- package/src/lib/config/share-utils.d.ts.map +1 -0
- package/src/lib/config/share-utils.js +50 -123
- package/src/lib/config/with-native-federation.d.ts +2 -1
- package/src/lib/config/with-native-federation.d.ts.map +1 -0
- package/src/lib/config/with-native-federation.js +16 -20
- package/src/lib/core/build-adapter.d.ts +4 -28
- package/src/lib/core/build-adapter.d.ts.map +1 -0
- package/src/lib/core/build-adapter.js +4 -9
- package/src/lib/core/build-for-federation.d.ts +5 -8
- package/src/lib/core/build-for-federation.d.ts.map +1 -0
- package/src/lib/core/build-for-federation.js +38 -45
- package/src/lib/core/bundle-exposed-and-mappings.d.ts +4 -7
- package/src/lib/core/bundle-exposed-and-mappings.d.ts.map +1 -0
- package/src/lib/core/bundle-exposed-and-mappings.js +32 -42
- package/src/lib/core/bundle-shared.d.ts +6 -4
- package/src/lib/core/bundle-shared.d.ts.map +1 -0
- package/src/lib/core/bundle-shared.js +57 -64
- package/src/lib/core/default-external-list.d.ts +1 -0
- package/src/lib/core/default-external-list.d.ts.map +1 -0
- package/src/lib/core/default-external-list.js +1 -5
- package/src/lib/core/default-server-deps-list.d.ts +1 -0
- package/src/lib/core/default-server-deps-list.d.ts.map +1 -0
- package/src/lib/core/default-server-deps-list.js +2 -6
- package/src/lib/core/federation-builder.d.ts +7 -6
- package/src/lib/core/federation-builder.d.ts.map +1 -0
- package/src/lib/core/federation-builder.js +14 -19
- package/src/lib/core/get-externals.d.ts +2 -1
- package/src/lib/core/get-externals.d.ts.map +1 -0
- package/src/lib/core/get-externals.js +2 -6
- package/src/lib/core/load-federation-config.d.ts +3 -2
- package/src/lib/core/load-federation-config.d.ts.map +1 -0
- package/src/lib/core/load-federation-config.js +6 -12
- package/src/lib/core/remove-unused-deps.d.ts +2 -1
- package/src/lib/core/remove-unused-deps.d.ts.map +1 -0
- package/src/lib/core/remove-unused-deps.js +21 -29
- package/src/lib/core/write-federation-info.d.ts +3 -2
- package/src/lib/core/write-federation-info.d.ts.map +1 -0
- package/src/lib/core/write-federation-info.js +3 -8
- package/src/lib/core/write-import-map.d.ts +3 -2
- package/src/lib/core/write-import-map.d.ts.map +1 -0
- package/src/lib/core/write-import-map.js +3 -8
- package/src/lib/domain/config/external-config.contract.d.ts +40 -0
- package/src/lib/domain/config/external-config.contract.d.ts.map +1 -0
- package/src/lib/domain/config/external-config.contract.js +1 -0
- package/src/lib/domain/config/federation-config.contract.d.ts +28 -0
- package/src/lib/domain/config/federation-config.contract.d.ts.map +1 -0
- package/src/lib/domain/config/federation-config.contract.js +1 -0
- package/src/lib/domain/config/index.d.ts +4 -0
- package/src/lib/domain/config/index.d.ts.map +1 -0
- package/src/lib/domain/config/index.js +1 -0
- package/src/lib/{core/default-skip-list.d.ts → domain/config/skip-list.contract.d.ts} +1 -3
- package/src/lib/domain/config/skip-list.contract.d.ts.map +1 -0
- package/src/lib/domain/config/skip-list.contract.js +1 -0
- package/src/lib/domain/core/build-adapter.contract.d.ts +28 -0
- package/src/lib/domain/core/build-adapter.contract.d.ts.map +1 -0
- package/src/lib/domain/core/build-adapter.contract.js +1 -0
- package/src/lib/domain/core/build-notification-options.contract.d.ts +10 -0
- package/src/lib/domain/core/build-notification-options.contract.d.ts.map +1 -0
- package/src/lib/domain/core/build-notification-options.contract.js +6 -0
- package/src/lib/domain/core/build-params.contract.d.ts +6 -0
- package/src/lib/domain/core/build-params.contract.d.ts.map +1 -0
- package/src/lib/domain/core/build-params.contract.js +1 -0
- package/src/lib/domain/core/federation-info.contract.d.ts +29 -0
- package/src/lib/domain/core/federation-info.contract.d.ts.map +1 -0
- package/src/lib/domain/core/federation-info.contract.js +1 -0
- package/src/lib/{core/federation-options.d.ts → domain/core/federation-options.contract.d.ts} +2 -1
- package/src/lib/domain/core/federation-options.contract.d.ts.map +1 -0
- package/src/lib/domain/core/federation-options.contract.js +1 -0
- package/src/lib/domain/core/index.d.ts +6 -0
- package/src/lib/domain/core/index.d.ts.map +1 -0
- package/src/lib/domain/core/index.js +1 -0
- package/src/lib/domain/utils/index.d.ts +3 -0
- package/src/lib/domain/utils/index.d.ts.map +1 -0
- package/src/lib/domain/utils/index.js +1 -0
- package/src/lib/domain/utils/keyvaluepair.contract.d.ts +5 -0
- package/src/lib/domain/utils/keyvaluepair.contract.d.ts.map +1 -0
- package/src/lib/domain/utils/keyvaluepair.contract.js +1 -0
- package/src/lib/domain/utils/mapped-path.contract.d.ts +5 -0
- package/src/lib/domain/utils/mapped-path.contract.d.ts.map +1 -0
- package/src/lib/domain/utils/mapped-path.contract.js +1 -0
- package/src/lib/utils/build-result-map.d.ts +3 -2
- package/src/lib/utils/build-result-map.d.ts.map +1 -0
- package/src/lib/utils/build-result-map.js +5 -11
- package/src/lib/utils/build-utils.d.ts +3 -2
- package/src/lib/utils/build-utils.d.ts.map +1 -0
- package/src/lib/utils/build-utils.js +3 -7
- package/src/lib/utils/bundle-caching.d.ts +4 -3
- package/src/lib/utils/bundle-caching.d.ts.map +1 -0
- package/src/lib/utils/bundle-caching.js +35 -47
- package/src/lib/utils/errors.d.ts +1 -0
- package/src/lib/utils/errors.d.ts.map +1 -0
- package/src/lib/utils/errors.js +1 -6
- package/src/lib/utils/get-external-imports.d.ts +1 -0
- package/src/lib/utils/get-external-imports.d.ts.map +1 -0
- package/src/lib/utils/get-external-imports.js +5 -10
- package/src/lib/utils/hash-file.d.ts +1 -0
- package/src/lib/utils/hash-file.d.ts.map +1 -0
- package/src/lib/utils/hash-file.js +3 -8
- package/src/lib/utils/logger.d.ts +1 -0
- package/src/lib/utils/logger.d.ts.map +1 -0
- package/src/lib/utils/logger.js +10 -16
- package/src/lib/utils/mapped-paths.d.ts +2 -4
- package/src/lib/utils/mapped-paths.d.ts.map +1 -0
- package/src/lib/utils/mapped-paths.js +4 -9
- package/src/lib/utils/normalize.d.ts +1 -0
- package/src/lib/utils/normalize.d.ts.map +1 -0
- package/src/lib/utils/normalize.js +2 -7
- package/src/lib/utils/package-info.d.ts +1 -0
- package/src/lib/utils/package-info.d.ts.map +1 -0
- package/src/lib/utils/package-info.js +36 -47
- package/src/lib/utils/rebuild-queue.d.ts +1 -0
- package/src/lib/utils/rebuild-queue.d.ts.map +1 -0
- package/src/lib/utils/rebuild-queue.js +5 -10
- package/src/lib/utils/resolve-glob.d.ts +1 -0
- package/src/lib/utils/resolve-glob.d.ts.map +1 -0
- package/src/lib/utils/resolve-glob.js +3 -8
- package/src/lib/utils/resolve-wildcard-keys.d.ts +2 -4
- package/src/lib/utils/resolve-wildcard-keys.d.ts.map +1 -0
- package/src/lib/utils/resolve-wildcard-keys.js +3 -8
- package/src/lib/utils/rewrite-chunk-imports.d.ts +1 -0
- package/src/lib/utils/rewrite-chunk-imports.d.ts.map +1 -0
- package/src/lib/utils/rewrite-chunk-imports.js +13 -22
- package/LICENSE +0 -8
- package/README.md +0 -509
- package/build.d.ts +0 -1
- package/build.js +0 -5
- package/build.js.map +0 -1
- package/src/build.d.ts +0 -19
- package/src/build.js +0 -38
- package/src/build.js.map +0 -1
- package/src/config.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/config/configuration-context.js.map +0 -1
- package/src/lib/config/federation-config.d.ts +0 -55
- package/src/lib/config/federation-config.js +0 -3
- package/src/lib/config/federation-config.js.map +0 -1
- package/src/lib/config/share-utils.js.map +0 -1
- package/src/lib/config/with-native-federation.js.map +0 -1
- package/src/lib/core/build-adapter.js.map +0 -1
- package/src/lib/core/build-for-federation.js.map +0 -1
- package/src/lib/core/bundle-exposed-and-mappings.js.map +0 -1
- package/src/lib/core/bundle-shared.js.map +0 -1
- package/src/lib/core/default-external-list.js.map +0 -1
- package/src/lib/core/default-server-deps-list.js.map +0 -1
- package/src/lib/core/default-skip-list.js.map +0 -1
- package/src/lib/core/federation-builder.js.map +0 -1
- package/src/lib/core/federation-options.js +0 -3
- package/src/lib/core/federation-options.js.map +0 -1
- package/src/lib/core/get-externals.js.map +0 -1
- package/src/lib/core/load-federation-config.js.map +0 -1
- package/src/lib/core/remove-unused-deps.js.map +0 -1
- package/src/lib/core/write-federation-info.js.map +0 -1
- package/src/lib/core/write-import-map.js.map +0 -1
- package/src/lib/utils/build-result-map.js.map +0 -1
- package/src/lib/utils/build-utils.js.map +0 -1
- package/src/lib/utils/bundle-caching.js.map +0 -1
- package/src/lib/utils/errors.js.map +0 -1
- package/src/lib/utils/get-external-imports.js.map +0 -1
- package/src/lib/utils/hash-file.js.map +0 -1
- package/src/lib/utils/logger.js.map +0 -1
- package/src/lib/utils/mapped-paths.js.map +0 -1
- package/src/lib/utils/normalize.js.map +0 -1
- package/src/lib/utils/package-info.js.map +0 -1
- package/src/lib/utils/rebuild-queue.js.map +0 -1
- package/src/lib/utils/resolve-glob.js.map +0 -1
- package/src/lib/utils/resolve-wildcard-keys.js.map +0 -1
- package/src/lib/utils/rewrite-chunk-imports.js.map +0 -1
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const default_server_deps_list_1 = require("../core/default-server-deps-list");
|
|
9
|
-
function withNativeFederation(config) {
|
|
10
|
-
const skip = (0, default_skip_list_1.prepareSkipList)(config.skip ?? []);
|
|
1
|
+
import { getMappedPaths } from '../utils/mapped-paths.js';
|
|
2
|
+
import { shareAll, findRootTsConfigJson } from './share-utils.js';
|
|
3
|
+
import { isInSkipList, prepareSkipList } from './default-skip-list.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { DEFAULT_SERVER_DEPS_LIST } from '../core/default-server-deps-list.js';
|
|
6
|
+
export function withNativeFederation(config) {
|
|
7
|
+
const skip = prepareSkipList(config.skip ?? []);
|
|
11
8
|
const normalized = {
|
|
12
9
|
name: config.name ?? '',
|
|
13
10
|
exposes: config.exposes ?? {},
|
|
@@ -27,7 +24,7 @@ function withNativeFederation(config) {
|
|
|
27
24
|
return normalized;
|
|
28
25
|
}
|
|
29
26
|
function filterShared(shared) {
|
|
30
|
-
const keys = Object.keys(shared).filter(
|
|
27
|
+
const keys = Object.keys(shared).filter(k => !k.startsWith('@angular/common/locales'));
|
|
31
28
|
const filtered = keys.reduce((acc, curr) => ({
|
|
32
29
|
...acc,
|
|
33
30
|
[curr]: shared[curr],
|
|
@@ -38,7 +35,7 @@ function normalizeShared(config, skip) {
|
|
|
38
35
|
let result = {};
|
|
39
36
|
const shared = config.shared;
|
|
40
37
|
if (!shared) {
|
|
41
|
-
result =
|
|
38
|
+
result = shareAll({
|
|
42
39
|
singleton: true,
|
|
43
40
|
strictVersion: true,
|
|
44
41
|
requiredVersion: 'auto',
|
|
@@ -62,7 +59,7 @@ function normalizeShared(config, skip) {
|
|
|
62
59
|
//result = share(result) as Record<string, NormalizedSharedConfig>;
|
|
63
60
|
}
|
|
64
61
|
result = Object.keys(result)
|
|
65
|
-
.filter(
|
|
62
|
+
.filter(key => !isInSkipList(key, skip))
|
|
66
63
|
.reduce((acc, cur) => ({
|
|
67
64
|
...acc,
|
|
68
65
|
[cur]: result[cur],
|
|
@@ -70,23 +67,22 @@ function normalizeShared(config, skip) {
|
|
|
70
67
|
return result;
|
|
71
68
|
}
|
|
72
69
|
function normalizeSharedMappings(config, skip) {
|
|
73
|
-
const rootTsConfigPath =
|
|
74
|
-
const paths =
|
|
70
|
+
const rootTsConfigPath = findRootTsConfigJson();
|
|
71
|
+
const paths = getMappedPaths({
|
|
75
72
|
rootTsConfigPath,
|
|
76
73
|
sharedMappings: config.sharedMappings,
|
|
77
74
|
});
|
|
78
|
-
const result = paths.filter(
|
|
79
|
-
if (paths.find(
|
|
80
|
-
|
|
75
|
+
const result = paths.filter(p => !isInSkipList(p.key, skip) && !p.key.includes('*'));
|
|
76
|
+
if (paths.find(p => p.key.includes('*'))) {
|
|
77
|
+
logger.warn('Sharing mapped paths with wildcards (*) not supported');
|
|
81
78
|
}
|
|
82
79
|
return result;
|
|
83
80
|
}
|
|
84
81
|
function getDefaultPlatform(cur) {
|
|
85
|
-
if (
|
|
82
|
+
if (DEFAULT_SERVER_DEPS_LIST.find(e => cur.startsWith(e))) {
|
|
86
83
|
return 'node';
|
|
87
84
|
}
|
|
88
85
|
else {
|
|
89
86
|
return 'browser';
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
//# sourceMappingURL=with-native-federation.js.map
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
outName: string;
|
|
6
|
-
}
|
|
7
|
-
export interface BuildAdapterOptions {
|
|
8
|
-
entryPoints: EntryPoint[];
|
|
9
|
-
tsConfigPath?: string;
|
|
10
|
-
external: Array<string>;
|
|
11
|
-
outdir: string;
|
|
12
|
-
mappedPaths: MappedPath[];
|
|
13
|
-
packageName?: string;
|
|
14
|
-
esm?: boolean;
|
|
15
|
-
dev?: boolean;
|
|
16
|
-
watch?: boolean;
|
|
17
|
-
kind: BuildKind;
|
|
18
|
-
hash: boolean;
|
|
19
|
-
platform?: 'browser' | 'node';
|
|
20
|
-
optimizedMappings?: boolean;
|
|
21
|
-
signal?: AbortSignal;
|
|
22
|
-
}
|
|
23
|
-
export interface BuildResult {
|
|
24
|
-
fileName: string;
|
|
25
|
-
}
|
|
26
|
-
export type BuildAdapter = (options: BuildAdapterOptions) => Promise<BuildResult[]>;
|
|
27
|
-
export declare function setBuildAdapter(buildAdapter: BuildAdapter): void;
|
|
28
|
-
export declare function getBuildAdapter(): BuildAdapter;
|
|
1
|
+
import type { NFBuildAdapter } from '../domain/core/build-adapter.contract.js';
|
|
2
|
+
export declare function setBuildAdapter(buildAdapter: NFBuildAdapter): void;
|
|
3
|
+
export declare function getBuildAdapter(): NFBuildAdapter;
|
|
4
|
+
//# sourceMappingURL=build-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-adapter.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/build-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAS/E,wBAAgB,eAAe,CAAC,YAAY,EAAE,cAAc,GAAG,IAAI,CAElE;AAED,wBAAgB,eAAe,IAAI,cAAc,CAEhD"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setBuildAdapter = setBuildAdapter;
|
|
4
|
-
exports.getBuildAdapter = getBuildAdapter;
|
|
5
|
-
const logger_1 = require("../utils/logger");
|
|
1
|
+
import { logger } from '../utils/logger.js';
|
|
6
2
|
let _buildAdapter = async () => {
|
|
7
3
|
// TODO: add logger
|
|
8
|
-
|
|
4
|
+
logger.error('NF is missing a build adapter!');
|
|
9
5
|
return [];
|
|
10
6
|
};
|
|
11
|
-
function setBuildAdapter(buildAdapter) {
|
|
7
|
+
export function setBuildAdapter(buildAdapter) {
|
|
12
8
|
_buildAdapter = buildAdapter;
|
|
13
9
|
}
|
|
14
|
-
function getBuildAdapter() {
|
|
10
|
+
export function getBuildAdapter() {
|
|
15
11
|
return _buildAdapter;
|
|
16
12
|
}
|
|
17
|
-
//# sourceMappingURL=build-adapter.js.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { FederationInfo } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
skipMappingsAndExposed: boolean;
|
|
6
|
-
skipShared: boolean;
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
}
|
|
1
|
+
import type { FederationInfo } from '../domain/core/federation-info.contract.js';
|
|
2
|
+
import type { FederationOptions } from '../domain/core/federation-options.contract.js';
|
|
3
|
+
import type { NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
4
|
+
import type { BuildParams } from '../domain/core/build-params.contract.js';
|
|
9
5
|
export declare const defaultBuildParams: BuildParams;
|
|
10
6
|
export declare function buildForFederation(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[], buildParams?: BuildParams): Promise<FederationInfo>;
|
|
7
|
+
//# sourceMappingURL=build-for-federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-for-federation.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/build-for-federation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,4CAA4C,CAAC;AAOpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAOvF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAEjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAE3E,eAAO,MAAM,kBAAkB,EAAE,WAGhC,CAAC;AAIF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EAAE,EACnB,WAAW,cAAqB,GAC/B,OAAO,CAAC,cAAc,CAAC,CAgIzB"}
|
|
@@ -1,83 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const bundle_caching_1 = require("./../utils/bundle-caching");
|
|
11
|
-
const normalize_1 = require("../utils/normalize");
|
|
12
|
-
const errors_1 = require("../utils/errors");
|
|
13
|
-
exports.defaultBuildParams = {
|
|
1
|
+
import { bundleExposedAndMappings, describeExposed, describeSharedMappings, } from './bundle-exposed-and-mappings.js';
|
|
2
|
+
import { bundleShared } from './bundle-shared.js';
|
|
3
|
+
import { writeFederationInfo } from './write-federation-info.js';
|
|
4
|
+
import { writeImportMap } from './write-import-map.js';
|
|
5
|
+
import { logger } from '../utils/logger.js';
|
|
6
|
+
import { getCachePath } from './../utils/bundle-caching.js';
|
|
7
|
+
import { normalizePackageName } from '../utils/normalize.js';
|
|
8
|
+
import { AbortedError } from '../utils/errors.js';
|
|
9
|
+
export const defaultBuildParams = {
|
|
14
10
|
skipMappingsAndExposed: false,
|
|
15
11
|
skipShared: false,
|
|
16
12
|
};
|
|
17
13
|
const sharedPackageInfoCache = [];
|
|
18
|
-
async function buildForFederation(config, fedOptions, externals, buildParams =
|
|
14
|
+
export async function buildForFederation(config, fedOptions, externals, buildParams = defaultBuildParams) {
|
|
19
15
|
const signal = buildParams.signal;
|
|
20
16
|
let artefactInfo;
|
|
21
17
|
if (!buildParams.skipMappingsAndExposed) {
|
|
22
18
|
const start = process.hrtime();
|
|
23
|
-
artefactInfo = await
|
|
24
|
-
|
|
19
|
+
artefactInfo = await bundleExposedAndMappings(config, fedOptions, externals, signal);
|
|
20
|
+
logger.measure(start, '[build artifacts] - To bundle all mappings and exposed.');
|
|
25
21
|
if (signal?.aborted)
|
|
26
|
-
throw new
|
|
22
|
+
throw new AbortedError('[buildForFederation] After exposed-and-mappings bundle');
|
|
27
23
|
}
|
|
28
|
-
const exposedInfo = !artefactInfo
|
|
29
|
-
|
|
30
|
-
: artefactInfo.exposes;
|
|
31
|
-
const normalizedCacheFolder = (0, normalize_1.normalizePackageName)(config.name);
|
|
24
|
+
const exposedInfo = !artefactInfo ? describeExposed(config, fedOptions) : artefactInfo.exposes;
|
|
25
|
+
const normalizedCacheFolder = normalizePackageName(config.name);
|
|
32
26
|
if (normalizedCacheFolder.length < 1) {
|
|
33
|
-
|
|
27
|
+
logger.warn("Project name in 'federation.config.js' is empty, defaulting to 'shell' cache folder (could collide with other projects in the workspace).");
|
|
34
28
|
}
|
|
35
29
|
const cacheProjectFolder = normalizedCacheFolder.length < 1 ? 'shell' : normalizedCacheFolder;
|
|
36
|
-
const pathToCache =
|
|
30
|
+
const pathToCache = getCachePath(fedOptions.workspaceRoot, cacheProjectFolder);
|
|
37
31
|
if (!buildParams.skipShared && sharedPackageInfoCache.length > 0) {
|
|
38
|
-
|
|
32
|
+
logger.info('Checksum matched, re-using cached externals.');
|
|
39
33
|
}
|
|
40
34
|
if (!buildParams.skipShared && sharedPackageInfoCache.length === 0) {
|
|
41
35
|
const { sharedBrowser, sharedServer, separateBrowser, separateServer } = splitShared(config.shared);
|
|
42
36
|
if (Object.keys(sharedBrowser).length > 0) {
|
|
43
37
|
notifyBundling('browser-shared');
|
|
44
38
|
const start = process.hrtime();
|
|
45
|
-
const sharedPackageInfoBrowser = await
|
|
46
|
-
|
|
39
|
+
const sharedPackageInfoBrowser = await bundleShared(sharedBrowser, config, fedOptions, externals, 'browser', { pathToCache, bundleName: 'browser-shared' });
|
|
40
|
+
logger.measure(start, '[build artifacts] - To bundle all shared browser externals');
|
|
47
41
|
sharedPackageInfoCache.push(...sharedPackageInfoBrowser);
|
|
48
42
|
if (signal?.aborted)
|
|
49
|
-
throw new
|
|
43
|
+
throw new AbortedError('[buildForFederation] After shared-browser bundle');
|
|
50
44
|
}
|
|
51
45
|
if (Object.keys(sharedServer).length > 0) {
|
|
52
46
|
notifyBundling('browser-shared');
|
|
53
47
|
const start = process.hrtime();
|
|
54
|
-
const sharedPackageInfoServer = await
|
|
55
|
-
|
|
48
|
+
const sharedPackageInfoServer = await bundleShared(sharedServer, config, fedOptions, externals, 'node', { pathToCache, bundleName: 'node-shared' });
|
|
49
|
+
logger.measure(start, '[build artifacts] - To bundle all shared node externals');
|
|
56
50
|
sharedPackageInfoCache.push(...sharedPackageInfoServer);
|
|
57
51
|
if (signal?.aborted)
|
|
58
|
-
throw new
|
|
52
|
+
throw new AbortedError('[buildForFederation] After shared-node bundle');
|
|
59
53
|
}
|
|
60
54
|
if (Object.keys(separateBrowser).length > 0) {
|
|
61
55
|
notifyBundling('browser-shared');
|
|
62
56
|
const start = process.hrtime();
|
|
63
57
|
const separatePackageInfoBrowser = await bundleSeparatePackages(separateBrowser, externals, config, fedOptions, 'browser', pathToCache);
|
|
64
|
-
|
|
58
|
+
logger.measure(start, '[build artifacts] - To bundle all separate browser externals');
|
|
65
59
|
sharedPackageInfoCache.push(...separatePackageInfoBrowser);
|
|
66
60
|
if (signal?.aborted)
|
|
67
|
-
throw new
|
|
61
|
+
throw new AbortedError('[buildForFederation] After separate-browser bundle');
|
|
68
62
|
}
|
|
69
63
|
if (Object.keys(separateServer).length > 0) {
|
|
70
64
|
notifyBundling('browser-shared');
|
|
71
65
|
const start = process.hrtime();
|
|
72
66
|
const separatePackageInfoServer = await bundleSeparatePackages(separateServer, externals, config, fedOptions, 'node', pathToCache);
|
|
73
|
-
|
|
67
|
+
logger.measure(start, '[build artifacts] - To bundle all separate node externals');
|
|
74
68
|
sharedPackageInfoCache.push(...separatePackageInfoServer);
|
|
75
69
|
}
|
|
76
70
|
if (signal?.aborted)
|
|
77
|
-
throw new
|
|
71
|
+
throw new AbortedError('[buildForFederation] After separate-node bundle');
|
|
78
72
|
}
|
|
79
73
|
const sharedMappingInfo = !artefactInfo
|
|
80
|
-
?
|
|
74
|
+
? describeSharedMappings(config, fedOptions)
|
|
81
75
|
: artefactInfo.mappings;
|
|
82
76
|
const sharedInfo = [...sharedPackageInfoCache, ...sharedMappingInfo];
|
|
83
77
|
const buildNotificationsEndpoint = fedOptions.buildNotifications?.enable && fedOptions.dev
|
|
@@ -89,8 +83,8 @@ async function buildForFederation(config, fedOptions, externals, buildParams = e
|
|
|
89
83
|
exposes: exposedInfo,
|
|
90
84
|
buildNotificationsEndpoint,
|
|
91
85
|
};
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
writeFederationInfo(federationInfo, fedOptions);
|
|
87
|
+
writeImportMap(sharedInfo, fedOptions);
|
|
94
88
|
return federationInfo;
|
|
95
89
|
}
|
|
96
90
|
function inferPackageFromSecondary(secondary) {
|
|
@@ -110,18 +104,18 @@ async function bundleSeparatePackages(separateBrowser, externals, config, fedOpt
|
|
|
110
104
|
groupedByPackage[packageName][key] = shared;
|
|
111
105
|
}
|
|
112
106
|
const bundlePromises = Object.entries(groupedByPackage).map(async ([packageName, sharedGroup]) => {
|
|
113
|
-
return
|
|
107
|
+
return bundleShared(sharedGroup, config, fedOptions, externals.filter(e => !e.startsWith(packageName)), platform, {
|
|
114
108
|
pathToCache,
|
|
115
|
-
bundleName: `${platform}-${
|
|
109
|
+
bundleName: `${platform}-${normalizePackageName(packageName)}`,
|
|
116
110
|
});
|
|
117
111
|
});
|
|
118
112
|
const buildResults = await Promise.all(bundlePromises);
|
|
119
113
|
return buildResults.flat();
|
|
120
114
|
}
|
|
121
115
|
function notifyBundling(platform) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
logger.info('Preparing shared npm packages for the platform ' + platform);
|
|
117
|
+
logger.notice('This only needs to be done once, as results are cached');
|
|
118
|
+
logger.notice("Skip packages you don't want to share in your federation config");
|
|
125
119
|
}
|
|
126
120
|
function splitShared(shared) {
|
|
127
121
|
const sharedServer = {};
|
|
@@ -130,7 +124,7 @@ function splitShared(shared) {
|
|
|
130
124
|
const separateServer = {};
|
|
131
125
|
for (const key in shared) {
|
|
132
126
|
const obj = shared[key];
|
|
133
|
-
if (obj
|
|
127
|
+
if (obj?.platform === 'node') {
|
|
134
128
|
if (obj.build === 'default') {
|
|
135
129
|
sharedServer[key] = obj;
|
|
136
130
|
}
|
|
@@ -138,7 +132,7 @@ function splitShared(shared) {
|
|
|
138
132
|
separateServer[key] = obj;
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
|
-
else if (obj
|
|
135
|
+
else if (obj?.platform === 'browser') {
|
|
142
136
|
if (obj.build === 'default') {
|
|
143
137
|
sharedBrowser[key] = obj;
|
|
144
138
|
}
|
|
@@ -154,4 +148,3 @@ function splitShared(shared) {
|
|
|
154
148
|
separateServer,
|
|
155
149
|
};
|
|
156
150
|
}
|
|
157
|
-
//# sourceMappingURL=build-for-federation.js.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { ExposesInfo, SharedInfo } from '
|
|
2
|
-
import { NormalizedFederationConfig } from '../config/federation-config';
|
|
3
|
-
import { FederationOptions } from '
|
|
4
|
-
export interface ArtefactInfo {
|
|
5
|
-
mappings: SharedInfo[];
|
|
6
|
-
exposes: ExposesInfo[];
|
|
7
|
-
}
|
|
1
|
+
import type { ArtefactInfo, ExposesInfo, SharedInfo } from '../domain/core/federation-info.contract.js';
|
|
2
|
+
import type { NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
3
|
+
import { type FederationOptions } from '../domain/core/federation-options.contract.js';
|
|
8
4
|
export declare function bundleExposedAndMappings(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[], signal?: AbortSignal): Promise<ArtefactInfo>;
|
|
9
5
|
export declare function describeExposed(config: NormalizedFederationConfig, options: FederationOptions): Array<ExposesInfo>;
|
|
10
6
|
export declare function describeSharedMappings(config: NormalizedFederationConfig, fedOptions: FederationOptions): Array<SharedInfo>;
|
|
7
|
+
//# sourceMappingURL=bundle-exposed-and-mappings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-exposed-and-mappings.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/bundle-exposed-and-mappings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAKjG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAIvF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,YAAY,CAAC,CAkFvB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,iBAAiB,GACzB,KAAK,CAAC,WAAW,CAAC,CAoBpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,iBAAiB,GAC5B,KAAK,CAAC,UAAU,CAAC,CAoBnB"}
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const build_result_map_1 = require("../utils/build-result-map");
|
|
10
|
-
const build_utils_1 = require("../utils/build-utils");
|
|
11
|
-
const logger_1 = require("../utils/logger");
|
|
12
|
-
const normalize_1 = require("../utils/normalize");
|
|
13
|
-
const errors_1 = require("../utils/errors");
|
|
14
|
-
async function bundleExposedAndMappings(config, fedOptions, externals, signal) {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createBuildResultMap, lookupInResultMap } from '../utils/build-result-map.js';
|
|
4
|
+
import { bundle } from '../utils/build-utils.js';
|
|
5
|
+
import { logger } from '../utils/logger.js';
|
|
6
|
+
import { normalize } from '../utils/normalize.js';
|
|
7
|
+
import { AbortedError } from '../utils/errors.js';
|
|
8
|
+
export async function bundleExposedAndMappings(config, fedOptions, externals, signal) {
|
|
15
9
|
if (signal?.aborted) {
|
|
16
|
-
throw new
|
|
10
|
+
throw new AbortedError('[bundle-exposed-and-mappings] Aborted before bundling');
|
|
17
11
|
}
|
|
18
|
-
const shared = config.sharedMappings.map(
|
|
12
|
+
const shared = config.sharedMappings.map(sm => {
|
|
19
13
|
const entryPoint = sm.path;
|
|
20
14
|
const tmp = sm.key.replace(/[^A-Za-z0-9]/g, '_');
|
|
21
15
|
const outFilePath = tmp + '.js';
|
|
22
16
|
return { fileName: entryPoint, outName: outFilePath, key: sm.key };
|
|
23
17
|
});
|
|
24
|
-
const exposes = Object.
|
|
25
|
-
const entryPoint = config.exposes[key];
|
|
18
|
+
const exposes = Object.entries(config.exposes).map(([key, entry]) => {
|
|
26
19
|
const outFilePath = key + '.js';
|
|
27
|
-
return { fileName:
|
|
20
|
+
return { fileName: entry, outName: outFilePath, key };
|
|
28
21
|
});
|
|
29
22
|
const entryPoints = [...shared, ...exposes];
|
|
30
23
|
const hash = !fedOptions.dev;
|
|
31
|
-
|
|
24
|
+
logger.info('Building federation artefacts');
|
|
32
25
|
let result;
|
|
33
26
|
try {
|
|
34
|
-
result = await
|
|
27
|
+
result = await bundle({
|
|
35
28
|
entryPoints,
|
|
36
29
|
outdir: fedOptions.outputPath,
|
|
37
30
|
tsConfigPath: fedOptions.tsConfig,
|
|
@@ -45,31 +38,29 @@ async function bundleExposedAndMappings(config, fedOptions, externals, signal) {
|
|
|
45
38
|
signal,
|
|
46
39
|
});
|
|
47
40
|
if (signal?.aborted) {
|
|
48
|
-
throw new
|
|
41
|
+
throw new AbortedError('[bundle-exposed-and-mappings] Aborted after bundle');
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
44
|
catch (error) {
|
|
52
|
-
if (!(error instanceof
|
|
53
|
-
|
|
45
|
+
if (!(error instanceof AbortedError)) {
|
|
46
|
+
logger.error('Error building federation artefacts');
|
|
54
47
|
}
|
|
55
48
|
throw error;
|
|
56
49
|
}
|
|
57
|
-
const resultMap =
|
|
50
|
+
const resultMap = createBuildResultMap(result, hash);
|
|
58
51
|
const sharedResult = [];
|
|
59
52
|
for (const item of shared) {
|
|
60
53
|
sharedResult.push({
|
|
61
54
|
packageName: item.key,
|
|
62
|
-
outFileName:
|
|
55
|
+
outFileName: lookupInResultMap(resultMap, item.outName),
|
|
63
56
|
requiredVersion: '',
|
|
64
57
|
singleton: true,
|
|
65
58
|
strictVersion: false,
|
|
66
|
-
version: config.features.mappingVersion
|
|
67
|
-
? getMappingVersion(item.fileName)
|
|
68
|
-
: '',
|
|
59
|
+
version: config.features.mappingVersion ? getMappingVersion(item.fileName) : '',
|
|
69
60
|
dev: !fedOptions.dev
|
|
70
61
|
? undefined
|
|
71
62
|
: {
|
|
72
|
-
entryPoint:
|
|
63
|
+
entryPoint: normalize(path.normalize(item.fileName)),
|
|
73
64
|
},
|
|
74
65
|
});
|
|
75
66
|
}
|
|
@@ -77,20 +68,20 @@ async function bundleExposedAndMappings(config, fedOptions, externals, signal) {
|
|
|
77
68
|
for (const item of exposes) {
|
|
78
69
|
exposedResult.push({
|
|
79
70
|
key: item.key,
|
|
80
|
-
outFileName:
|
|
71
|
+
outFileName: lookupInResultMap(resultMap, item.outName),
|
|
81
72
|
dev: !fedOptions.dev
|
|
82
73
|
? undefined
|
|
83
74
|
: {
|
|
84
|
-
entryPoint:
|
|
75
|
+
entryPoint: normalize(path.join(fedOptions.workspaceRoot, item.fileName)),
|
|
85
76
|
},
|
|
86
77
|
});
|
|
87
78
|
}
|
|
88
79
|
return { mappings: sharedResult, exposes: exposedResult };
|
|
89
80
|
}
|
|
90
|
-
function describeExposed(config, options) {
|
|
81
|
+
export function describeExposed(config, options) {
|
|
91
82
|
const result = [];
|
|
92
83
|
for (const key in config.exposes) {
|
|
93
|
-
const localPath =
|
|
84
|
+
const localPath = normalize(path.normalize(path.join(options.workspaceRoot, config.exposes[key])));
|
|
94
85
|
result.push({
|
|
95
86
|
key,
|
|
96
87
|
outFileName: '',
|
|
@@ -103,7 +94,7 @@ function describeExposed(config, options) {
|
|
|
103
94
|
}
|
|
104
95
|
return result;
|
|
105
96
|
}
|
|
106
|
-
function describeSharedMappings(config, fedOptions) {
|
|
97
|
+
export function describeSharedMappings(config, fedOptions) {
|
|
107
98
|
const result = [];
|
|
108
99
|
for (const m of config.sharedMappings) {
|
|
109
100
|
result.push({
|
|
@@ -116,21 +107,20 @@ function describeSharedMappings(config, fedOptions) {
|
|
|
116
107
|
dev: !fedOptions.dev
|
|
117
108
|
? undefined
|
|
118
109
|
: {
|
|
119
|
-
entryPoint:
|
|
110
|
+
entryPoint: normalize(path.normalize(m.path)),
|
|
120
111
|
},
|
|
121
112
|
});
|
|
122
113
|
}
|
|
123
114
|
return result;
|
|
124
115
|
}
|
|
125
116
|
function getMappingVersion(fileName) {
|
|
126
|
-
const entryFileDir =
|
|
127
|
-
const cand1 =
|
|
128
|
-
const cand2 =
|
|
129
|
-
const packageJsonPath = [cand1, cand2].find(
|
|
117
|
+
const entryFileDir = path.dirname(fileName);
|
|
118
|
+
const cand1 = path.join(entryFileDir, 'package.json');
|
|
119
|
+
const cand2 = path.join(path.dirname(entryFileDir), 'package.json');
|
|
120
|
+
const packageJsonPath = [cand1, cand2].find(cand => fs.existsSync(cand));
|
|
130
121
|
if (packageJsonPath) {
|
|
131
|
-
const json = JSON.parse(
|
|
122
|
+
const json = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
132
123
|
return json.version ?? '';
|
|
133
124
|
}
|
|
134
125
|
return '';
|
|
135
126
|
}
|
|
136
|
-
//# sourceMappingURL=bundle-exposed-and-mappings.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { NormalizedFederationConfig
|
|
2
|
-
import { SharedInfo } from '
|
|
3
|
-
import { FederationOptions } from '
|
|
4
|
-
|
|
1
|
+
import type { NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
2
|
+
import type { SharedInfo } from '../domain/core/federation-info.contract.js';
|
|
3
|
+
import { type FederationOptions } from '../domain/core/federation-options.contract.js';
|
|
4
|
+
import type { NormalizedExternalConfig } from '../domain/config/external-config.contract.js';
|
|
5
|
+
export declare function bundleShared(sharedBundles: Record<string, NormalizedExternalConfig>, config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[], platform: "browser" | "node" | undefined, cacheOptions: {
|
|
5
6
|
pathToCache: string;
|
|
6
7
|
bundleName: string;
|
|
7
8
|
}): Promise<Array<SharedInfo>>;
|
|
9
|
+
//# sourceMappingURL=bundle-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-shared.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/bundle-shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAGjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAWvF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAG7F,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,EACvD,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,EAAE,SAAS,GAAG,MAAM,YAAY,EACxC,YAAY,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAkI5B"}
|