@softarc/native-federation 4.1.3 → 4.2.0
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/LICENSE.md +7 -0
- package/README.md +638 -0
- package/dist/config.js +17 -0
- package/dist/domain.js +2 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21 -0
- package/{src → dist}/internal.d.ts +6 -7
- package/dist/internal.js +26 -0
- package/dist/lib/config/configuration-context.js +15 -0
- package/dist/lib/config/default-skip-list.js +36 -0
- package/dist/lib/config/get-external-imports.d.ts +2 -0
- package/dist/lib/config/get-external-imports.js +60 -0
- package/dist/lib/config/get-used-dependencies.d.ts +24 -0
- package/dist/lib/config/get-used-dependencies.js +126 -0
- package/{src/lib/utils → dist/lib/config}/mapped-paths.d.ts +2 -2
- package/dist/lib/config/mapped-paths.js +31 -0
- package/dist/lib/config/remove-unused-deps.js +11 -0
- package/dist/lib/config/share-utils.d.ts +20 -0
- package/dist/lib/config/share-utils.js +344 -0
- package/dist/lib/config/with-native-federation.js +80 -0
- package/{src/lib/core → dist/lib/core/build}/build-adapter.d.ts +1 -1
- package/dist/lib/core/build/build-adapter.js +16 -0
- package/dist/lib/core/build/build-for-federation.d.ts +4 -0
- package/dist/lib/core/build/build-for-federation.js +207 -0
- package/{src/lib/utils → dist/lib/core/build}/build-result-map.d.ts +1 -1
- package/dist/lib/core/build/build-result-map.js +39 -0
- package/dist/lib/core/build/bundle-exposed-and-mappings.d.ts +13 -0
- package/dist/lib/core/build/bundle-exposed-and-mappings.js +178 -0
- package/dist/lib/core/build/bundle-shared.d.ts +34 -0
- package/dist/lib/core/build/bundle-shared.js +261 -0
- package/dist/lib/core/build/compute-integrity.d.ts +11 -0
- package/dist/lib/core/build/compute-integrity.js +20 -0
- package/dist/lib/core/build/default-external-list.js +32 -0
- package/dist/lib/core/build/get-externals.d.ts +2 -0
- package/dist/lib/core/build/get-externals.js +9 -0
- package/dist/lib/core/build/rebuild-for-federation.d.ts +4 -0
- package/dist/lib/core/build/rebuild-for-federation.js +52 -0
- package/dist/lib/core/build/rewrite-chunk-imports.d.ts +5 -0
- package/dist/lib/core/build/rewrite-chunk-imports.js +74 -0
- package/dist/lib/core/cache/cache-persistence.d.ts +22 -0
- package/dist/lib/core/cache/cache-persistence.js +63 -0
- package/{src/lib/core → dist/lib/core/cache}/federation-cache.d.ts +2 -2
- package/dist/lib/core/cache/federation-cache.js +22 -0
- package/dist/lib/core/federation-builder.js +53 -0
- package/{src → dist}/lib/core/normalize-options.d.ts +13 -1
- package/dist/lib/core/normalize-options.js +67 -0
- package/dist/lib/core/output/write-federation-info.d.ts +5 -0
- package/dist/lib/core/output/write-federation-info.js +17 -0
- package/dist/lib/core/output/write-import-map.d.ts +11 -0
- package/dist/lib/core/output/write-import-map.js +42 -0
- package/dist/lib/core/rebuild-queue.js +61 -0
- package/{src → dist}/lib/domain/config/external-config.contract.d.ts +2 -2
- package/dist/lib/domain/config/external-config.contract.js +0 -0
- package/dist/lib/domain/config/federation-config.contract.js +0 -0
- package/dist/lib/domain/config/index.js +0 -0
- package/dist/lib/domain/config/skip-list.contract.js +0 -0
- package/dist/lib/domain/core/build-adapter.contract.js +0 -0
- package/dist/lib/domain/core/build-notification-options.contract.js +9 -0
- package/dist/lib/domain/core/chunk.js +12 -0
- package/dist/lib/domain/core/federation-cache.contract.js +0 -0
- package/dist/lib/domain/core/federation-info.contract.js +0 -0
- package/dist/lib/domain/core/federation-options.contract.js +0 -0
- package/dist/lib/domain/core/index.js +9 -0
- package/dist/lib/domain/core/manifest.contract.js +0 -0
- package/dist/lib/domain/utils/file-watcher.contract.js +0 -0
- package/dist/lib/domain/utils/io-port.contract.d.ts +45 -0
- package/dist/lib/domain/utils/io-port.contract.js +0 -0
- package/dist/lib/domain/utils/keyvaluepair.contract.js +0 -0
- package/dist/lib/domain/utils/mapped-path.contract.js +0 -0
- package/dist/lib/domain/utils/package-json.contract.d.ts +27 -0
- package/dist/lib/domain/utils/package-json.contract.js +0 -0
- package/dist/lib/domain/utils/used-dependencies.contract.js +0 -0
- package/dist/lib/utils/errors.js +10 -0
- package/{src → dist}/lib/utils/file-watcher.d.ts +2 -0
- package/dist/lib/utils/file-watcher.js +51 -0
- package/dist/lib/utils/hash-file.d.ts +7 -0
- package/dist/lib/utils/hash-file.js +15 -0
- package/dist/lib/utils/io/node-io-adapter.d.ts +2 -0
- package/dist/lib/utils/io/node-io-adapter.js +68 -0
- package/dist/lib/utils/io/package-json-repository.d.ts +5 -0
- package/dist/lib/utils/io/package-json-repository.js +79 -0
- package/dist/lib/utils/logger.js +29 -0
- package/dist/lib/utils/normalize.js +22 -0
- package/dist/lib/utils/package/entry-point-resolver.d.ts +2 -0
- package/dist/lib/utils/package/entry-point-resolver.js +78 -0
- package/dist/lib/utils/package/esm-detection.d.ts +5 -0
- package/dist/lib/utils/package/esm-detection.js +10 -0
- package/dist/lib/utils/package/exports-resolver.d.ts +13 -0
- package/dist/lib/utils/package/exports-resolver.js +55 -0
- package/dist/lib/utils/package/package-info.d.ts +7 -0
- package/dist/lib/utils/package/package-info.js +31 -0
- package/dist/lib/utils/package/resolve-wildcard-keys.d.ts +3 -0
- package/dist/lib/utils/package/resolve-wildcard-keys.js +22 -0
- package/dist/lib/utils/package/version-maps.d.ts +3 -0
- package/dist/lib/utils/package/version-maps.js +8 -0
- package/dist/lib/utils/path-patterns.d.ts +14 -0
- package/dist/lib/utils/path-patterns.js +28 -0
- package/package.json +45 -22
- package/src/config.js +0 -4
- package/src/domain.js +0 -2
- package/src/index.d.ts +0 -10
- package/src/index.js +0 -10
- package/src/internal.js +0 -11
- package/src/lib/config/configuration-context.js +0 -10
- package/src/lib/config/default-skip-list.js +0 -31
- package/src/lib/config/remove-unused-deps.js +0 -10
- package/src/lib/config/share-utils.d.ts +0 -10
- package/src/lib/config/share-utils.js +0 -302
- package/src/lib/config/with-native-federation.js +0 -79
- package/src/lib/core/build-adapter.js +0 -12
- package/src/lib/core/build-for-federation.d.ts +0 -4
- package/src/lib/core/build-for-federation.js +0 -173
- package/src/lib/core/bundle-exposed-and-mappings.d.ts +0 -7
- package/src/lib/core/bundle-exposed-and-mappings.js +0 -177
- package/src/lib/core/bundle-shared.d.ts +0 -13
- package/src/lib/core/bundle-shared.js +0 -222
- package/src/lib/core/default-external-list.js +0 -29
- package/src/lib/core/federation-builder.js +0 -45
- package/src/lib/core/federation-cache.js +0 -16
- package/src/lib/core/get-externals.d.ts +0 -2
- package/src/lib/core/get-externals.js +0 -6
- package/src/lib/core/normalize-options.js +0 -58
- package/src/lib/core/rebuild-for-federation.d.ts +0 -4
- package/src/lib/core/rebuild-for-federation.js +0 -43
- package/src/lib/core/write-federation-info.d.ts +0 -3
- package/src/lib/core/write-federation-info.js +0 -6
- package/src/lib/core/write-import-map.d.ts +0 -6
- package/src/lib/core/write-import-map.js +0 -33
- package/src/lib/domain/config/external-config.contract.js +0 -1
- package/src/lib/domain/config/federation-config.contract.js +0 -1
- package/src/lib/domain/config/index.js +0 -1
- package/src/lib/domain/config/skip-list.contract.js +0 -1
- package/src/lib/domain/config/with-native-federation.contract.d.ts +0 -2
- package/src/lib/domain/config/with-native-federation.contract.js +0 -1
- package/src/lib/domain/core/build-adapter.contract.js +0 -1
- package/src/lib/domain/core/build-notification-options.contract.js +0 -6
- package/src/lib/domain/core/chunk.js +0 -8
- package/src/lib/domain/core/federation-cache.contract.js +0 -1
- package/src/lib/domain/core/federation-info.contract.js +0 -1
- package/src/lib/domain/core/federation-options.contract.js +0 -1
- package/src/lib/domain/core/index.js +0 -2
- package/src/lib/domain/core/manifest.contract.js +0 -1
- package/src/lib/domain/utils/file-watcher.contract.js +0 -1
- package/src/lib/domain/utils/index.d.ts +0 -2
- package/src/lib/domain/utils/index.js +0 -1
- package/src/lib/domain/utils/keyvaluepair.contract.js +0 -1
- package/src/lib/domain/utils/mapped-path.contract.js +0 -5
- package/src/lib/domain/utils/used-dependencies.contract.js +0 -1
- package/src/lib/utils/build-result-map.js +0 -29
- package/src/lib/utils/cache-persistence.d.ts +0 -19
- package/src/lib/utils/cache-persistence.js +0 -66
- package/src/lib/utils/errors.js +0 -7
- package/src/lib/utils/file-watcher.js +0 -51
- package/src/lib/utils/get-external-imports.d.ts +0 -1
- package/src/lib/utils/get-external-imports.js +0 -80
- package/src/lib/utils/get-used-dependencies.d.ts +0 -8
- package/src/lib/utils/get-used-dependencies.js +0 -123
- package/src/lib/utils/hash-file.d.ts +0 -3
- package/src/lib/utils/hash-file.js +0 -13
- package/src/lib/utils/logger.js +0 -27
- package/src/lib/utils/mapped-paths.js +0 -33
- package/src/lib/utils/normalize.js +0 -17
- package/src/lib/utils/package-info.d.ts +0 -30
- package/src/lib/utils/package-info.js +0 -268
- package/src/lib/utils/rebuild-queue.js +0 -63
- package/src/lib/utils/resolve-glob.d.ts +0 -1
- package/src/lib/utils/resolve-glob.js +0 -29
- package/src/lib/utils/resolve-wildcard-keys.d.ts +0 -29
- package/src/lib/utils/resolve-wildcard-keys.js +0 -126
- package/src/lib/utils/rewrite-chunk-imports.d.ts +0 -2
- package/src/lib/utils/rewrite-chunk-imports.js +0 -48
- /package/{src → dist}/config.d.ts +0 -0
- /package/{src → dist}/domain.d.ts +0 -0
- /package/{src → dist}/lib/config/configuration-context.d.ts +0 -0
- /package/{src → dist}/lib/config/default-skip-list.d.ts +0 -0
- /package/{src → dist}/lib/config/remove-unused-deps.d.ts +0 -0
- /package/{src → dist}/lib/config/with-native-federation.d.ts +0 -0
- /package/{src/lib/core → dist/lib/core/build}/default-external-list.d.ts +0 -0
- /package/{src → dist}/lib/core/federation-builder.d.ts +0 -0
- /package/{src/lib/utils → dist/lib/core}/rebuild-queue.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/federation-config.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/index.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/skip-list.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/build-adapter.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/build-notification-options.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/chunk.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-cache.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-info.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-options.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/index.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/manifest.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/file-watcher.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/keyvaluepair.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/mapped-path.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/used-dependencies.contract.d.ts +0 -0
- /package/{src → dist}/lib/utils/errors.d.ts +0 -0
- /package/{src → dist}/lib/utils/logger.d.ts +0 -0
- /package/{src → dist}/lib/utils/normalize.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,43 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softarc/native-federation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "node esbuild.config.mjs && tsc -p tsconfig.build.json",
|
|
8
|
+
"lint": "eslint src",
|
|
9
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
10
|
+
"knip": "knip",
|
|
11
|
+
"test": "vitest"
|
|
12
|
+
},
|
|
6
13
|
"dependencies": {
|
|
7
14
|
"@softarc/sheriff-core": "^0.19.6",
|
|
8
15
|
"chalk": "^5.6.2",
|
|
16
|
+
"esbuild": "^0.28.0",
|
|
9
17
|
"fast-glob": "^3.3.3",
|
|
10
|
-
"json5": "^2.2.3"
|
|
11
|
-
|
|
18
|
+
"json5": "^2.2.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eslint/js": "^10.0.1",
|
|
22
|
+
"@types/node": "~24.13.0",
|
|
23
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
24
|
+
"@vitest/ui": "^4.0.0",
|
|
25
|
+
"eslint": "^10.4.1",
|
|
26
|
+
"globals": "^17.3.0",
|
|
27
|
+
"jiti": "^2.6.1",
|
|
28
|
+
"jsdom": "^29.0.0",
|
|
29
|
+
"knip": "^6.16.1",
|
|
30
|
+
"prettier": "^3.8.1",
|
|
31
|
+
"tslib": "^2.3.0",
|
|
32
|
+
"typescript": "~6.0.0",
|
|
33
|
+
"typescript-eslint": "^8.61.0",
|
|
34
|
+
"vite": "^8.0.0",
|
|
35
|
+
"vitest": "^4.0.0"
|
|
12
36
|
},
|
|
13
37
|
"exports": {
|
|
14
38
|
"./package.json": "./package.json",
|
|
15
39
|
".": {
|
|
16
|
-
"types": "./
|
|
17
|
-
"import": "./
|
|
18
|
-
"default": "./
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"default": "./dist/index.js"
|
|
19
43
|
},
|
|
20
44
|
"./config": {
|
|
21
|
-
"types": "./
|
|
22
|
-
"import": "./
|
|
23
|
-
"default": "./
|
|
45
|
+
"types": "./dist/config.d.ts",
|
|
46
|
+
"import": "./dist/config.js",
|
|
47
|
+
"default": "./dist/config.js"
|
|
24
48
|
},
|
|
25
49
|
"./domain": {
|
|
26
|
-
"types": "./
|
|
27
|
-
"import": "./
|
|
28
|
-
"default": "./
|
|
50
|
+
"types": "./dist/domain.d.ts",
|
|
51
|
+
"import": "./dist/domain.js",
|
|
52
|
+
"default": "./dist/domain.js"
|
|
29
53
|
},
|
|
30
54
|
"./internal": {
|
|
31
|
-
"types": "./
|
|
32
|
-
"import": "./
|
|
33
|
-
"default": "./
|
|
55
|
+
"types": "./dist/internal.d.ts",
|
|
56
|
+
"import": "./dist/internal.js",
|
|
57
|
+
"default": "./dist/internal.js"
|
|
34
58
|
}
|
|
35
59
|
},
|
|
60
|
+
"main": "./dist/index.js",
|
|
61
|
+
"module": "./dist/index.js",
|
|
62
|
+
"types": "./dist/index.d.ts",
|
|
36
63
|
"files": [
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"types": "./src/index.d.ts",
|
|
41
|
-
"module": "./src/index.js",
|
|
42
|
-
"main": "./src/index.js"
|
|
43
|
-
}
|
|
64
|
+
"dist"
|
|
65
|
+
]
|
|
66
|
+
}
|
package/src/config.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export * from './lib/domain/config/index.js';
|
|
2
|
-
export { withNativeFederation } from './lib/config/with-native-federation.js';
|
|
3
|
-
export { findRootTsConfigJson, share, shareAll, setInferVersion, } from './lib/config/share-utils.js';
|
|
4
|
-
export { DEFAULT_SKIP_LIST } from './lib/config/default-skip-list.js';
|
package/src/domain.js
DELETED
package/src/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { setBuildAdapter } from './lib/core/build-adapter.js';
|
|
2
|
-
export { buildForFederation } from './lib/core/build-for-federation.js';
|
|
3
|
-
export { rebuildForFederation } from './lib/core/rebuild-for-federation.js';
|
|
4
|
-
export { createFederationCache } from './lib/core/federation-cache.js';
|
|
5
|
-
export { bundleExposedAndMappings } from './lib/core/bundle-exposed-and-mappings.js';
|
|
6
|
-
export { getExternals } from './lib/core/get-externals.js';
|
|
7
|
-
export { normalizeFederationOptions } from './lib/core/normalize-options.js';
|
|
8
|
-
export { writeFederationInfo } from './lib/core/write-federation-info.js';
|
|
9
|
-
export { type BuildHelperParams, federationBuilder } from './lib/core/federation-builder.js';
|
|
10
|
-
export * from './domain.js';
|
package/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { setBuildAdapter } from './lib/core/build-adapter.js';
|
|
2
|
-
export { buildForFederation } from './lib/core/build-for-federation.js';
|
|
3
|
-
export { rebuildForFederation } from './lib/core/rebuild-for-federation.js';
|
|
4
|
-
export { createFederationCache } from './lib/core/federation-cache.js';
|
|
5
|
-
export { bundleExposedAndMappings } from './lib/core/bundle-exposed-and-mappings.js';
|
|
6
|
-
export { getExternals } from './lib/core/get-externals.js';
|
|
7
|
-
export { normalizeFederationOptions } from './lib/core/normalize-options.js';
|
|
8
|
-
export { writeFederationInfo } from './lib/core/write-federation-info.js';
|
|
9
|
-
export { federationBuilder } from './lib/core/federation-builder.js';
|
|
10
|
-
export * from './domain.js';
|
package/src/internal.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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, popFromResultMap, } from './lib/utils/build-result-map.js';
|
|
8
|
-
export { writeImportMap } from './lib/core/write-import-map.js';
|
|
9
|
-
export { getDefaultCachePath, getChecksum } from './lib/utils/cache-persistence.js';
|
|
10
|
-
export { isInSkipList, prepareSkipList } from './lib/config/default-skip-list.js';
|
|
11
|
-
export { syncNfFileWatcher, createNfWatcher } from './lib/utils/file-watcher.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
let _context = {};
|
|
2
|
-
export function useWorkspace(workspaceRoot) {
|
|
3
|
-
_context = { ..._context, workspaceRoot };
|
|
4
|
-
}
|
|
5
|
-
export function usePackageJson(packageJson) {
|
|
6
|
-
_context = { ..._context, packageJson };
|
|
7
|
-
}
|
|
8
|
-
export function getConfigContext() {
|
|
9
|
-
return _context;
|
|
10
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_SKIP_LIST = [
|
|
2
|
-
'@softarc/native-federation',
|
|
3
|
-
'@softarc/native-federation-core',
|
|
4
|
-
'@softarc/native-federation-node',
|
|
5
|
-
'@softarc/native-federation-esbuild',
|
|
6
|
-
'@softarc/native-federation-runtime',
|
|
7
|
-
'@softarc/native-federation-orchestrator',
|
|
8
|
-
'vanilla-native-federation',
|
|
9
|
-
'es-module-shims',
|
|
10
|
-
'tslib/',
|
|
11
|
-
pkg => pkg.startsWith('@types/'),
|
|
12
|
-
];
|
|
13
|
-
export function prepareSkipList(skipList) {
|
|
14
|
-
return {
|
|
15
|
-
strings: new Set(skipList.filter(e => typeof e === 'string')),
|
|
16
|
-
functions: skipList.filter(e => typeof e === 'function'),
|
|
17
|
-
regexps: skipList.filter(e => typeof e === 'object'),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export function isInSkipList(entry, skipList) {
|
|
21
|
-
if (skipList.strings.has(entry)) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
if (skipList.functions.find(f => f(entry))) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
if (skipList.regexps.find(r => r.test(entry))) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function removeUnusedDeps(usedDependencies, config) {
|
|
2
|
-
const filteredDependencies = Object.entries(config.shared)
|
|
3
|
-
.filter(([shared, meta]) => !!meta.includeSecondaries || usedDependencies.external.has(shared))
|
|
4
|
-
.reduce((acc, [shared, meta]) => ({ ...acc, [shared]: meta }), {});
|
|
5
|
-
return {
|
|
6
|
-
...config,
|
|
7
|
-
shared: filteredDependencies,
|
|
8
|
-
sharedMappings: usedDependencies.internal,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type SkipList } from '../domain/config/skip-list.contract.js';
|
|
2
|
-
import type { ShareAllExternalsOptions, ShareExternalsOptions } from '../domain/config/external-config.contract.js';
|
|
3
|
-
export declare function findRootTsConfigJson(): string;
|
|
4
|
-
export declare function shareAll(config: ShareAllExternalsOptions, opts?: {
|
|
5
|
-
skipList?: SkipList;
|
|
6
|
-
projectPath?: string;
|
|
7
|
-
overrides?: ShareExternalsOptions;
|
|
8
|
-
}): ShareExternalsOptions | null;
|
|
9
|
-
export declare function setInferVersion(infer: boolean): void;
|
|
10
|
-
export declare function share(configuredShareObjects: ShareExternalsOptions, projectPath?: string, skipList?: SkipList): ShareExternalsOptions;
|
|
@@ -1,302 +0,0 @@
|
|
|
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 { resolvePackageJsonExportsWildcard } from '../utils/resolve-wildcard-keys.js';
|
|
9
|
-
let inferVersion = false;
|
|
10
|
-
export function findRootTsConfigJson() {
|
|
11
|
-
const packageJson = findPackageJson(cwd());
|
|
12
|
-
const projectRoot = path.dirname(packageJson);
|
|
13
|
-
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
14
|
-
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
15
|
-
if (fs.existsSync(tsConfigBaseJson)) {
|
|
16
|
-
return tsConfigBaseJson;
|
|
17
|
-
}
|
|
18
|
-
else if (fs.existsSync(tsConfigJson)) {
|
|
19
|
-
return tsConfigJson;
|
|
20
|
-
}
|
|
21
|
-
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
22
|
-
}
|
|
23
|
-
function findPackageJson(folder) {
|
|
24
|
-
while (!fs.existsSync(path.join(folder, 'package.json')) && path.dirname(folder) !== folder) {
|
|
25
|
-
folder = path.dirname(folder);
|
|
26
|
-
}
|
|
27
|
-
const filePath = path.join(folder, 'package.json');
|
|
28
|
-
if (fs.existsSync(filePath)) {
|
|
29
|
-
return filePath;
|
|
30
|
-
}
|
|
31
|
-
throw new Error('no package.json found. Searched the following folder and all parents: ' + folder);
|
|
32
|
-
}
|
|
33
|
-
function lookupVersion(key, workspaceRoot) {
|
|
34
|
-
const versionMaps = getVersionMaps(workspaceRoot, workspaceRoot);
|
|
35
|
-
for (const versionMap of versionMaps) {
|
|
36
|
-
const version = lookupVersionInMap(key, versionMap);
|
|
37
|
-
if (version) {
|
|
38
|
-
return version;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
|
|
42
|
-
}
|
|
43
|
-
function lookupVersionInMap(key, versions) {
|
|
44
|
-
const parts = key.split('/');
|
|
45
|
-
if (parts.length >= 2 && parts[0].startsWith('@')) {
|
|
46
|
-
key = parts[0] + '/' + parts[1];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
key = parts[0];
|
|
50
|
-
}
|
|
51
|
-
if (!versions[key]) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return versions[key];
|
|
55
|
-
}
|
|
56
|
-
function _findSecondaries(libPath, excludes, shareObject, acc, preparedSkipList) {
|
|
57
|
-
const files = fs.readdirSync(libPath);
|
|
58
|
-
const secondaries = files
|
|
59
|
-
.map(f => path.join(libPath, f))
|
|
60
|
-
.filter(f => fs.lstatSync(f).isDirectory() && !f.endsWith('node_modules'));
|
|
61
|
-
for (const s of secondaries) {
|
|
62
|
-
if (fs.existsSync(path.join(s, 'package.json'))) {
|
|
63
|
-
const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
|
|
64
|
-
const inCustomSkipList = excludes.some(e => e === secondaryLibName || (e.endsWith('*') && secondaryLibName.startsWith(e.slice(0, -1))));
|
|
65
|
-
if (inCustomSkipList)
|
|
66
|
-
continue;
|
|
67
|
-
if (isInSkipList(secondaryLibName, preparedSkipList)) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
acc[secondaryLibName] = { ...shareObject };
|
|
71
|
-
}
|
|
72
|
-
_findSecondaries(s, excludes, shareObject, acc, preparedSkipList);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function findSecondaries(libPath, excludes, shareObject, preparedSkipList) {
|
|
76
|
-
const acc = {};
|
|
77
|
-
_findSecondaries(libPath, excludes, shareObject, acc, preparedSkipList);
|
|
78
|
-
return acc;
|
|
79
|
-
}
|
|
80
|
-
function getSecondaries(includeSecondaries, libPath, key, shareObject, preparedSkipList) {
|
|
81
|
-
let exclude = [];
|
|
82
|
-
let resolveGlob = false;
|
|
83
|
-
if (typeof includeSecondaries === 'object') {
|
|
84
|
-
if (Array.isArray(includeSecondaries.skip)) {
|
|
85
|
-
exclude = includeSecondaries.skip;
|
|
86
|
-
}
|
|
87
|
-
else if (typeof includeSecondaries.skip === 'string') {
|
|
88
|
-
exclude = [includeSecondaries.skip];
|
|
89
|
-
}
|
|
90
|
-
resolveGlob = !!includeSecondaries.resolveGlob;
|
|
91
|
-
}
|
|
92
|
-
// const libPath = path.join(path.dirname(packagePath), 'node_modules', key);
|
|
93
|
-
if (!fs.existsSync(libPath)) {
|
|
94
|
-
return {};
|
|
95
|
-
}
|
|
96
|
-
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject, preparedSkipList, resolveGlob);
|
|
97
|
-
if (configured) {
|
|
98
|
-
return configured;
|
|
99
|
-
}
|
|
100
|
-
// Fallback: Search folders
|
|
101
|
-
const secondaries = findSecondaries(libPath, exclude, shareObject, preparedSkipList);
|
|
102
|
-
return secondaries;
|
|
103
|
-
}
|
|
104
|
-
function readConfiguredSecondaries(parent, libPath, exclude, shareObject, preparedSkipList, resolveGlob) {
|
|
105
|
-
const libPackageJson = path.join(libPath, 'package.json');
|
|
106
|
-
if (!fs.existsSync(libPackageJson)) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
|
|
110
|
-
const version = packageJson['version'];
|
|
111
|
-
const esm = packageJson['type'] === 'module';
|
|
112
|
-
const exports = packageJson['exports'];
|
|
113
|
-
if (!exports) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
const keys = Object.keys(exports).filter(key => key !== '.' &&
|
|
117
|
-
key !== './package.json' &&
|
|
118
|
-
key.startsWith('./') &&
|
|
119
|
-
(exports[key]?.['default'] || exports[key]?.['import'] || typeof exports[key] === 'string'));
|
|
120
|
-
const result = {};
|
|
121
|
-
const discoveredFiles = new Set();
|
|
122
|
-
for (const key of keys) {
|
|
123
|
-
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
124
|
-
const inCustomSkipList = exclude.some(e => e === secondaryName || (e.endsWith('*') && secondaryName.startsWith(e.slice(0, -1))));
|
|
125
|
-
if (inCustomSkipList)
|
|
126
|
-
continue;
|
|
127
|
-
if (isInSkipList(secondaryName, preparedSkipList)) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const entry = getDefaultEntry(exports, key);
|
|
131
|
-
if (typeof entry !== 'string') {
|
|
132
|
-
console.log('No entry point found for ' + secondaryName);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (!entry?.endsWith('.js') && !entry?.endsWith('.mjs') && !entry?.endsWith('.cjs')) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const items = resolveGlobSecondaries(key, libPath, parent, secondaryName, entry, { discovered: discoveredFiles, skip: exclude }, resolveGlob);
|
|
139
|
-
items.forEach(e => discoveredFiles.add(typeof e === 'string' ? e : e.value));
|
|
140
|
-
for (const item of items) {
|
|
141
|
-
if (typeof item === 'object') {
|
|
142
|
-
result[item.key] = {
|
|
143
|
-
...shareObject,
|
|
144
|
-
packageInfo: {
|
|
145
|
-
entryPoint: item.value,
|
|
146
|
-
version: shareObject.version ?? version,
|
|
147
|
-
esm,
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
result[item] = {
|
|
153
|
-
...shareObject,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
function resolveGlobSecondaries(key, libPath, parent, secondaryName, entry, excludes, resolveGlob) {
|
|
161
|
-
let items = [];
|
|
162
|
-
if (key.includes('*')) {
|
|
163
|
-
if (!resolveGlob)
|
|
164
|
-
return items;
|
|
165
|
-
const expanded = resolvePackageJsonExportsWildcard(key, entry, libPath);
|
|
166
|
-
items = expanded
|
|
167
|
-
.map(e => ({
|
|
168
|
-
key: path.join(parent, e.key),
|
|
169
|
-
value: path.join(libPath, e.value),
|
|
170
|
-
}))
|
|
171
|
-
.filter(i => {
|
|
172
|
-
if (excludes.skip.some(e => e.endsWith('*') ? i.key.startsWith(e.slice(0, -1)) : e === i.key)) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
if (excludes.discovered.has(i.value)) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
return true;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
items = [secondaryName];
|
|
183
|
-
}
|
|
184
|
-
return items;
|
|
185
|
-
}
|
|
186
|
-
function getDefaultEntry(exports, key) {
|
|
187
|
-
let entry = '';
|
|
188
|
-
if (typeof exports[key] === 'string') {
|
|
189
|
-
entry = exports[key];
|
|
190
|
-
}
|
|
191
|
-
if (!entry) {
|
|
192
|
-
entry = exports[key]?.['default'];
|
|
193
|
-
if (typeof entry === 'object') {
|
|
194
|
-
entry = entry['default'];
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (!entry) {
|
|
198
|
-
entry = exports[key]?.['import'];
|
|
199
|
-
if (typeof entry === 'object') {
|
|
200
|
-
entry = entry['import'] ?? entry['default'];
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!entry) {
|
|
204
|
-
entry = exports[key]?.['require'];
|
|
205
|
-
if (typeof entry === 'object') {
|
|
206
|
-
entry = entry['require'] ?? entry['default'];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return entry;
|
|
210
|
-
}
|
|
211
|
-
export function shareAll(config, opts = {}) {
|
|
212
|
-
// let workspacePath: string | undefined = undefined;
|
|
213
|
-
const projectPath = inferProjectPath(opts.projectPath);
|
|
214
|
-
// workspacePath = getConfigContext().workspaceRoot ?? '';
|
|
215
|
-
// if (!workspacePath) {
|
|
216
|
-
// workspacePath = projectPath;
|
|
217
|
-
// }
|
|
218
|
-
const versionMaps = getVersionMaps(projectPath, projectPath);
|
|
219
|
-
const sharedExternals = {};
|
|
220
|
-
const skipList = opts.skipList ?? DEFAULT_SKIP_LIST;
|
|
221
|
-
for (const versions of versionMaps) {
|
|
222
|
-
for (const key in versions) {
|
|
223
|
-
if (isInSkipList(key, prepareSkipList(skipList))) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (!!opts.overrides && Object.keys(opts.overrides).some(o => key.startsWith(o))) {
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
|
|
230
|
-
const requiredVersion = inferVersion ? versions[key] : config.requiredVersion;
|
|
231
|
-
if (!sharedExternals[key]) {
|
|
232
|
-
sharedExternals[key] = { ...config, requiredVersion };
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return {
|
|
237
|
-
...share(sharedExternals, opts.projectPath, skipList),
|
|
238
|
-
...(!opts.overrides ? {} : share(opts.overrides, opts.projectPath, skipList)),
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function inferProjectPath(projectPath) {
|
|
242
|
-
if (!projectPath && getConfigContext().packageJson) {
|
|
243
|
-
projectPath = path.dirname(getConfigContext().packageJson || '');
|
|
244
|
-
}
|
|
245
|
-
if (!projectPath && getConfigContext().workspaceRoot) {
|
|
246
|
-
projectPath = getConfigContext().workspaceRoot || '';
|
|
247
|
-
}
|
|
248
|
-
if (!projectPath) {
|
|
249
|
-
projectPath = cwd();
|
|
250
|
-
}
|
|
251
|
-
return projectPath;
|
|
252
|
-
}
|
|
253
|
-
export function setInferVersion(infer) {
|
|
254
|
-
inferVersion = infer;
|
|
255
|
-
}
|
|
256
|
-
export function share(configuredShareObjects, projectPath = '', skipList = DEFAULT_SKIP_LIST) {
|
|
257
|
-
projectPath = inferProjectPath(projectPath);
|
|
258
|
-
const packagePath = findPackageJson(projectPath);
|
|
259
|
-
const preparedSkipList = prepareSkipList(skipList);
|
|
260
|
-
const shareObjects = { ...configuredShareObjects };
|
|
261
|
-
const result = {};
|
|
262
|
-
let includeSecondaries;
|
|
263
|
-
for (const key in shareObjects) {
|
|
264
|
-
includeSecondaries = false;
|
|
265
|
-
const shareObject = shareObjects[key];
|
|
266
|
-
if (shareObject.requiredVersion === 'auto' ||
|
|
267
|
-
(inferVersion && typeof shareObject.requiredVersion === 'undefined') ||
|
|
268
|
-
shareObject.requiredVersion.length < 1) {
|
|
269
|
-
const version = lookupVersion(key, projectPath);
|
|
270
|
-
shareObject.requiredVersion = version;
|
|
271
|
-
shareObject.version = version.replace(/^\D*/, '');
|
|
272
|
-
}
|
|
273
|
-
if (typeof shareObject.includeSecondaries === 'undefined') {
|
|
274
|
-
shareObject.includeSecondaries = true;
|
|
275
|
-
}
|
|
276
|
-
if (shareObject.includeSecondaries) {
|
|
277
|
-
includeSecondaries = shareObject.includeSecondaries;
|
|
278
|
-
delete shareObject.includeSecondaries;
|
|
279
|
-
if (includeSecondaries?.keepAll)
|
|
280
|
-
shareObject.includeSecondaries = true;
|
|
281
|
-
}
|
|
282
|
-
result[key] = shareObject;
|
|
283
|
-
if (includeSecondaries) {
|
|
284
|
-
const libPackageJson = findDepPackageJson(key, path.dirname(packagePath));
|
|
285
|
-
if (!libPackageJson) {
|
|
286
|
-
logger.error('Could not find folder containing dep ' + key);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
const libPath = path.dirname(libPackageJson);
|
|
290
|
-
const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject, preparedSkipList);
|
|
291
|
-
if (secondaries) {
|
|
292
|
-
addSecondaries(secondaries, result);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
298
|
-
function addSecondaries(secondaries, result) {
|
|
299
|
-
for (const key in secondaries) {
|
|
300
|
-
result[key] = secondaries[key];
|
|
301
|
-
}
|
|
302
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { getRawMappedPaths } 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
|
-
export function withNativeFederation(config) {
|
|
6
|
-
const skip = prepareSkipList(config.skip ?? []);
|
|
7
|
-
const chunks = config.chunks ?? true;
|
|
8
|
-
const normalized = {
|
|
9
|
-
$type: 'classic',
|
|
10
|
-
name: config.name ?? '',
|
|
11
|
-
exposes: normalizeExposes(config.exposes),
|
|
12
|
-
shared: normalizeShared(config, skip, chunks),
|
|
13
|
-
sharedMappings: removeSkippedMappings(config, skip),
|
|
14
|
-
chunks,
|
|
15
|
-
skip,
|
|
16
|
-
externals: config.externals ?? [],
|
|
17
|
-
features: {
|
|
18
|
-
mappingVersion: config.features?.mappingVersion ?? true,
|
|
19
|
-
ignoreUnusedDeps: config.features?.ignoreUnusedDeps ?? true,
|
|
20
|
-
denseChunking: config.features?.denseChunking ?? false,
|
|
21
|
-
integrityHashes: config.features?.integrityHashes ?? false,
|
|
22
|
-
},
|
|
23
|
-
...(config.shareScope && { shareScope: config.shareScope }),
|
|
24
|
-
};
|
|
25
|
-
return normalized;
|
|
26
|
-
}
|
|
27
|
-
function normalizeExposes(exposes) {
|
|
28
|
-
if (!exposes)
|
|
29
|
-
return {};
|
|
30
|
-
return Object.fromEntries(Object.entries(exposes).map(([key, value]) => [
|
|
31
|
-
key,
|
|
32
|
-
typeof value === 'string' ? { file: value } : value,
|
|
33
|
-
]));
|
|
34
|
-
}
|
|
35
|
-
function normalizeShared(config, skip, chunks) {
|
|
36
|
-
let result = {};
|
|
37
|
-
const shared = config.shared ??
|
|
38
|
-
shareAll({
|
|
39
|
-
singleton: true,
|
|
40
|
-
strictVersion: true,
|
|
41
|
-
requiredVersion: 'auto',
|
|
42
|
-
platform: 'browser',
|
|
43
|
-
});
|
|
44
|
-
result = Object.keys(shared).reduce((acc, cur) => {
|
|
45
|
-
const key = cur.replace(/\\/g, '/');
|
|
46
|
-
const sharedConfig = shared[cur];
|
|
47
|
-
if (!!sharedConfig.chunks && !sharedConfig.build && sharedConfig.chunks !== chunks) {
|
|
48
|
-
logger.warn(`External '${cur}' has explicit chunk settings, consider switching build type to { build: 'package' }.`);
|
|
49
|
-
sharedConfig.chunks = chunks;
|
|
50
|
-
}
|
|
51
|
-
const normalizedConfig = {
|
|
52
|
-
requiredVersion: sharedConfig.requiredVersion ?? 'auto',
|
|
53
|
-
singleton: sharedConfig.singleton ?? false,
|
|
54
|
-
strictVersion: sharedConfig.strictVersion ?? false,
|
|
55
|
-
version: sharedConfig.version,
|
|
56
|
-
chunks: sharedConfig.chunks ?? chunks,
|
|
57
|
-
includeSecondaries: sharedConfig.includeSecondaries,
|
|
58
|
-
packageInfo: sharedConfig.packageInfo,
|
|
59
|
-
platform: sharedConfig.platform ?? config.platform ?? 'browser',
|
|
60
|
-
build: sharedConfig.build ?? 'default',
|
|
61
|
-
...(sharedConfig.shareScope && { shareScope: sharedConfig.shareScope }),
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
...acc,
|
|
65
|
-
[key]: normalizedConfig,
|
|
66
|
-
};
|
|
67
|
-
}, {});
|
|
68
|
-
result = Object.keys(result)
|
|
69
|
-
.filter(key => !isInSkipList(key, skip))
|
|
70
|
-
.reduce((acc, cur) => ({ ...acc, [cur]: result[cur] }), {});
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
function removeSkippedMappings(config, skipList) {
|
|
74
|
-
const rootTsConfigPath = findRootTsConfigJson();
|
|
75
|
-
const paths = getRawMappedPaths(rootTsConfigPath, config.sharedMappings);
|
|
76
|
-
return Object.entries(paths)
|
|
77
|
-
.filter(([, _import]) => !isInSkipList(_import, skipList))
|
|
78
|
-
.reduce((acc, [_path, _import]) => ({ ...acc, [_path]: _import }), {});
|
|
79
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { logger } from '../utils/logger.js';
|
|
2
|
-
let _buildAdapter = null;
|
|
3
|
-
export function setBuildAdapter(buildAdapter) {
|
|
4
|
-
_buildAdapter = buildAdapter;
|
|
5
|
-
}
|
|
6
|
-
export function getBuildAdapter() {
|
|
7
|
-
if (!_buildAdapter) {
|
|
8
|
-
logger.error('Please set a BuildAdapter!');
|
|
9
|
-
throw new Error('BuildAdapter not set');
|
|
10
|
-
}
|
|
11
|
-
return _buildAdapter;
|
|
12
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
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 buildForFederation(config: NormalizedFederationConfig, fedOptions: NormalizedFederationOptions, externals: string[], signal?: AbortSignal): Promise<FederationInfo>;
|