@softarc/native-federation 3.5.5 → 4.0.0-RC10
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 +4 -1
- package/src/config.js +4 -6
- package/src/domain.d.ts +2 -0
- package/src/domain.js +2 -0
- package/src/index.d.ts +10 -1
- package/src/index.js +10 -5
- package/src/internal.d.ts +13 -0
- package/src/internal.js +10 -0
- package/src/lib/config/configuration-context.js +3 -9
- package/src/lib/config/default-skip-list.d.ts +4 -0
- package/src/lib/config/default-skip-list.js +31 -0
- package/src/lib/config/remove-unused-deps.d.ts +3 -0
- package/src/lib/config/remove-unused-deps.js +10 -0
- package/src/lib/config/share-utils.d.ts +6 -18
- package/src/lib/config/share-utils.js +49 -128
- package/src/lib/config/with-native-federation.d.ts +1 -1
- package/src/lib/config/with-native-federation.js +48 -75
- package/src/lib/core/build-adapter.d.ts +3 -28
- package/src/lib/core/build-adapter.js +8 -13
- package/src/lib/core/build-for-federation.d.ts +4 -10
- package/src/lib/core/build-for-federation.js +84 -79
- package/src/lib/core/bundle-exposed-and-mappings.d.ts +6 -10
- package/src/lib/core/bundle-exposed-and-mappings.js +78 -60
- package/src/lib/core/bundle-shared.d.ts +11 -6
- package/src/lib/core/bundle-shared.js +88 -72
- package/src/lib/core/default-external-list.js +1 -8
- package/src/lib/core/federation-builder.d.ts +11 -6
- package/src/lib/core/federation-builder.js +27 -21
- package/src/lib/core/federation-cache.d.ts +8 -0
- package/src/lib/core/federation-cache.js +11 -0
- package/src/lib/core/get-externals.d.ts +1 -1
- package/src/lib/core/get-externals.js +2 -6
- package/src/lib/core/normalize-options.d.ts +12 -0
- package/src/lib/core/normalize-options.js +57 -0
- package/src/lib/core/rebuild-for-federation.d.ts +4 -0
- package/src/lib/core/rebuild-for-federation.js +37 -0
- package/src/lib/core/write-federation-info.d.ts +2 -2
- package/src/lib/core/write-federation-info.js +3 -8
- package/src/lib/core/write-import-map.d.ts +6 -3
- package/src/lib/core/write-import-map.js +13 -9
- package/src/lib/domain/config/external-config.contract.d.ts +43 -0
- package/src/lib/domain/config/external-config.contract.js +1 -0
- package/src/lib/domain/config/federation-config.contract.d.ts +35 -0
- package/src/lib/domain/config/federation-config.contract.js +1 -0
- package/src/lib/domain/config/index.d.ts +3 -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} +0 -3
- package/src/lib/domain/config/skip-list.contract.js +1 -0
- package/src/lib/domain/config/with-native-federation.contract.d.ts +2 -0
- package/src/lib/domain/config/with-native-federation.contract.js +1 -0
- package/src/lib/domain/core/build-adapter.contract.d.ts +40 -0
- package/src/lib/domain/core/build-adapter.contract.js +1 -0
- package/src/lib/domain/core/build-notification-options.contract.d.ts +9 -0
- package/src/lib/domain/core/build-notification-options.contract.js +6 -0
- package/src/lib/domain/core/chunk.d.ts +2 -0
- package/src/lib/domain/core/chunk.js +8 -0
- package/src/lib/domain/core/federation-cache.contract.d.ts +7 -0
- package/src/lib/domain/core/federation-cache.contract.js +1 -0
- package/src/lib/domain/core/federation-info.contract.d.ts +33 -0
- package/src/lib/domain/core/federation-info.contract.js +1 -0
- package/src/lib/domain/core/federation-options.contract.d.ts +21 -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.js +2 -0
- package/src/lib/domain/utils/index.d.ts +2 -0
- package/src/lib/domain/utils/index.js +1 -0
- package/src/lib/domain/utils/keyvaluepair.contract.d.ts +4 -0
- package/src/lib/domain/utils/keyvaluepair.contract.js +1 -0
- package/src/lib/domain/utils/mapped-path.contract.d.ts +1 -0
- package/src/lib/domain/utils/mapped-path.contract.js +5 -0
- package/src/lib/domain/utils/used-dependencies.contract.d.ts +5 -0
- package/src/lib/domain/utils/used-dependencies.contract.js +1 -0
- package/src/lib/utils/build-result-map.d.ts +3 -2
- package/src/lib/utils/build-result-map.js +14 -13
- package/src/lib/utils/{bundle-caching.d.ts → cache-persistence.d.ts} +6 -4
- package/src/lib/utils/cache-persistence.js +66 -0
- package/src/lib/utils/errors.js +1 -6
- package/src/lib/utils/get-external-imports.js +5 -10
- package/src/lib/utils/get-used-dependencies.d.ts +7 -0
- package/src/lib/utils/get-used-dependencies.js +123 -0
- package/src/lib/utils/hash-file.js +3 -8
- package/src/lib/utils/logger.js +10 -16
- package/src/lib/utils/mapped-paths.d.ts +7 -10
- package/src/lib/utils/mapped-paths.js +18 -37
- package/src/lib/utils/normalize.js +2 -7
- package/src/lib/utils/package-info.js +36 -47
- package/src/lib/utils/rebuild-queue.d.ts +14 -1
- package/src/lib/utils/rebuild-queue.js +36 -21
- package/src/lib/utils/resolve-glob.js +7 -12
- package/src/lib/utils/resolve-wildcard-keys.js +9 -15
- package/src/lib/utils/rewrite-chunk-imports.d.ts +0 -2
- package/src/lib/utils/rewrite-chunk-imports.js +13 -29
- 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.d.ts +0 -2
- package/src/lib/core/default-server-deps-list.js +0 -10
- package/src/lib/core/default-server-deps-list.js.map +0 -1
- package/src/lib/core/default-skip-list.js +0 -49
- 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.d.ts +0 -14
- 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.d.ts +0 -3
- package/src/lib/core/load-federation-config.js +0 -24
- package/src/lib/core/load-federation-config.js.map +0 -1
- package/src/lib/core/remove-unused-deps.d.ts +0 -2
- package/src/lib/core/remove-unused-deps.js +0 -98
- 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.d.ts +0 -2
- package/src/lib/utils/build-utils.js +0 -9
- package/src/lib/utils/build-utils.js.map +0 -1
- package/src/lib/utils/bundle-caching.js +0 -78
- package/src/lib/utils/bundle-caching.js.map +0 -1
- package/src/lib/utils/config-utils.d.ts +0 -2
- package/src/lib/utils/config-utils.js +0 -13
- package/src/lib/utils/config-utils.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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
2
|
+
import type { FederationOptions, NormalizedFederationOptions } from '../domain/core/federation-options.contract.js';
|
|
3
|
+
import { type FederationCache } from '../../domain.js';
|
|
4
|
+
export declare function normalizeFederationOptions(options: FederationOptions): Promise<{
|
|
5
|
+
config: NormalizedFederationConfig;
|
|
6
|
+
options: NormalizedFederationOptions<undefined>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function normalizeFederationOptions<TBundlerCache>(options: FederationOptions, cache: FederationCache<TBundlerCache>): Promise<{
|
|
9
|
+
config: NormalizedFederationConfig;
|
|
10
|
+
options: NormalizedFederationOptions<TBundlerCache>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function resolveProjectName(name?: string): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { pathToFileURL } from 'url';
|
|
4
|
+
import { removeUnusedDeps } from '../config/remove-unused-deps.js';
|
|
5
|
+
import { createFederationCache } from './federation-cache.js';
|
|
6
|
+
import { getDefaultCachePath } from '../utils/cache-persistence.js';
|
|
7
|
+
import { getUsedDependenciesFactory } from '../utils/get-used-dependencies.js';
|
|
8
|
+
import { logger } from '../utils/logger.js';
|
|
9
|
+
import { normalizePackageName } from '../utils/normalize.js';
|
|
10
|
+
export async function normalizeFederationOptions(options, cache) {
|
|
11
|
+
/**
|
|
12
|
+
* Step 1: normalizing config
|
|
13
|
+
*/
|
|
14
|
+
const fullConfigPath = path.join(options.workspaceRoot, options.federationConfig);
|
|
15
|
+
const getUsedDeps = getUsedDependenciesFactory(options.workspaceRoot, options.entryPoints);
|
|
16
|
+
if (!fs.existsSync(fullConfigPath)) {
|
|
17
|
+
throw new Error('Expected ' + fullConfigPath);
|
|
18
|
+
}
|
|
19
|
+
let config = (await import(pathToFileURL(fullConfigPath).href))
|
|
20
|
+
?.default;
|
|
21
|
+
/**
|
|
22
|
+
* Step 2: normalizing options
|
|
23
|
+
*/
|
|
24
|
+
const federationCache = cache ??
|
|
25
|
+
createFederationCache(getDefaultCachePath(options.workspaceRoot));
|
|
26
|
+
const normalizedOptions = {
|
|
27
|
+
...options,
|
|
28
|
+
entryPoints: options.entryPoints ?? Object.values(config.exposes ?? {}),
|
|
29
|
+
projectName: resolveProjectName(options.projectName ?? config.name),
|
|
30
|
+
federationCache,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Step 3: Remove unused deps
|
|
34
|
+
*/
|
|
35
|
+
if (config.features.ignoreUnusedDeps) {
|
|
36
|
+
config = removeUnusedDeps(getUsedDeps(config), config);
|
|
37
|
+
logger.info('Removed unused dependencies.');
|
|
38
|
+
logger.debug('This can be disabled per dependency/external using the "includeSecondaries: {keepAll: true}" property. Or in general by disabling the "ignoreUnusedDeps" feature. ');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const withWildcard = Object.keys(config.sharedMappings).some(m => m.includes('*'));
|
|
42
|
+
if (withWildcard) {
|
|
43
|
+
logger.warn('Sharing mapped paths with wildcards (*) is only supported with ignoreUnusedDeps feature.');
|
|
44
|
+
config.sharedMappings = Object.entries(config.sharedMappings)
|
|
45
|
+
.filter(([_path]) => !_path.includes('*'))
|
|
46
|
+
.reduce((acc, [_path, _import]) => ({ ...acc, [_path]: _import }), {});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { config, options: normalizedOptions };
|
|
50
|
+
}
|
|
51
|
+
export function resolveProjectName(name) {
|
|
52
|
+
if (!name || name.length < 1) {
|
|
53
|
+
logger.warn("Project name in 'federation.config.js' is empty, defaulting to 'shell' cache folder (could collide with other projects in the workspace).");
|
|
54
|
+
return 'shell';
|
|
55
|
+
}
|
|
56
|
+
return normalizePackageName(name);
|
|
57
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FederationInfo } from '../domain/core/federation-info.contract.js';
|
|
2
|
+
import type { NormalizedFederationOptions } from '../domain/core/federation-options.contract.js';
|
|
3
|
+
import type { NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
4
|
+
export declare function rebuildForFederation(config: NormalizedFederationConfig, fedOptions: NormalizedFederationOptions, externals: string[], modifiedFiles: string[], signal?: AbortSignal): Promise<FederationInfo>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { bundleExposedAndMappings, describeExposed, describeSharedMappings, } from './bundle-exposed-and-mappings.js';
|
|
2
|
+
import { writeFederationInfo } from './write-federation-info.js';
|
|
3
|
+
import { writeImportMap } from './write-import-map.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { AbortedError } from '../utils/errors.js';
|
|
6
|
+
export async function rebuildForFederation(config, fedOptions, externals, modifiedFiles, signal) {
|
|
7
|
+
const federationCache = fedOptions.federationCache;
|
|
8
|
+
logger.info(`Re-bundling all internal libraries and exposed modules..'`);
|
|
9
|
+
const start = process.hrtime();
|
|
10
|
+
const artifactInfo = await bundleExposedAndMappings(config, fedOptions, externals, modifiedFiles, signal);
|
|
11
|
+
logger.measure(start, 'To re-bundle all internal libraries and exposed modules.');
|
|
12
|
+
if (signal?.aborted)
|
|
13
|
+
throw new AbortedError('[buildForFederation] After exposed-and-mappings bundle');
|
|
14
|
+
const exposedInfo = !artifactInfo ? describeExposed(config, fedOptions) : artifactInfo.exposes;
|
|
15
|
+
const sharedMappingInfo = !artifactInfo
|
|
16
|
+
? describeSharedMappings(config, fedOptions)
|
|
17
|
+
: artifactInfo.mappings;
|
|
18
|
+
const sharedExternals = [...federationCache.externals, ...sharedMappingInfo];
|
|
19
|
+
const buildNotificationsEndpoint = fedOptions.buildNotifications?.enable && fedOptions.dev
|
|
20
|
+
? fedOptions.buildNotifications?.endpoint
|
|
21
|
+
: undefined;
|
|
22
|
+
const federationInfo = {
|
|
23
|
+
name: config.name,
|
|
24
|
+
shared: sharedExternals,
|
|
25
|
+
exposes: exposedInfo,
|
|
26
|
+
buildNotificationsEndpoint,
|
|
27
|
+
};
|
|
28
|
+
if (federationCache.chunks) {
|
|
29
|
+
federationInfo.chunks = federationCache.chunks;
|
|
30
|
+
}
|
|
31
|
+
if (artifactInfo?.chunks) {
|
|
32
|
+
federationInfo.chunks = { ...(federationInfo.chunks ?? {}), ...artifactInfo?.chunks };
|
|
33
|
+
}
|
|
34
|
+
writeFederationInfo(federationInfo, fedOptions);
|
|
35
|
+
writeImportMap(federationCache, fedOptions);
|
|
36
|
+
return federationInfo;
|
|
37
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FederationInfo } from '
|
|
2
|
-
import { FederationOptions } from '
|
|
1
|
+
import type { FederationInfo } from '../domain/core/federation-info.contract.js';
|
|
2
|
+
import type { FederationOptions } from '../domain/core/federation-options.contract.js';
|
|
3
3
|
export declare function writeFederationInfo(federationInfo: FederationInfo, fedOptions: FederationOptions): void;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
function writeFederationInfo(federationInfo, fedOptions) {
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export function writeFederationInfo(federationInfo, fedOptions) {
|
|
8
4
|
const metaDataPath = path.join(fedOptions.workspaceRoot, fedOptions.outputPath, 'remoteEntry.json');
|
|
9
5
|
fs.writeFileSync(metaDataPath, JSON.stringify(federationInfo, null, 2));
|
|
10
6
|
}
|
|
11
|
-
//# sourceMappingURL=write-federation-info.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { SharedInfo } from '
|
|
2
|
-
import { FederationOptions } from '
|
|
3
|
-
export declare function writeImportMap(sharedInfo:
|
|
1
|
+
import type { ChunkInfo, SharedInfo } from '../domain/core/federation-info.contract.js';
|
|
2
|
+
import type { FederationOptions } from '../domain/core/federation-options.contract.js';
|
|
3
|
+
export declare function writeImportMap(sharedInfo: {
|
|
4
|
+
externals: SharedInfo[];
|
|
5
|
+
chunks?: ChunkInfo;
|
|
6
|
+
}, fedOption: FederationOptions): void;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
-
function writeImportMap(sharedInfo, fedOption) {
|
|
8
|
-
const imports = sharedInfo.reduce((acc, cur) => {
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { toChunkImport } from '../domain/core/chunk.js';
|
|
4
|
+
export function writeImportMap(sharedInfo, fedOption) {
|
|
5
|
+
const imports = sharedInfo.externals.reduce((acc, cur) => {
|
|
9
6
|
return {
|
|
10
7
|
...acc,
|
|
11
8
|
[cur.packageName]: cur.outFileName,
|
|
12
9
|
};
|
|
13
10
|
}, {});
|
|
11
|
+
if (sharedInfo.chunks) {
|
|
12
|
+
Object.values(sharedInfo.chunks).forEach(c => {
|
|
13
|
+
c.forEach(e => {
|
|
14
|
+
const key = toChunkImport(e);
|
|
15
|
+
imports[key] = e;
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
14
19
|
const importMap = { imports };
|
|
15
20
|
const importMapPath = path.join(fedOption.workspaceRoot, fedOption.outputPath, 'importmap.json');
|
|
16
21
|
fs.writeFileSync(importMapPath, JSON.stringify(importMap, null, 2));
|
|
17
22
|
}
|
|
18
|
-
//# sourceMappingURL=write-import-map.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ExternalConfig {
|
|
2
|
+
singleton?: boolean;
|
|
3
|
+
strictVersion?: boolean;
|
|
4
|
+
requiredVersion?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
includeSecondaries?: boolean;
|
|
7
|
+
platform?: 'browser' | 'node';
|
|
8
|
+
build?: 'separate' | 'package';
|
|
9
|
+
chunks?: boolean;
|
|
10
|
+
shareScope?: string;
|
|
11
|
+
packageInfo?: {
|
|
12
|
+
entryPoint: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
esm?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizedExternalConfig {
|
|
18
|
+
singleton: boolean;
|
|
19
|
+
strictVersion: boolean;
|
|
20
|
+
requiredVersion: string;
|
|
21
|
+
version?: string;
|
|
22
|
+
includeSecondaries?: boolean;
|
|
23
|
+
shareScope?: string;
|
|
24
|
+
chunks: boolean;
|
|
25
|
+
platform: 'browser' | 'node';
|
|
26
|
+
build: 'default' | 'separate' | 'package';
|
|
27
|
+
packageInfo?: {
|
|
28
|
+
entryPoint: string;
|
|
29
|
+
version: string;
|
|
30
|
+
esm: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export type IncludeSecondariesOptions = {
|
|
34
|
+
skip: string | string[];
|
|
35
|
+
resolveGlob?: boolean;
|
|
36
|
+
keepAll?: boolean;
|
|
37
|
+
} | boolean;
|
|
38
|
+
export type SharedExternalsConfig = Record<string, ExternalConfig>;
|
|
39
|
+
export type NormalizedSharedExternalsConfig = Record<string, NormalizedExternalConfig>;
|
|
40
|
+
export type ShareAllExternalsOptions = ExternalConfig & {
|
|
41
|
+
includeSecondaries?: IncludeSecondariesOptions;
|
|
42
|
+
};
|
|
43
|
+
export type ShareExternalsOptions = Record<string, ShareAllExternalsOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PreparedSkipList, SkipList } from './skip-list.contract.js';
|
|
2
|
+
import type { PathToImport } from '../utils/mapped-path.contract.js';
|
|
3
|
+
import type { NormalizedSharedExternalsConfig, SharedExternalsConfig } from './external-config.contract.js';
|
|
4
|
+
export interface FederationConfig {
|
|
5
|
+
name?: string;
|
|
6
|
+
exposes?: Record<string, string>;
|
|
7
|
+
shared?: SharedExternalsConfig;
|
|
8
|
+
platform?: 'browser' | 'node';
|
|
9
|
+
sharedMappings?: Array<string>;
|
|
10
|
+
chunks?: boolean;
|
|
11
|
+
skip?: SkipList;
|
|
12
|
+
externals?: string[];
|
|
13
|
+
shareScope?: string;
|
|
14
|
+
features?: {
|
|
15
|
+
mappingVersion?: boolean;
|
|
16
|
+
ignoreUnusedDeps?: boolean;
|
|
17
|
+
denseChunking?: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface NormalizedFederationConfig {
|
|
21
|
+
$type: 'classic';
|
|
22
|
+
name: string;
|
|
23
|
+
exposes: Record<string, string>;
|
|
24
|
+
shared: NormalizedSharedExternalsConfig;
|
|
25
|
+
sharedMappings: PathToImport;
|
|
26
|
+
skip: PreparedSkipList;
|
|
27
|
+
chunks: boolean;
|
|
28
|
+
externals: string[];
|
|
29
|
+
shareScope?: string;
|
|
30
|
+
features: {
|
|
31
|
+
mappingVersion: boolean;
|
|
32
|
+
ignoreUnusedDeps: boolean;
|
|
33
|
+
denseChunking: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { ExternalConfig, IncludeSecondariesOptions, SharedExternalsConfig, ShareAllExternalsOptions, ShareExternalsOptions, } from './external-config.contract.js';
|
|
2
|
+
export type { FederationConfig } from './federation-config.contract.js';
|
|
3
|
+
export type { PreparedSkipList, SkipFn, SkipList, SkipListEntry } from './skip-list.contract.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export type SkipFn = (name: string) => boolean;
|
|
2
2
|
export type SkipListEntry = string | RegExp | SkipFn;
|
|
3
3
|
export type SkipList = SkipListEntry[];
|
|
4
|
-
export declare const DEFAULT_SKIP_LIST: SkipList;
|
|
5
4
|
export type PreparedSkipList = {
|
|
6
5
|
strings: Set<string>;
|
|
7
6
|
functions: SkipFn[];
|
|
8
7
|
regexps: RegExp[];
|
|
9
8
|
};
|
|
10
|
-
export declare function prepareSkipList(skipList: SkipList): PreparedSkipList;
|
|
11
|
-
export declare function isInSkipList(entry: string, skipList: PreparedSkipList): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PathToImport } from '../utils/mapped-path.contract.js';
|
|
2
|
+
import type { FederationCache } from './federation-cache.contract.js';
|
|
3
|
+
export interface NFBuildAdapterContext<TBundlerContext = unknown> {
|
|
4
|
+
ctx: TBundlerContext;
|
|
5
|
+
outdir: string;
|
|
6
|
+
dev: boolean;
|
|
7
|
+
name: string;
|
|
8
|
+
isMappingOrExposed: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NFBuildAdapter {
|
|
11
|
+
setup(name: string, options: NFBuildAdapterOptions): Promise<void>;
|
|
12
|
+
build(name: string, opts?: {
|
|
13
|
+
modifiedFiles?: string[];
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}): Promise<NFBuildAdapterResult[]>;
|
|
16
|
+
dispose(name?: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface EntryPoint {
|
|
19
|
+
fileName: string;
|
|
20
|
+
outName: string;
|
|
21
|
+
key?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface NFBuildAdapterOptions<TBundlerCache = unknown> {
|
|
24
|
+
entryPoints: EntryPoint[];
|
|
25
|
+
tsConfigPath?: string;
|
|
26
|
+
external: string[];
|
|
27
|
+
outdir: string;
|
|
28
|
+
mappedPaths: PathToImport;
|
|
29
|
+
isMappingOrExposed: boolean;
|
|
30
|
+
dev?: boolean;
|
|
31
|
+
watch?: boolean;
|
|
32
|
+
chunks?: boolean;
|
|
33
|
+
hash: boolean;
|
|
34
|
+
platform?: 'browser' | 'node';
|
|
35
|
+
optimizedMappings?: boolean;
|
|
36
|
+
cache: FederationCache<TBundlerCache>;
|
|
37
|
+
}
|
|
38
|
+
export interface NFBuildAdapterResult {
|
|
39
|
+
fileName: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface BuildNotificationOptions {
|
|
2
|
+
enable: boolean;
|
|
3
|
+
endpoint: string;
|
|
4
|
+
}
|
|
5
|
+
export declare enum BuildNotificationType {
|
|
6
|
+
COMPLETED = "federation-rebuild-complete",
|
|
7
|
+
ERROR = "federation-rebuild-error",
|
|
8
|
+
CANCELLED = "federation-rebuild-cancelled"
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var BuildNotificationType;
|
|
2
|
+
(function (BuildNotificationType) {
|
|
3
|
+
BuildNotificationType["COMPLETED"] = "federation-rebuild-complete";
|
|
4
|
+
BuildNotificationType["ERROR"] = "federation-rebuild-error";
|
|
5
|
+
BuildNotificationType["CANCELLED"] = "federation-rebuild-cancelled";
|
|
6
|
+
})(BuildNotificationType || (BuildNotificationType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface FederationInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
exposes: ExposesInfo[];
|
|
4
|
+
shared: SharedInfo[];
|
|
5
|
+
chunks?: Record<string, string[]>;
|
|
6
|
+
buildNotificationsEndpoint?: string;
|
|
7
|
+
}
|
|
8
|
+
export type SharedInfo = {
|
|
9
|
+
singleton: boolean;
|
|
10
|
+
strictVersion: boolean;
|
|
11
|
+
requiredVersion: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
packageName: string;
|
|
14
|
+
shareScope?: string;
|
|
15
|
+
bundle?: string;
|
|
16
|
+
outFileName: string;
|
|
17
|
+
dev?: {
|
|
18
|
+
entryPoint: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ChunkInfo = Record<string, string[]>;
|
|
22
|
+
export interface ExposesInfo {
|
|
23
|
+
key: string;
|
|
24
|
+
outFileName: string;
|
|
25
|
+
dev?: {
|
|
26
|
+
entryPoint: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface ArtifactInfo {
|
|
30
|
+
mappings: SharedInfo[];
|
|
31
|
+
exposes: ExposesInfo[];
|
|
32
|
+
chunks?: ChunkInfo;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BuildNotificationOptions } from './build-notification-options.contract.js';
|
|
2
|
+
import type { FederationCache } from './federation-cache.contract.js';
|
|
3
|
+
export interface FederationOptions {
|
|
4
|
+
workspaceRoot: string;
|
|
5
|
+
outputPath: string;
|
|
6
|
+
federationConfig: string;
|
|
7
|
+
projectName?: string;
|
|
8
|
+
cacheExternalArtifacts?: boolean;
|
|
9
|
+
tsConfig?: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
dev?: boolean;
|
|
12
|
+
watch?: boolean;
|
|
13
|
+
packageJson?: string;
|
|
14
|
+
entryPoints?: string[];
|
|
15
|
+
buildNotifications?: BuildNotificationOptions;
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizedFederationOptions<TBundlerCache = unknown> extends FederationOptions {
|
|
18
|
+
federationCache: FederationCache<TBundlerCache>;
|
|
19
|
+
entryPoints: string[];
|
|
20
|
+
projectName: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { SharedInfo, FederationInfo, ExposesInfo, ArtifactInfo, ChunkInfo, } from './federation-info.contract.js';
|
|
2
|
+
export { type BuildNotificationOptions, BuildNotificationType, } from './build-notification-options.contract.js';
|
|
3
|
+
export type { FederationOptions, NormalizedFederationOptions, } from './federation-options.contract.js';
|
|
4
|
+
export type { EntryPoint, NFBuildAdapterOptions, NFBuildAdapter, NFBuildAdapterResult, NFBuildAdapterContext, } from './build-adapter.contract.js';
|
|
5
|
+
export { CHUNK_PREFIX, toChunkImport } from './chunk.js';
|
|
6
|
+
export type { FederationCache } from './federation-cache.contract.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PathToImport = Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createBuildResultMap(buildResult:
|
|
1
|
+
import type { NFBuildAdapterResult } from '../domain/core/build-adapter.contract.js';
|
|
2
|
+
export declare function createBuildResultMap(buildResult: NFBuildAdapterResult[], isHashed: boolean): Record<string, string>;
|
|
3
3
|
export declare function lookupInResultMap(map: Record<string, string>, requestName: string): string;
|
|
4
|
+
export declare function popFromResultMap(map: Record<string, string>, requestName: string): string;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createBuildResultMap = createBuildResultMap;
|
|
4
|
-
exports.lookupInResultMap = lookupInResultMap;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
function createBuildResultMap(buildResult, isHashed) {
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export function createBuildResultMap(buildResult, isHashed) {
|
|
8
3
|
const map = {};
|
|
9
4
|
for (const item of buildResult) {
|
|
10
|
-
const resultName =
|
|
5
|
+
const resultName = path.basename(item.fileName);
|
|
11
6
|
let requestName = resultName;
|
|
12
7
|
if (isHashed) {
|
|
13
8
|
const start = resultName.lastIndexOf('-');
|
|
@@ -16,12 +11,18 @@ function createBuildResultMap(buildResult, isHashed) {
|
|
|
16
11
|
const part2 = resultName.substring(end);
|
|
17
12
|
requestName = part1 + part2;
|
|
18
13
|
}
|
|
19
|
-
map[requestName] =
|
|
14
|
+
map[requestName] = item.fileName;
|
|
20
15
|
}
|
|
21
16
|
return map;
|
|
22
17
|
}
|
|
23
|
-
function lookupInResultMap(map, requestName) {
|
|
24
|
-
const key =
|
|
25
|
-
|
|
18
|
+
export function lookupInResultMap(map, requestName) {
|
|
19
|
+
const key = path.basename(requestName);
|
|
20
|
+
// path.basename is to maintain backwards compatible
|
|
21
|
+
return path.basename(map[key]);
|
|
22
|
+
}
|
|
23
|
+
export function popFromResultMap(map, requestName) {
|
|
24
|
+
const key = path.basename(requestName);
|
|
25
|
+
const out = map[key];
|
|
26
|
+
delete map[key];
|
|
27
|
+
return out;
|
|
26
28
|
}
|
|
27
|
-
//# sourceMappingURL=build-result-map.js.map
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SharedInfo } from '
|
|
3
|
-
export declare const
|
|
1
|
+
import type { NormalizedExternalConfig } from '../domain/config/external-config.contract.js';
|
|
2
|
+
import type { ChunkInfo, SharedInfo } from '../domain/core/federation-info.contract.js';
|
|
3
|
+
export declare const getDefaultCachePath: (workspaceRoot: string) => string;
|
|
4
4
|
export declare const getFilename: (title: string, dev?: boolean) => string;
|
|
5
|
-
export declare const getChecksum: (shared: Record<string,
|
|
5
|
+
export declare const getChecksum: (shared: Record<string, NormalizedExternalConfig>, dev: "1" | "0") => string;
|
|
6
6
|
export declare const cacheEntry: (pathToCache: string, fileName: string) => {
|
|
7
7
|
getMetadata: (checksum: string) => {
|
|
8
8
|
checksum: string;
|
|
9
9
|
externals: SharedInfo[];
|
|
10
|
+
chunks?: ChunkInfo;
|
|
10
11
|
files: string[];
|
|
11
12
|
} | undefined;
|
|
12
13
|
persist: (payload: {
|
|
13
14
|
checksum: string;
|
|
14
15
|
externals: SharedInfo[];
|
|
16
|
+
chunks?: ChunkInfo;
|
|
15
17
|
files: string[];
|
|
16
18
|
}) => void;
|
|
17
19
|
copyFiles: (fullOutputPath: string) => void;
|