@softarc/native-federation 3.5.1 → 4.0.0-RC2
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 +8 -1
- package/src/index.js +8 -5
- package/src/internal.d.ts +11 -0
- package/src/internal.js +8 -0
- package/src/lib/config/configuration-context.js +3 -9
- package/src/lib/config/default-skip-list.d.ts +4 -0
- package/src/lib/{core → config}/default-skip-list.js +10 -16
- package/src/lib/config/share-utils.d.ts +6 -17
- package/src/lib/config/share-utils.js +50 -123
- package/src/lib/config/with-native-federation.d.ts +1 -1
- package/src/lib/config/with-native-federation.js +37 -38
- package/src/lib/core/build-adapter.d.ts +3 -28
- package/src/lib/core/build-adapter.js +4 -9
- package/src/lib/core/build-for-federation.d.ts +4 -8
- package/src/lib/core/build-for-federation.js +73 -60
- package/src/lib/core/bundle-exposed-and-mappings.d.ts +4 -8
- package/src/lib/core/bundle-exposed-and-mappings.js +32 -42
- package/src/lib/core/bundle-shared.d.ts +9 -5
- package/src/lib/core/bundle-shared.js +80 -68
- package/src/lib/core/default-external-list.js +1 -5
- package/src/lib/core/default-server-deps-list.js +2 -6
- package/src/lib/core/federation-builder.d.ts +6 -6
- package/src/lib/core/federation-builder.js +14 -19
- package/src/lib/core/get-externals.d.ts +1 -1
- package/src/lib/core/get-externals.js +2 -6
- package/src/lib/core/load-federation-config.d.ts +2 -2
- package/src/lib/core/load-federation-config.js +6 -12
- package/src/lib/core/remove-unused-deps.d.ts +1 -1
- package/src/lib/core/remove-unused-deps.js +21 -29
- 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 +41 -0
- package/src/lib/domain/config/external-config.contract.js +1 -0
- package/src/lib/domain/config/federation-config.contract.d.ts +29 -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/core/build-adapter.contract.d.ts +28 -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/build-params.contract.d.ts +5 -0
- package/src/lib/domain/core/build-params.contract.js +1 -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-info.contract.d.ts +32 -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} +5 -1
- 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 +4 -0
- package/src/lib/domain/utils/mapped-path.contract.js +1 -0
- package/src/lib/utils/build-result-map.d.ts +2 -2
- package/src/lib/utils/build-result-map.js +5 -11
- package/src/lib/utils/build-utils.d.ts +2 -2
- package/src/lib/utils/build-utils.js +3 -7
- package/src/lib/utils/bundle-caching.d.ts +5 -3
- package/src/lib/utils/bundle-caching.js +35 -47
- package/src/lib/utils/errors.js +1 -6
- package/src/lib/utils/get-external-imports.js +5 -10
- 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 +1 -4
- package/src/lib/utils/mapped-paths.js +4 -9
- package/src/lib/utils/normalize.js +2 -7
- package/src/lib/utils/package-info.js +36 -47
- package/src/lib/utils/rebuild-queue.js +5 -10
- package/src/lib/utils/resolve-glob.js +3 -8
- package/src/lib/utils/resolve-wildcard-keys.d.ts +1 -4
- package/src/lib/utils/resolve-wildcard-keys.js +3 -8
- 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.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
package/package.json
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softarc/native-federation",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "4.0.0-RC2",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"
|
|
7
|
+
"@softarc/sheriff-core": "^0.19.6",
|
|
8
8
|
"chalk": "^5.6.2",
|
|
9
|
-
"@softarc/native-federation-runtime": "~3.5.1",
|
|
10
9
|
"fast-glob": "^3.3.3",
|
|
11
|
-
"
|
|
10
|
+
"json5": "^2.2.3",
|
|
11
|
+
"esbuild": "^0.27.0"
|
|
12
12
|
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./src/index.d.ts",
|
|
17
|
+
"import": "./src/index.js",
|
|
18
|
+
"default": "./src/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./config": {
|
|
21
|
+
"types": "./src/config.d.ts",
|
|
22
|
+
"import": "./src/config.js",
|
|
23
|
+
"default": "./src/config.js"
|
|
24
|
+
},
|
|
25
|
+
"./domain": {
|
|
26
|
+
"types": "./src/domain.d.ts",
|
|
27
|
+
"import": "./src/domain.js",
|
|
28
|
+
"default": "./src/domain.js"
|
|
29
|
+
},
|
|
30
|
+
"./internal": {
|
|
31
|
+
"types": "./src/internal.d.ts",
|
|
32
|
+
"import": "./src/internal.js",
|
|
33
|
+
"default": "./src/internal.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"src",
|
|
38
|
+
"!**/*.tsbuildinfo"
|
|
39
|
+
],
|
|
13
40
|
"types": "./src/index.d.ts",
|
|
41
|
+
"module": "./src/index.js",
|
|
14
42
|
"main": "./src/index.js"
|
|
15
43
|
}
|
package/src/config.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './lib/domain/config/index.js';
|
|
2
|
+
export { withNativeFederation } from './lib/config/with-native-federation.js';
|
|
3
|
+
export { findRootTsConfigJson, share, shareAll } from './lib/config/share-utils.js';
|
|
4
|
+
export { DEFAULT_SKIP_LIST } from './lib/config/default-skip-list.js';
|
package/src/config.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./build"), exports);
|
|
6
|
-
//# sourceMappingURL=config.js.map
|
|
1
|
+
export * from './lib/domain/config/index.js';
|
|
2
|
+
export { withNativeFederation } from './lib/config/with-native-federation.js';
|
|
3
|
+
export { findRootTsConfigJson, share, shareAll } from './lib/config/share-utils.js';
|
|
4
|
+
export { DEFAULT_SKIP_LIST } from './lib/config/default-skip-list.js';
|
package/src/domain.d.ts
ADDED
package/src/domain.js
ADDED
package/src/index.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { setBuildAdapter } from './lib/core/build-adapter.js';
|
|
2
|
+
export { buildForFederation } from './lib/core/build-for-federation.js';
|
|
3
|
+
export { bundleExposedAndMappings } from './lib/core/bundle-exposed-and-mappings.js';
|
|
4
|
+
export { getExternals } from './lib/core/get-externals.js';
|
|
5
|
+
export { loadFederationConfig } from './lib/core/load-federation-config.js';
|
|
6
|
+
export { writeFederationInfo } from './lib/core/write-federation-info.js';
|
|
7
|
+
export { type BuildHelperParams, federationBuilder } from './lib/core/federation-builder.js';
|
|
8
|
+
export * from './domain.js';
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { setBuildAdapter } from './lib/core/build-adapter.js';
|
|
2
|
+
export { buildForFederation } from './lib/core/build-for-federation.js';
|
|
3
|
+
export { bundleExposedAndMappings } from './lib/core/bundle-exposed-and-mappings.js';
|
|
4
|
+
export { getExternals } from './lib/core/get-externals.js';
|
|
5
|
+
export { loadFederationConfig } from './lib/core/load-federation-config.js';
|
|
6
|
+
export { writeFederationInfo } from './lib/core/write-federation-info.js';
|
|
7
|
+
export { federationBuilder } from './lib/core/federation-builder.js';
|
|
8
|
+
export * from './domain.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './lib/utils/build-result-map.js';
|
|
2
|
+
export { hashFile } from './lib/utils/hash-file.js';
|
|
3
|
+
export * from './lib/utils/errors.js';
|
|
4
|
+
export { logger, setLogLevel } from './lib/utils/logger.js';
|
|
5
|
+
export type { MappedPath } from './lib/domain/utils/mapped-path.contract.js';
|
|
6
|
+
export { RebuildQueue } from './lib/utils/rebuild-queue.js';
|
|
7
|
+
export { AbortedError } from './lib/utils/errors.js';
|
|
8
|
+
export { createBuildResultMap, lookupInResultMap } from './lib/utils/build-result-map.js';
|
|
9
|
+
export { writeImportMap } from './lib/core/write-import-map.js';
|
|
10
|
+
export type { NormalizedExternalConfig, NormalizedSharedExternalsConfig, } from './lib/domain/config/external-config.contract.js';
|
|
11
|
+
export type { NormalizedFederationConfig } from './lib/domain/config/federation-config.contract.js';
|
package/src/internal.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './lib/utils/build-result-map.js';
|
|
2
|
+
export { hashFile } from './lib/utils/hash-file.js';
|
|
3
|
+
export * from './lib/utils/errors.js';
|
|
4
|
+
export { logger, setLogLevel } from './lib/utils/logger.js';
|
|
5
|
+
export { RebuildQueue } from './lib/utils/rebuild-queue.js';
|
|
6
|
+
export { AbortedError } from './lib/utils/errors.js';
|
|
7
|
+
export { createBuildResultMap, lookupInResultMap } from './lib/utils/build-result-map.js';
|
|
8
|
+
export { writeImportMap } from './lib/core/write-import-map.js';
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWorkspace = useWorkspace;
|
|
4
|
-
exports.usePackageJson = usePackageJson;
|
|
5
|
-
exports.getConfigContext = getConfigContext;
|
|
6
1
|
let _context = {};
|
|
7
|
-
function useWorkspace(workspaceRoot) {
|
|
2
|
+
export function useWorkspace(workspaceRoot) {
|
|
8
3
|
_context = { ..._context, workspaceRoot };
|
|
9
4
|
}
|
|
10
|
-
function usePackageJson(packageJson) {
|
|
5
|
+
export function usePackageJson(packageJson) {
|
|
11
6
|
_context = { ..._context, packageJson };
|
|
12
7
|
}
|
|
13
|
-
function getConfigContext() {
|
|
8
|
+
export function getConfigContext() {
|
|
14
9
|
return _context;
|
|
15
10
|
}
|
|
16
|
-
//# sourceMappingURL=configuration-context.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PreparedSkipList, SkipList } from '../domain/config/skip-list.contract.js';
|
|
2
|
+
export declare const DEFAULT_SKIP_LIST: SkipList;
|
|
3
|
+
export declare function prepareSkipList(skipList: SkipList): PreparedSkipList;
|
|
4
|
+
export declare function isInSkipList(entry: string, skipList: PreparedSkipList): boolean;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SKIP_LIST = void 0;
|
|
4
|
-
exports.prepareSkipList = prepareSkipList;
|
|
5
|
-
exports.isInSkipList = isInSkipList;
|
|
6
|
-
exports.DEFAULT_SKIP_LIST = [
|
|
1
|
+
export const DEFAULT_SKIP_LIST = [
|
|
7
2
|
'@softarc/native-federation-runtime',
|
|
8
3
|
'@softarc/native-federation',
|
|
9
4
|
'@softarc/native-federation-core',
|
|
@@ -22,28 +17,27 @@ exports.DEFAULT_SKIP_LIST = [
|
|
|
22
17
|
// '@angular/ssr',
|
|
23
18
|
/\/schematics(\/|$)/,
|
|
24
19
|
/^@nx\/angular/,
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
pkg => pkg.startsWith('@angular/') && !!pkg.match(/\/testing(\/|$)/),
|
|
21
|
+
pkg => pkg.startsWith('@types/'),
|
|
27
22
|
'express',
|
|
28
23
|
// (pkg) => pkg.startsWith('@angular/common/locales'),
|
|
29
24
|
];
|
|
30
|
-
function prepareSkipList(skipList) {
|
|
25
|
+
export function prepareSkipList(skipList) {
|
|
31
26
|
return {
|
|
32
|
-
strings: new Set(skipList.filter(
|
|
33
|
-
functions: skipList.filter(
|
|
34
|
-
regexps: skipList.filter(
|
|
27
|
+
strings: new Set(skipList.filter(e => typeof e === 'string')),
|
|
28
|
+
functions: skipList.filter(e => typeof e === 'function'),
|
|
29
|
+
regexps: skipList.filter(e => typeof e === 'object'),
|
|
35
30
|
};
|
|
36
31
|
}
|
|
37
|
-
function isInSkipList(entry, skipList) {
|
|
32
|
+
export function isInSkipList(entry, skipList) {
|
|
38
33
|
if (skipList.strings.has(entry)) {
|
|
39
34
|
return true;
|
|
40
35
|
}
|
|
41
|
-
if (skipList.functions.find(
|
|
36
|
+
if (skipList.functions.find(f => f(entry))) {
|
|
42
37
|
return true;
|
|
43
38
|
}
|
|
44
|
-
if (skipList.regexps.find(
|
|
39
|
+
if (skipList.regexps.find(r => r.test(entry))) {
|
|
45
40
|
return true;
|
|
46
41
|
}
|
|
47
42
|
return false;
|
|
48
43
|
}
|
|
49
|
-
//# sourceMappingURL=default-skip-list.js.map
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type SkipList } from '../domain/config/skip-list.contract.js';
|
|
2
|
+
import type { ShareAllExternalsOptions, ShareExternalsOptions } from '../domain/config/external-config.contract.js';
|
|
3
3
|
export declare const DEFAULT_SECONDARIES_SKIP_LIST: string[];
|
|
4
|
-
type IncludeSecondariesOptions = {
|
|
5
|
-
skip: string | string[];
|
|
6
|
-
resolveGlob?: boolean;
|
|
7
|
-
keepAll?: boolean;
|
|
8
|
-
} | boolean;
|
|
9
|
-
type CustomSharedConfig = SharedConfig & {
|
|
10
|
-
includeSecondaries?: IncludeSecondariesOptions;
|
|
11
|
-
};
|
|
12
|
-
type ConfigObject = Record<string, CustomSharedConfig>;
|
|
13
|
-
type Config = (string | ConfigObject)[] | ConfigObject;
|
|
14
4
|
export declare function findRootTsConfigJson(): string;
|
|
15
|
-
export declare function shareAll(config
|
|
5
|
+
export declare function shareAll(config: ShareAllExternalsOptions, opts?: {
|
|
16
6
|
skipList?: SkipList;
|
|
17
7
|
projectPath?: string;
|
|
18
|
-
overrides?:
|
|
19
|
-
}):
|
|
8
|
+
overrides?: ShareExternalsOptions;
|
|
9
|
+
}): ShareExternalsOptions | null;
|
|
20
10
|
export declare function setInferVersion(infer: boolean): void;
|
|
21
|
-
export declare function share(configuredShareObjects:
|
|
22
|
-
export {};
|
|
11
|
+
export declare function share(configuredShareObjects: ShareExternalsOptions, projectPath?: string, skipList?: SkipList): ShareExternalsOptions;
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const process_1 = require("process");
|
|
11
|
-
const default_skip_list_1 = require("../core/default-skip-list");
|
|
12
|
-
const package_info_1 = require("../utils/package-info");
|
|
13
|
-
const configuration_context_1 = require("./configuration-context");
|
|
14
|
-
const logger_1 = require("../utils/logger");
|
|
15
|
-
const resolve_wildcard_keys_1 = require("../utils/resolve-wildcard-keys");
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { cwd } from 'process';
|
|
4
|
+
import { DEFAULT_SKIP_LIST, isInSkipList, prepareSkipList } from './default-skip-list.js';
|
|
5
|
+
import { findDepPackageJson, getVersionMaps } from '../utils/package-info.js';
|
|
6
|
+
import { getConfigContext } from './configuration-context.js';
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
|
+
import { resolveWildcardKeys } from '../utils/resolve-wildcard-keys.js';
|
|
16
9
|
let inferVersion = false;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
];
|
|
21
|
-
function findRootTsConfigJson() {
|
|
22
|
-
const packageJson = findPackageJson((0, process_1.cwd)());
|
|
10
|
+
export const DEFAULT_SECONDARIES_SKIP_LIST = ['@angular/router/upgrade', '@angular/common/upgrade'];
|
|
11
|
+
export function findRootTsConfigJson() {
|
|
12
|
+
const packageJson = findPackageJson(cwd());
|
|
23
13
|
const projectRoot = path.dirname(packageJson);
|
|
24
14
|
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
25
15
|
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
@@ -32,19 +22,17 @@ function findRootTsConfigJson() {
|
|
|
32
22
|
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
33
23
|
}
|
|
34
24
|
function findPackageJson(folder) {
|
|
35
|
-
while (!fs.existsSync(path.join(folder, 'package.json')) &&
|
|
36
|
-
path.dirname(folder) !== folder) {
|
|
25
|
+
while (!fs.existsSync(path.join(folder, 'package.json')) && path.dirname(folder) !== folder) {
|
|
37
26
|
folder = path.dirname(folder);
|
|
38
27
|
}
|
|
39
28
|
const filePath = path.join(folder, 'package.json');
|
|
40
29
|
if (fs.existsSync(filePath)) {
|
|
41
30
|
return filePath;
|
|
42
31
|
}
|
|
43
|
-
throw new Error('no package.json found. Searched the following folder and all parents: ' +
|
|
44
|
-
folder);
|
|
32
|
+
throw new Error('no package.json found. Searched the following folder and all parents: ' + folder);
|
|
45
33
|
}
|
|
46
34
|
function lookupVersion(key, workspaceRoot) {
|
|
47
|
-
const versionMaps =
|
|
35
|
+
const versionMaps = getVersionMaps(workspaceRoot, workspaceRoot);
|
|
48
36
|
for (const versionMap of versionMaps) {
|
|
49
37
|
const version = lookupVersionInMap(key, versionMap);
|
|
50
38
|
if (version) {
|
|
@@ -72,18 +60,15 @@ function lookupVersionInMap(key, versions) {
|
|
|
72
60
|
function _findSecondaries(libPath, excludes, shareObject, acc, preparedSkipList) {
|
|
73
61
|
const files = fs.readdirSync(libPath);
|
|
74
62
|
const secondaries = files
|
|
75
|
-
.map(
|
|
76
|
-
.filter(
|
|
63
|
+
.map(f => path.join(libPath, f))
|
|
64
|
+
.filter(f => fs.lstatSync(f).isDirectory() && !f.endsWith('node_modules'));
|
|
77
65
|
for (const s of secondaries) {
|
|
78
66
|
if (fs.existsSync(path.join(s, 'package.json'))) {
|
|
79
|
-
const secondaryLibName = s
|
|
80
|
-
|
|
81
|
-
.replace(/^.*node_modules[/]/, '');
|
|
82
|
-
const inCustomSkipList = excludes.some((e) => e === secondaryLibName ||
|
|
83
|
-
(e.endsWith('*') && secondaryLibName.startsWith(e.slice(0, -1))));
|
|
67
|
+
const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
|
|
68
|
+
const inCustomSkipList = excludes.some(e => e === secondaryLibName || (e.endsWith('*') && secondaryLibName.startsWith(e.slice(0, -1))));
|
|
84
69
|
if (inCustomSkipList)
|
|
85
70
|
continue;
|
|
86
|
-
if (
|
|
71
|
+
if (isInSkipList(secondaryLibName, preparedSkipList)) {
|
|
87
72
|
continue;
|
|
88
73
|
}
|
|
89
74
|
acc[secondaryLibName] = { ...shareObject };
|
|
@@ -97,7 +82,7 @@ function findSecondaries(libPath, excludes, shareObject, preparedSkipList) {
|
|
|
97
82
|
return acc;
|
|
98
83
|
}
|
|
99
84
|
function getSecondaries(includeSecondaries, libPath, key, shareObject, preparedSkipList) {
|
|
100
|
-
let exclude = [...
|
|
85
|
+
let exclude = [...DEFAULT_SECONDARIES_SKIP_LIST];
|
|
101
86
|
let resolveGlob = false;
|
|
102
87
|
if (typeof includeSecondaries === 'object') {
|
|
103
88
|
if (Array.isArray(includeSecondaries.skip)) {
|
|
@@ -132,21 +117,18 @@ function readConfiguredSecondaries(parent, libPath, exclude, shareObject, prepar
|
|
|
132
117
|
if (!exports) {
|
|
133
118
|
return null;
|
|
134
119
|
}
|
|
135
|
-
const keys = Object.keys(exports).filter(
|
|
136
|
-
key
|
|
120
|
+
const keys = Object.keys(exports).filter(key => key !== '.' &&
|
|
121
|
+
key !== './package.json' &&
|
|
137
122
|
key.startsWith('./') &&
|
|
138
|
-
(exports[key]['default'] ||
|
|
139
|
-
exports[key]['import'] ||
|
|
140
|
-
typeof exports[key] === 'string'));
|
|
123
|
+
(exports[key]?.['default'] || exports[key]?.['import'] || typeof exports[key] === 'string'));
|
|
141
124
|
const result = {};
|
|
142
125
|
const discoveredFiles = new Set();
|
|
143
126
|
for (const key of keys) {
|
|
144
127
|
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
145
|
-
const inCustomSkipList = exclude.some(
|
|
146
|
-
(e.endsWith('*') && secondaryName.startsWith(e.slice(0, -1))));
|
|
128
|
+
const inCustomSkipList = exclude.some(e => e === secondaryName || (e.endsWith('*') && secondaryName.startsWith(e.slice(0, -1))));
|
|
147
129
|
if (inCustomSkipList)
|
|
148
130
|
continue;
|
|
149
|
-
if (
|
|
131
|
+
if (isInSkipList(secondaryName, preparedSkipList)) {
|
|
150
132
|
continue;
|
|
151
133
|
}
|
|
152
134
|
const entry = getDefaultEntry(exports, key);
|
|
@@ -154,13 +136,11 @@ function readConfiguredSecondaries(parent, libPath, exclude, shareObject, prepar
|
|
|
154
136
|
console.log('No entry point found for ' + secondaryName);
|
|
155
137
|
continue;
|
|
156
138
|
}
|
|
157
|
-
if (!entry?.endsWith('.js') &&
|
|
158
|
-
!entry?.endsWith('.mjs') &&
|
|
159
|
-
!entry?.endsWith('.cjs')) {
|
|
139
|
+
if (!entry?.endsWith('.js') && !entry?.endsWith('.mjs') && !entry?.endsWith('.cjs')) {
|
|
160
140
|
continue;
|
|
161
141
|
}
|
|
162
142
|
const items = resolveGlobSecondaries(key, libPath, parent, secondaryName, entry, { discovered: discoveredFiles, skip: exclude }, resolveGlob);
|
|
163
|
-
items.forEach(
|
|
143
|
+
items.forEach(e => discoveredFiles.add(typeof e === 'string' ? e : e.value));
|
|
164
144
|
for (const item of items) {
|
|
165
145
|
if (typeof item === 'object') {
|
|
166
146
|
result[item.key] = {
|
|
@@ -186,14 +166,14 @@ function resolveGlobSecondaries(key, libPath, parent, secondaryName, entry, excl
|
|
|
186
166
|
if (key.includes('*')) {
|
|
187
167
|
if (!resolveGlob)
|
|
188
168
|
return items;
|
|
189
|
-
const expanded =
|
|
169
|
+
const expanded = resolveWildcardKeys(key, entry, libPath);
|
|
190
170
|
items = expanded
|
|
191
|
-
.map(
|
|
171
|
+
.map(e => ({
|
|
192
172
|
key: path.join(parent, e.key),
|
|
193
173
|
value: path.join(libPath, e.value),
|
|
194
174
|
}))
|
|
195
|
-
.filter(
|
|
196
|
-
if (excludes.skip.some(
|
|
175
|
+
.filter(i => {
|
|
176
|
+
if (excludes.skip.some(e => e.endsWith('*') ? i.key.startsWith(e.slice(0, -1)) : e === i.key)) {
|
|
197
177
|
return false;
|
|
198
178
|
}
|
|
199
179
|
if (excludes.discovered.has(i.value)) {
|
|
@@ -232,110 +212,58 @@ function getDefaultEntry(exports, key) {
|
|
|
232
212
|
}
|
|
233
213
|
return entry;
|
|
234
214
|
}
|
|
235
|
-
function shareAll(config
|
|
215
|
+
export function shareAll(config, opts = {}) {
|
|
236
216
|
// let workspacePath: string | undefined = undefined;
|
|
237
217
|
const projectPath = inferProjectPath(opts.projectPath);
|
|
238
218
|
// workspacePath = getConfigContext().workspaceRoot ?? '';
|
|
239
219
|
// if (!workspacePath) {
|
|
240
220
|
// workspacePath = projectPath;
|
|
241
221
|
// }
|
|
242
|
-
const versionMaps =
|
|
222
|
+
const versionMaps = getVersionMaps(projectPath, projectPath);
|
|
243
223
|
const sharedExternals = {};
|
|
244
|
-
const preparedSkipList =
|
|
224
|
+
const preparedSkipList = prepareSkipList(opts.skipList ?? DEFAULT_SKIP_LIST);
|
|
245
225
|
for (const versions of versionMaps) {
|
|
246
226
|
for (const key in versions) {
|
|
247
|
-
if (
|
|
227
|
+
if (isInSkipList(key, preparedSkipList)) {
|
|
248
228
|
continue;
|
|
249
229
|
}
|
|
250
|
-
if (!!opts.overrides &&
|
|
251
|
-
Object.keys(opts.overrides).some((o) => key.startsWith(o))) {
|
|
230
|
+
if (!!opts.overrides && Object.keys(opts.overrides).some(o => key.startsWith(o))) {
|
|
252
231
|
continue;
|
|
253
232
|
}
|
|
254
233
|
const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
|
|
255
|
-
const requiredVersion = inferVersion
|
|
256
|
-
? versions[key]
|
|
257
|
-
: config.requiredVersion;
|
|
234
|
+
const requiredVersion = inferVersion ? versions[key] : config.requiredVersion;
|
|
258
235
|
if (!sharedExternals[key]) {
|
|
259
236
|
sharedExternals[key] = { ...config, requiredVersion };
|
|
260
237
|
}
|
|
261
238
|
}
|
|
262
239
|
}
|
|
263
240
|
return {
|
|
264
|
-
...share(sharedExternals, opts.projectPath, opts.skipList ??
|
|
241
|
+
...share(sharedExternals, opts.projectPath, opts.skipList ?? DEFAULT_SKIP_LIST),
|
|
265
242
|
...(!opts.overrides
|
|
266
243
|
? {}
|
|
267
|
-
: share(opts.overrides, opts.projectPath, opts.skipList ??
|
|
244
|
+
: share(opts.overrides, opts.projectPath, opts.skipList ?? DEFAULT_SKIP_LIST)),
|
|
268
245
|
};
|
|
269
246
|
}
|
|
270
247
|
function inferProjectPath(projectPath) {
|
|
271
|
-
if (!projectPath &&
|
|
272
|
-
projectPath = path.dirname(
|
|
248
|
+
if (!projectPath && getConfigContext().packageJson) {
|
|
249
|
+
projectPath = path.dirname(getConfigContext().packageJson || '');
|
|
273
250
|
}
|
|
274
|
-
if (!projectPath &&
|
|
275
|
-
projectPath =
|
|
251
|
+
if (!projectPath && getConfigContext().workspaceRoot) {
|
|
252
|
+
projectPath = getConfigContext().workspaceRoot || '';
|
|
276
253
|
}
|
|
277
254
|
if (!projectPath) {
|
|
278
|
-
projectPath =
|
|
255
|
+
projectPath = cwd();
|
|
279
256
|
}
|
|
280
257
|
return projectPath;
|
|
281
258
|
}
|
|
282
|
-
function setInferVersion(infer) {
|
|
259
|
+
export function setInferVersion(infer) {
|
|
283
260
|
inferVersion = infer;
|
|
284
261
|
}
|
|
285
|
-
function
|
|
286
|
-
const discovered = new Set();
|
|
287
|
-
const result = [];
|
|
288
|
-
const packageNames = Object.keys(configuredShareObjects);
|
|
289
|
-
for (const packageName of packageNames) {
|
|
290
|
-
const shareConfig = configuredShareObjects[packageName];
|
|
291
|
-
if (typeof shareConfig === 'object' && shareConfig.transient) {
|
|
292
|
-
logger_1.logger.warn('PLEASE NOTE: The transient flag in your federation.config.js');
|
|
293
|
-
logger_1.logger.warn('is deprecated. Please remove it. Meanwhile, Native Federation');
|
|
294
|
-
logger_1.logger.warn('uses the underlying bundler for splitting transient');
|
|
295
|
-
logger_1.logger.warn('dependencies into separate chunks, _when_ necessary.');
|
|
296
|
-
const packagePath = path.join(projectRoot, 'node_modules', packageName, 'package.json');
|
|
297
|
-
_findTransientDeps(packagePath, projectRoot, preparedSkipList, discovered, result);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return result;
|
|
301
|
-
}
|
|
302
|
-
function _findTransientDeps(packagePath, projectRoot, preparedSkipList, discovered, result) {
|
|
303
|
-
if (!fs.existsSync(packagePath)) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
|
|
307
|
-
const deps = Object.keys(packageJson.dependencies ?? {});
|
|
308
|
-
for (const dep of deps) {
|
|
309
|
-
const depPackageJson = path.join(projectRoot, 'node_modules', dep, 'package.json');
|
|
310
|
-
const depPath = path.dirname(depPackageJson);
|
|
311
|
-
if (!discovered.has(depPackageJson) &&
|
|
312
|
-
!(0, default_skip_list_1.isInSkipList)(dep, preparedSkipList) &&
|
|
313
|
-
fs.existsSync(depPackageJson)) {
|
|
314
|
-
discovered.add(depPackageJson);
|
|
315
|
-
const version = packageJson.dependencies[dep];
|
|
316
|
-
result.push({
|
|
317
|
-
packageName: dep,
|
|
318
|
-
requiredVersion: version,
|
|
319
|
-
packagePath: depPath,
|
|
320
|
-
});
|
|
321
|
-
_findTransientDeps(depPackageJson, projectRoot, preparedSkipList, discovered, result);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
function share(configuredShareObjects, projectPath = '', skipList = default_skip_list_1.DEFAULT_SKIP_LIST) {
|
|
262
|
+
export function share(configuredShareObjects, projectPath = '', skipList = DEFAULT_SKIP_LIST) {
|
|
326
263
|
projectPath = inferProjectPath(projectPath);
|
|
327
264
|
const packagePath = findPackageJson(projectPath);
|
|
328
|
-
const
|
|
329
|
-
const
|
|
330
|
-
const transientDeps = findTransientDeps(configuredShareObjects, packageDirectory, preparedSkipList);
|
|
331
|
-
const transientShareObject = transientDeps.reduce((acc, curr) => ({
|
|
332
|
-
...acc,
|
|
333
|
-
[curr.packageName]: { path: curr.packagePath },
|
|
334
|
-
}), {});
|
|
335
|
-
const shareObjects = {
|
|
336
|
-
...configuredShareObjects,
|
|
337
|
-
...transientShareObject,
|
|
338
|
-
};
|
|
265
|
+
const preparedSkipList = prepareSkipList(skipList);
|
|
266
|
+
const shareObjects = { ...configuredShareObjects };
|
|
339
267
|
const result = {};
|
|
340
268
|
let includeSecondaries;
|
|
341
269
|
for (const key in shareObjects) {
|
|
@@ -358,9 +286,9 @@ function share(configuredShareObjects, projectPath = '', skipList = default_skip
|
|
|
358
286
|
}
|
|
359
287
|
result[key] = shareObject;
|
|
360
288
|
if (includeSecondaries) {
|
|
361
|
-
const libPackageJson =
|
|
289
|
+
const libPackageJson = findDepPackageJson(key, path.dirname(packagePath));
|
|
362
290
|
if (!libPackageJson) {
|
|
363
|
-
|
|
291
|
+
logger.error('Could not find folder containing dep ' + key);
|
|
364
292
|
continue;
|
|
365
293
|
}
|
|
366
294
|
const libPath = path.dirname(libPackageJson);
|
|
@@ -377,4 +305,3 @@ function addSecondaries(secondaries, result) {
|
|
|
377
305
|
result[key] = secondaries[key];
|
|
378
306
|
}
|
|
379
307
|
}
|
|
380
|
-
//# sourceMappingURL=share-utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FederationConfig, NormalizedFederationConfig } from '
|
|
1
|
+
import type { FederationConfig, NormalizedFederationConfig } from '../domain/config/federation-config.contract.js';
|
|
2
2
|
export declare function withNativeFederation(config: FederationConfig): NormalizedFederationConfig;
|