@softarc/native-federation 0.9.1
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/README.md +11 -0
- package/build.d.ts +1 -0
- package/build.js +5 -0
- package/build.js.map +1 -0
- package/package.json +11 -0
- package/src/build.d.ts +15 -0
- package/src/build.js +27 -0
- package/src/build.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/config/federation-config.d.ts +26 -0
- package/src/lib/config/federation-config.js +3 -0
- package/src/lib/config/federation-config.js.map +1 -0
- package/src/lib/config/index.d.ts +2 -0
- package/src/lib/config/index.js +10 -0
- package/src/lib/config/index.js.map +1 -0
- package/src/lib/config/share-utils.d.ts +15 -0
- package/src/lib/config/share-utils.js +190 -0
- package/src/lib/config/share-utils.js.map +1 -0
- package/src/lib/config/with-native-federation.d.ts +2 -0
- package/src/lib/config/with-native-federation.js +53 -0
- package/src/lib/config/with-native-federation.js.map +1 -0
- package/src/lib/core/build-adapter.d.ts +11 -0
- package/src/lib/core/build-adapter.js +17 -0
- package/src/lib/core/build-adapter.js.map +1 -0
- package/src/lib/core/build-for-federation.d.ts +3 -0
- package/src/lib/core/build-for-federation.js +26 -0
- package/src/lib/core/build-for-federation.js.map +1 -0
- package/src/lib/core/bundle-exposed.d.ts +4 -0
- package/src/lib/core/bundle-exposed.js +34 -0
- package/src/lib/core/bundle-exposed.js.map +1 -0
- package/src/lib/core/bundle-shared-mappings.d.ts +4 -0
- package/src/lib/core/bundle-shared-mappings.js +51 -0
- package/src/lib/core/bundle-shared-mappings.js.map +1 -0
- package/src/lib/core/bundle-shared.d.ts +4 -0
- package/src/lib/core/bundle-shared.js +53 -0
- package/src/lib/core/bundle-shared.js.map +1 -0
- package/src/lib/core/default-skip-list.d.ts +1 -0
- package/src/lib/core/default-skip-list.js +11 -0
- package/src/lib/core/default-skip-list.js.map +1 -0
- package/src/lib/core/federation-options.d.ts +6 -0
- package/src/lib/core/federation-options.js +3 -0
- package/src/lib/core/federation-options.js.map +1 -0
- package/src/lib/core/get-externals.d.ts +2 -0
- package/src/lib/core/get-externals.js +12 -0
- package/src/lib/core/get-externals.js.map +1 -0
- package/src/lib/core/load-federation-config.d.ts +2 -0
- package/src/lib/core/load-federation-config.js +12 -0
- package/src/lib/core/load-federation-config.js.map +1 -0
- package/src/lib/core/write-federation-info.d.ts +3 -0
- package/src/lib/core/write-federation-info.js +11 -0
- package/src/lib/core/write-federation-info.js.map +1 -0
- package/src/lib/core/write-import-map.d.ts +3 -0
- package/src/lib/core/write-import-map.js +15 -0
- package/src/lib/core/write-import-map.js.map +1 -0
- package/src/lib/utils/build-utils.d.ts +2 -0
- package/src/lib/utils/build-utils.js +13 -0
- package/src/lib/utils/build-utils.js.map +1 -0
- package/src/lib/utils/copy-src-map-if-exists.d.ts +1 -0
- package/src/lib/utils/copy-src-map-if-exists.js +13 -0
- package/src/lib/utils/copy-src-map-if-exists.js.map +1 -0
- package/src/lib/utils/hash-file.d.ts +1 -0
- package/src/lib/utils/hash-file.js +13 -0
- package/src/lib/utils/hash-file.js.map +1 -0
- package/src/lib/utils/mapped-paths.d.ts +10 -0
- package/src/lib/utils/mapped-paths.js +37 -0
- package/src/lib/utils/mapped-paths.js.map +1 -0
- package/src/lib/utils/package-info.d.ts +9 -0
- package/src/lib/utils/package-info.js +99 -0
- package/src/lib/utils/package-info.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# native-federation-core
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build native-federation-core` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test native-federation-core` to execute the unit tests via [Jest](https://jestjs.io).
|
package/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/build';
|
package/build.js
ADDED
package/build.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../libs/native-federation-core/build.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
|
package/package.json
ADDED
package/src/build.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { NormalizedFederationConfig } from './lib/config/federation-config';
|
|
2
|
+
export { FederationOptions } from './lib/core/federation-options';
|
|
3
|
+
export { setBuildAdapter } from './lib/core/build-adapter';
|
|
4
|
+
export { writeImportMap } from './lib/core/write-import-map';
|
|
5
|
+
export { writeFederationInfo } from './lib/core/write-federation-info';
|
|
6
|
+
export { bundleShared } from './lib/core/bundle-shared';
|
|
7
|
+
export { bundleSharedMappings } from './lib/core/bundle-shared-mappings';
|
|
8
|
+
export { bundleExposed } from './lib/core/bundle-exposed';
|
|
9
|
+
export { getExternals } from './lib/core/get-externals';
|
|
10
|
+
export { loadFederationConfig } from './lib/core/load-federation-config';
|
|
11
|
+
export { MappedPath } from './lib/utils/mapped-paths';
|
|
12
|
+
export { BuildAdapter } from './lib/core/build-adapter';
|
|
13
|
+
export { withNativeFederation } from './lib/config/with-native-federation';
|
|
14
|
+
export { buildForFederation } from './lib/core/build-for-federation';
|
|
15
|
+
export { share, shareAll } from './lib/config/share-utils';
|
package/src/build.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shareAll = exports.share = exports.buildForFederation = exports.withNativeFederation = exports.loadFederationConfig = exports.getExternals = exports.bundleExposed = exports.bundleSharedMappings = exports.bundleShared = exports.writeFederationInfo = exports.writeImportMap = exports.setBuildAdapter = void 0;
|
|
4
|
+
var build_adapter_1 = require("./lib/core/build-adapter");
|
|
5
|
+
Object.defineProperty(exports, "setBuildAdapter", { enumerable: true, get: function () { return build_adapter_1.setBuildAdapter; } });
|
|
6
|
+
var write_import_map_1 = require("./lib/core/write-import-map");
|
|
7
|
+
Object.defineProperty(exports, "writeImportMap", { enumerable: true, get: function () { return write_import_map_1.writeImportMap; } });
|
|
8
|
+
var write_federation_info_1 = require("./lib/core/write-federation-info");
|
|
9
|
+
Object.defineProperty(exports, "writeFederationInfo", { enumerable: true, get: function () { return write_federation_info_1.writeFederationInfo; } });
|
|
10
|
+
var bundle_shared_1 = require("./lib/core/bundle-shared");
|
|
11
|
+
Object.defineProperty(exports, "bundleShared", { enumerable: true, get: function () { return bundle_shared_1.bundleShared; } });
|
|
12
|
+
var bundle_shared_mappings_1 = require("./lib/core/bundle-shared-mappings");
|
|
13
|
+
Object.defineProperty(exports, "bundleSharedMappings", { enumerable: true, get: function () { return bundle_shared_mappings_1.bundleSharedMappings; } });
|
|
14
|
+
var bundle_exposed_1 = require("./lib/core/bundle-exposed");
|
|
15
|
+
Object.defineProperty(exports, "bundleExposed", { enumerable: true, get: function () { return bundle_exposed_1.bundleExposed; } });
|
|
16
|
+
var get_externals_1 = require("./lib/core/get-externals");
|
|
17
|
+
Object.defineProperty(exports, "getExternals", { enumerable: true, get: function () { return get_externals_1.getExternals; } });
|
|
18
|
+
var load_federation_config_1 = require("./lib/core/load-federation-config");
|
|
19
|
+
Object.defineProperty(exports, "loadFederationConfig", { enumerable: true, get: function () { return load_federation_config_1.loadFederationConfig; } });
|
|
20
|
+
var with_native_federation_1 = require("./lib/config/with-native-federation");
|
|
21
|
+
Object.defineProperty(exports, "withNativeFederation", { enumerable: true, get: function () { return with_native_federation_1.withNativeFederation; } });
|
|
22
|
+
var build_for_federation_1 = require("./lib/core/build-for-federation");
|
|
23
|
+
Object.defineProperty(exports, "buildForFederation", { enumerable: true, get: function () { return build_for_federation_1.buildForFederation; } });
|
|
24
|
+
var share_utils_1 = require("./lib/config/share-utils");
|
|
25
|
+
Object.defineProperty(exports, "share", { enumerable: true, get: function () { return share_utils_1.share; } });
|
|
26
|
+
Object.defineProperty(exports, "shareAll", { enumerable: true, get: function () { return share_utils_1.shareAll; } });
|
|
27
|
+
//# sourceMappingURL=build.js.map
|
package/src/build.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../libs/native-federation-core/src/build.ts"],"names":[],"mappings":";;;AAEA,0DAA2D;AAAlD,gHAAA,eAAe,OAAA;AACxB,gEAA6D;AAApD,kHAAA,cAAc,OAAA;AACvB,0EAAuE;AAA9D,4HAAA,mBAAmB,OAAA;AAC5B,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAC7B,4DAA0D;AAAjD,+GAAA,aAAa,OAAA;AACtB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAG7B,8EAA2E;AAAlE,8HAAA,oBAAoB,OAAA;AAC7B,wEAAqE;AAA5D,0HAAA,kBAAkB,OAAA;AAC3B,wDAA2D;AAAlD,oGAAA,KAAK,OAAA;AAAE,uGAAA,QAAQ,OAAA"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@softarc/native-federation-runtime';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/native-federation-core/src/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MappedPath } from '../utils/mapped-paths';
|
|
2
|
+
export interface SharedConfig {
|
|
3
|
+
singleton?: boolean;
|
|
4
|
+
strictVersion?: boolean;
|
|
5
|
+
requiredVersion?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FederationConfig {
|
|
9
|
+
name?: string;
|
|
10
|
+
exposes?: Record<string, string>;
|
|
11
|
+
shared?: Record<string, SharedConfig>;
|
|
12
|
+
sharedMappings?: Array<string>;
|
|
13
|
+
skip?: Array<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface NormalizedSharedConfig {
|
|
16
|
+
singleton: boolean;
|
|
17
|
+
strictVersion: boolean;
|
|
18
|
+
requiredVersion: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface NormalizedFederationConfig {
|
|
22
|
+
name: string;
|
|
23
|
+
exposes: Record<string, string>;
|
|
24
|
+
shared: Record<string, NormalizedSharedConfig>;
|
|
25
|
+
sharedMappings: Array<MappedPath>;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-config.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/federation-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shareAll = exports.share = exports.findRootTsConfigJson = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./with-native-federation"), exports);
|
|
6
|
+
var webpack_1 = require("@angular-architects/module-federation/webpack");
|
|
7
|
+
Object.defineProperty(exports, "findRootTsConfigJson", { enumerable: true, get: function () { return webpack_1.findRootTsConfigJson; } });
|
|
8
|
+
Object.defineProperty(exports, "share", { enumerable: true, get: function () { return webpack_1.share; } });
|
|
9
|
+
Object.defineProperty(exports, "shareAll", { enumerable: true, get: function () { return webpack_1.shareAll; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/index.ts"],"names":[],"mappings":";;;;AAAA,mEAAyC;AACzC,yEAIuD;AAHrD,+GAAA,oBAAoB,OAAA;AACpB,gGAAA,KAAK,OAAA;AACL,mGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SharedConfig } from './federation-config';
|
|
2
|
+
export declare const DEFAULT_SECONARIES_SKIP_LIST: string[];
|
|
3
|
+
declare type IncludeSecondariesOptions = {
|
|
4
|
+
skip: string | string[];
|
|
5
|
+
} | boolean;
|
|
6
|
+
declare type CustomSharedConfig = SharedConfig & {
|
|
7
|
+
includeSecondaries?: IncludeSecondariesOptions;
|
|
8
|
+
};
|
|
9
|
+
declare type ConfigObject = Record<string, CustomSharedConfig>;
|
|
10
|
+
declare type Config = (string | ConfigObject)[] | ConfigObject;
|
|
11
|
+
export declare function findRootTsConfigJson(): string;
|
|
12
|
+
export declare function shareAll(config?: CustomSharedConfig, skip?: string[], packageJsonPath?: string): Config | null;
|
|
13
|
+
export declare function setInferVersion(infer: boolean): void;
|
|
14
|
+
export declare function share(shareObjects: Config, packageJsonPath?: string): Config;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.share = exports.setInferVersion = exports.shareAll = exports.findRootTsConfigJson = exports.DEFAULT_SECONARIES_SKIP_LIST = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const process_1 = require("process");
|
|
7
|
+
const default_skip_list_1 = require("../core/default-skip-list");
|
|
8
|
+
let inferVersion = false;
|
|
9
|
+
exports.DEFAULT_SECONARIES_SKIP_LIST = [
|
|
10
|
+
'@angular/router/upgrade',
|
|
11
|
+
'@angular/common/upgrade',
|
|
12
|
+
];
|
|
13
|
+
function findRootTsConfigJson() {
|
|
14
|
+
const packageJson = findPackageJson((0, process_1.cwd)());
|
|
15
|
+
const projectRoot = path.dirname(packageJson);
|
|
16
|
+
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
17
|
+
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
18
|
+
if (fs.existsSync(tsConfigBaseJson)) {
|
|
19
|
+
return tsConfigBaseJson;
|
|
20
|
+
}
|
|
21
|
+
else if (fs.existsSync(tsConfigJson)) {
|
|
22
|
+
return tsConfigJson;
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
25
|
+
}
|
|
26
|
+
exports.findRootTsConfigJson = findRootTsConfigJson;
|
|
27
|
+
function findPackageJson(folder) {
|
|
28
|
+
while (!fs.existsSync(path.join(folder, 'package.json')) &&
|
|
29
|
+
path.dirname(folder) !== folder) {
|
|
30
|
+
folder = path.dirname(folder);
|
|
31
|
+
}
|
|
32
|
+
const filePath = path.join(folder, 'package.json');
|
|
33
|
+
if (fs.existsSync(filePath)) {
|
|
34
|
+
return filePath;
|
|
35
|
+
}
|
|
36
|
+
throw new Error('no package.json found. Searched the following folder and all parents: ' +
|
|
37
|
+
folder);
|
|
38
|
+
}
|
|
39
|
+
function readVersionMap(packagePath) {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
41
|
+
const json = require(packagePath);
|
|
42
|
+
const versions = Object.assign({}, json['dependencies']);
|
|
43
|
+
return versions;
|
|
44
|
+
}
|
|
45
|
+
function lookupVersion(key, versions) {
|
|
46
|
+
const parts = key.split('/');
|
|
47
|
+
if (parts.length >= 2 && parts[0].startsWith('@')) {
|
|
48
|
+
key = parts[0] + '/' + parts[1];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
key = parts[0];
|
|
52
|
+
}
|
|
53
|
+
if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
|
|
54
|
+
key = '@angular-architects/module-federation';
|
|
55
|
+
}
|
|
56
|
+
if (!versions[key]) {
|
|
57
|
+
throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
|
|
58
|
+
}
|
|
59
|
+
return versions[key];
|
|
60
|
+
}
|
|
61
|
+
function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
62
|
+
const files = fs.readdirSync(libPath);
|
|
63
|
+
const dirs = files
|
|
64
|
+
.map((f) => path.join(libPath, f))
|
|
65
|
+
.filter((f) => fs.lstatSync(f).isDirectory() && f !== 'node_modules');
|
|
66
|
+
const secondaries = dirs.filter((d) => fs.existsSync(path.join(d, 'package.json')));
|
|
67
|
+
for (const s of secondaries) {
|
|
68
|
+
const secondaryLibName = s
|
|
69
|
+
.replace(/\\/g, '/')
|
|
70
|
+
.replace(/^.*node_modules[/]/, '');
|
|
71
|
+
if (excludes.includes(secondaryLibName)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
acc[secondaryLibName] = Object.assign({}, shareObject);
|
|
75
|
+
_findSecondaries(s, excludes, shareObject, acc);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function findSecondaries(libPath, excludes, shareObject) {
|
|
79
|
+
const acc = {};
|
|
80
|
+
_findSecondaries(libPath, excludes, shareObject, acc);
|
|
81
|
+
return acc;
|
|
82
|
+
}
|
|
83
|
+
function getSecondaries(includeSecondaries, packagePath, key, shareObject) {
|
|
84
|
+
let exclude = [...exports.DEFAULT_SECONARIES_SKIP_LIST];
|
|
85
|
+
if (typeof includeSecondaries === 'object') {
|
|
86
|
+
if (Array.isArray(includeSecondaries.skip)) {
|
|
87
|
+
exclude = includeSecondaries.skip;
|
|
88
|
+
}
|
|
89
|
+
else if (typeof includeSecondaries.skip === 'string') {
|
|
90
|
+
exclude = [includeSecondaries.skip];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const libPath = path.join(path.dirname(packagePath), 'node_modules', key);
|
|
94
|
+
if (!fs.existsSync(libPath)) {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
|
|
98
|
+
if (configured) {
|
|
99
|
+
return configured;
|
|
100
|
+
}
|
|
101
|
+
// Fallback: Search folders
|
|
102
|
+
const secondaries = findSecondaries(libPath, exclude, shareObject);
|
|
103
|
+
return secondaries;
|
|
104
|
+
}
|
|
105
|
+
function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
106
|
+
const libPackageJson = path.join(libPath, 'package.json');
|
|
107
|
+
if (!fs.existsSync(libPackageJson)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
|
|
111
|
+
const exports = packageJson['exports'];
|
|
112
|
+
if (!exports) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const keys = Object.keys(exports).filter((key) => key != '.' &&
|
|
116
|
+
key != './package.json' &&
|
|
117
|
+
!key.endsWith('*') &&
|
|
118
|
+
exports[key]['default']);
|
|
119
|
+
const result = {};
|
|
120
|
+
for (const key of keys) {
|
|
121
|
+
// const relPath = exports[key]['default'];
|
|
122
|
+
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
123
|
+
if (exclude.includes(secondaryName)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
result[secondaryName] = Object.assign({}, shareObject);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
function shareAll(config = {}, skip = [...default_skip_list_1.DEFAULT_SKIP_LIST], packageJsonPath = '') {
|
|
131
|
+
if (!packageJsonPath) {
|
|
132
|
+
packageJsonPath = (0, process_1.cwd)();
|
|
133
|
+
}
|
|
134
|
+
const packagePath = findPackageJson(packageJsonPath);
|
|
135
|
+
const versions = readVersionMap(packagePath);
|
|
136
|
+
const share = {};
|
|
137
|
+
for (const key in versions) {
|
|
138
|
+
if (skip.includes(key)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
share[key] = Object.assign({}, config);
|
|
142
|
+
}
|
|
143
|
+
return module.exports.share(share, packageJsonPath);
|
|
144
|
+
}
|
|
145
|
+
exports.shareAll = shareAll;
|
|
146
|
+
function setInferVersion(infer) {
|
|
147
|
+
inferVersion = infer;
|
|
148
|
+
}
|
|
149
|
+
exports.setInferVersion = setInferVersion;
|
|
150
|
+
function share(shareObjects, packageJsonPath = '') {
|
|
151
|
+
if (!packageJsonPath) {
|
|
152
|
+
packageJsonPath = (0, process_1.cwd)();
|
|
153
|
+
}
|
|
154
|
+
const packagePath = findPackageJson(packageJsonPath);
|
|
155
|
+
const versions = readVersionMap(packagePath);
|
|
156
|
+
const result = {};
|
|
157
|
+
let includeSecondaries;
|
|
158
|
+
for (const key in shareObjects) {
|
|
159
|
+
includeSecondaries = false;
|
|
160
|
+
const shareObject = shareObjects[key];
|
|
161
|
+
if (shareObject.requiredVersion === 'auto' ||
|
|
162
|
+
(inferVersion && typeof shareObject.requiredVersion === 'undefined')) {
|
|
163
|
+
const version = lookupVersion(key, versions);
|
|
164
|
+
shareObject.requiredVersion = version;
|
|
165
|
+
shareObject.version = version.replace(/^\D*/, '');
|
|
166
|
+
}
|
|
167
|
+
if (typeof shareObject.includeSecondaries === 'undefined') {
|
|
168
|
+
shareObject.includeSecondaries = true;
|
|
169
|
+
}
|
|
170
|
+
if (shareObject.includeSecondaries) {
|
|
171
|
+
includeSecondaries = shareObject.includeSecondaries;
|
|
172
|
+
delete shareObject.includeSecondaries;
|
|
173
|
+
}
|
|
174
|
+
result[key] = shareObject;
|
|
175
|
+
if (includeSecondaries) {
|
|
176
|
+
const secondaries = getSecondaries(includeSecondaries, packagePath, key, shareObject);
|
|
177
|
+
if (secondaries) {
|
|
178
|
+
addSecondaries(secondaries, result);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
exports.share = share;
|
|
185
|
+
function addSecondaries(secondaries, result) {
|
|
186
|
+
for (const key in secondaries) {
|
|
187
|
+
result[key] = secondaries[key];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=share-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-utils.js","source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MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;KAChC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withNativeFederation = void 0;
|
|
4
|
+
const mapped_paths_1 = require("../utils/mapped-paths");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
function withNativeFederation(config) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const skip = (_a = new Set(config.skip)) !== null && _a !== void 0 ? _a : new Set();
|
|
9
|
+
return {
|
|
10
|
+
name: (_b = config.name) !== null && _b !== void 0 ? _b : '',
|
|
11
|
+
exposes: (_c = config.exposes) !== null && _c !== void 0 ? _c : {},
|
|
12
|
+
shared: normalizeShared(config, skip),
|
|
13
|
+
sharedMappings: normalizeSharedMappings(config, skip),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.withNativeFederation = withNativeFederation;
|
|
17
|
+
function normalizeShared(config, skip) {
|
|
18
|
+
let result = {};
|
|
19
|
+
const shared = config.shared;
|
|
20
|
+
if (!shared) {
|
|
21
|
+
result = (0, config_1.shareAll)({
|
|
22
|
+
singleton: true,
|
|
23
|
+
strictVersion: true,
|
|
24
|
+
requiredVersion: 'auto',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
result = Object.keys(shared).reduce((acc, cur) => {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
return (Object.assign(Object.assign({}, acc), { [cur]: {
|
|
31
|
+
requiredVersion: (_a = shared[cur].requiredVersion) !== null && _a !== void 0 ? _a : 'auto',
|
|
32
|
+
singleton: (_b = shared[cur].singleton) !== null && _b !== void 0 ? _b : false,
|
|
33
|
+
strictVersion: (_c = shared[cur].strictVersion) !== null && _c !== void 0 ? _c : false,
|
|
34
|
+
version: shared[cur].version,
|
|
35
|
+
} }));
|
|
36
|
+
}, {});
|
|
37
|
+
result = (0, config_1.share)(result);
|
|
38
|
+
}
|
|
39
|
+
result = Object.keys(result)
|
|
40
|
+
.filter((key) => !skip.has(key))
|
|
41
|
+
.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), { [cur]: result[cur] })), {});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function normalizeSharedMappings(config, skip) {
|
|
45
|
+
const rootTsConfigPath = (0, config_1.findRootTsConfigJson)();
|
|
46
|
+
const paths = (0, mapped_paths_1.getMappedPaths)({
|
|
47
|
+
rootTsConfigPath,
|
|
48
|
+
sharedMappings: config.sharedMappings,
|
|
49
|
+
});
|
|
50
|
+
const result = paths.filter((p) => !skip.has(p.key));
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=with-native-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-native-federation.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/with-native-federation.ts"],"names":[],"mappings":";;;AAAA,wDAAmE;AACnE,sCAAkE;AAOlE,SAAgB,oBAAoB,CAClC,MAAwB;;IAExB,MAAM,IAAI,GAAG,MAAA,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAI,IAAI,GAAG,EAAU,CAAC;IAEvD,OAAO;QACL,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,EAAE;QACvB,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE;QAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC;QACrC,cAAc,EAAE,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC;KACtD,CAAC;AACJ,CAAC;AAXD,oDAWC;AAED,SAAS,eAAe,CACtB,MAAwB,EACxB,IAAiB;IAEjB,IAAI,MAAM,GAA2C,EAAE,CAAC;IAExD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,IAAI,CAAC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cAAc;KACtC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MappedPath } from "../utils/mapped-paths";
|
|
2
|
+
export interface BuildAdapterOptions {
|
|
3
|
+
entryPoint: string;
|
|
4
|
+
tsConfigPath?: string;
|
|
5
|
+
external: Array<string>;
|
|
6
|
+
outfile: string;
|
|
7
|
+
mappedPaths: MappedPath[];
|
|
8
|
+
}
|
|
9
|
+
export declare type BuildAdapter = (options: BuildAdapterOptions) => Promise<void>;
|
|
10
|
+
export declare function setBuildAdapter(buildAdapter: BuildAdapter): void;
|
|
11
|
+
export declare function getBuildAdapter(): BuildAdapter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBuildAdapter = exports.setBuildAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
let _buildAdapter = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
6
|
+
// TODO: add logger
|
|
7
|
+
console.error('Please set a BuildAdapter!');
|
|
8
|
+
});
|
|
9
|
+
function setBuildAdapter(buildAdapter) {
|
|
10
|
+
_buildAdapter = buildAdapter;
|
|
11
|
+
}
|
|
12
|
+
exports.setBuildAdapter = setBuildAdapter;
|
|
13
|
+
function getBuildAdapter() {
|
|
14
|
+
return _buildAdapter;
|
|
15
|
+
}
|
|
16
|
+
exports.getBuildAdapter = getBuildAdapter;
|
|
17
|
+
//# sourceMappingURL=build-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-adapter.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/build-adapter.ts"],"names":[],"mappings":";;;;AAEA,IAAI,aAAa,GAAiB,GAAS,EAAE;IACzC,mBAAmB;IACnB,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;AAC/C,CAAC,CAAA,CAAA;AAaD,SAAgB,eAAe,CAAC,YAA0B;IACtD,aAAa,GAAG,YAAY,CAAC;AACjC,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe;IAC3B,OAAO,aAAa,CAAC;AACzB,CAAC;AAFD,0CAEC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { NormalizedFederationConfig } from '../config/federation-config';
|
|
2
|
+
import { FederationOptions } from './federation-options';
|
|
3
|
+
export declare function buildForFederation(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[]): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildForFederation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const write_import_map_1 = require("./write-import-map");
|
|
6
|
+
const write_federation_info_1 = require("./write-federation-info");
|
|
7
|
+
const bundle_shared_1 = require("./bundle-shared");
|
|
8
|
+
const bundle_shared_mappings_1 = require("./bundle-shared-mappings");
|
|
9
|
+
const bundle_exposed_1 = require("./bundle-exposed");
|
|
10
|
+
function buildForFederation(config, fedOptions, externals) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const exposedInfo = yield (0, bundle_exposed_1.bundleExposed)(config, fedOptions, externals);
|
|
13
|
+
const sharedPackageInfo = yield (0, bundle_shared_1.bundleShared)(config, fedOptions, externals);
|
|
14
|
+
const sharedMappingInfo = yield (0, bundle_shared_mappings_1.bundleSharedMappings)(config, fedOptions, externals);
|
|
15
|
+
const sharedInfo = [...sharedPackageInfo, ...sharedMappingInfo];
|
|
16
|
+
const federationInfo = {
|
|
17
|
+
name: config.name,
|
|
18
|
+
shared: sharedInfo,
|
|
19
|
+
exposes: exposedInfo,
|
|
20
|
+
};
|
|
21
|
+
(0, write_federation_info_1.writeFederationInfo)(federationInfo, fedOptions);
|
|
22
|
+
(0, write_import_map_1.writeImportMap)(sharedInfo, fedOptions);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.buildForFederation = buildForFederation;
|
|
26
|
+
//# sourceMappingURL=build-for-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-for-federation.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/build-for-federation.ts"],"names":[],"mappings":";;;;AAGA,yDAAoD;AACpD,mEAA8D;AAC9D,mDAA+C;AAC/C,qEAAgE;AAChE,qDAAiD;AAEjD,SAAsB,kBAAkB,CAAC,MAAkC,EAAE,UAA6B,EAAE,SAAmB;;QAC7H,MAAM,WAAW,GAAG,MAAM,IAAA,8BAAa,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAEvE,MAAM,iBAAiB,GAAG,MAAM,IAAA,4BAAY,EAC1C,MAAM,EACN,UAAU,EACV,SAAS,CACV,CAAC;QAEF,MAAM,iBAAiB,GAAG,MAAM,IAAA,6CAAoB,EAClD,MAAM,EACN,UAAU,EACV,SAAS,CACV,CAAC;QAEF,MAAM,UAAU,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,CAAC,CAAC;QAEhE,MAAM,cAAc,GAAmB;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,WAAW;SACrB,CAAC;QAEF,IAAA,2CAAmB,EAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAEhD,IAAA,iCAAc,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;CAAA;AA1BD,gDA0BC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NormalizedFederationConfig } from '../config/federation-config';
|
|
2
|
+
import { ExposesInfo } from '@softarc/native-federation-runtime';
|
|
3
|
+
import { FederationOptions } from './federation-options';
|
|
4
|
+
export declare function bundleExposed(config: NormalizedFederationConfig, options: FederationOptions, externals: string[]): Promise<Array<ExposesInfo>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundleExposed = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const build_utils_1 = require("../utils/build-utils");
|
|
8
|
+
const hash_file_1 = require("../utils/hash-file");
|
|
9
|
+
function bundleExposed(config, options, externals) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const result = [];
|
|
12
|
+
for (const key in config.exposes) {
|
|
13
|
+
const outFileName = key + '.js';
|
|
14
|
+
const outFilePath = path.join(options.outputPath, outFileName);
|
|
15
|
+
const entryPoint = config.exposes[key];
|
|
16
|
+
console.info('Bundle exposed file', entryPoint, '...');
|
|
17
|
+
yield (0, build_utils_1.bundle)({
|
|
18
|
+
entryPoint,
|
|
19
|
+
tsConfigPath: options.tsConfig,
|
|
20
|
+
external: externals,
|
|
21
|
+
outfile: outFilePath,
|
|
22
|
+
mappedPaths: config.sharedMappings,
|
|
23
|
+
});
|
|
24
|
+
const hash = (0, hash_file_1.hashFile)(outFilePath);
|
|
25
|
+
const hashedOutFileName = `${key}-${hash}.js`;
|
|
26
|
+
const hashedOutFilePath = path.join(options.outputPath, hashedOutFileName);
|
|
27
|
+
fs.renameSync(outFilePath, hashedOutFilePath);
|
|
28
|
+
result.push({ key, outFileName: hashedOutFileName });
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.bundleExposed = bundleExposed;
|
|
34
|
+
//# sourceMappingURL=bundle-exposed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-exposed.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/bundle-exposed.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,yBAAyB;AAEzB,sDAA8C;AAE9C,kDAA8C;AAG9C,SAAsB,aAAa,CACjC,MAAkC,EAClC,OAA0B,EAC1B,SAAmB;;QACnB,MAAM,MAAM,GAAuB,EAAE,CAAC;QAEtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE;YAChC,MAAM,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC;YAChC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEvC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;YAEvD,MAAM,IAAA,oBAAM,EAAC;gBACX,UAAU;gBACV,YAAY,EAAE,OAAO,CAAC,QAAQ;gBAC9B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,MAAM,CAAC,cAAc;aACnC,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,IAAA,oBAAQ,EAAC,WAAW,CAAC,CAAC;YACnC,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC;YAC9C,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;YAC3E,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;YAE9C,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAC;SACtD;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AA7BD,sCA6BC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NormalizedFederationConfig } from '../config/federation-config';
|
|
2
|
+
import { SharedInfo } from '@softarc/native-federation-runtime';
|
|
3
|
+
import { FederationOptions } from '../core/federation-options';
|
|
4
|
+
export declare function bundleSharedMappings(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[]): Promise<Array<SharedInfo>>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundleSharedMappings = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const build_utils_1 = require("../utils/build-utils");
|
|
8
|
+
const hash_file_1 = require("../utils/hash-file");
|
|
9
|
+
function bundleSharedMappings(config, fedOptions, externals) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const result = [];
|
|
12
|
+
for (const m of config.sharedMappings) {
|
|
13
|
+
const key = m.key.replace(/[^A-Za-z0-9]/g, '_');
|
|
14
|
+
const outFileName = key + '.js';
|
|
15
|
+
const outFilePath = path.join(fedOptions.outputPath, outFileName);
|
|
16
|
+
console.info('Bundling shared mapping', m.key, '...');
|
|
17
|
+
try {
|
|
18
|
+
yield (0, build_utils_1.bundle)({
|
|
19
|
+
entryPoint: m.path,
|
|
20
|
+
tsConfigPath: fedOptions.tsConfig,
|
|
21
|
+
external: externals,
|
|
22
|
+
outfile: outFilePath,
|
|
23
|
+
mappedPaths: [],
|
|
24
|
+
});
|
|
25
|
+
const hash = (0, hash_file_1.hashFile)(outFilePath);
|
|
26
|
+
const hashedOutFileName = `${key}-${hash}.js`;
|
|
27
|
+
const hashedOutFilePath = path.join(fedOptions.outputPath, hashedOutFileName);
|
|
28
|
+
fs.renameSync(outFilePath, hashedOutFilePath);
|
|
29
|
+
result.push({
|
|
30
|
+
packageName: m.key,
|
|
31
|
+
outFileName: hashedOutFileName,
|
|
32
|
+
requiredVersion: '',
|
|
33
|
+
singleton: true,
|
|
34
|
+
strictVersion: false,
|
|
35
|
+
version: '',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
// TODO: add logger
|
|
40
|
+
console.error('Error bundling shared mapping ' + m.key);
|
|
41
|
+
console.error(` >> If you don't need this mapping to shared, you can explicity configure the sharedMappings property in your federation.config.js`);
|
|
42
|
+
if (fedOptions.verbose) {
|
|
43
|
+
console.error(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.bundleSharedMappings = bundleSharedMappings;
|
|
51
|
+
//# sourceMappingURL=bundle-shared-mappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-shared-mappings.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/bundle-shared-mappings.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,yBAAyB;AAEzB,sDAA8C;AAE9C,kDAA8C;AAG9C,SAAsB,oBAAoB,CACxC,MAAkC,EAClC,UAA6B,EAC7B,SAAmB;;QACnB,MAAM,MAAM,GAAsB,EAAE,CAAC;QAErC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,cAAc,EAAE;YACrC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC;YAChC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAElE,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAEtD,IAAI;gBACF,MAAM,IAAA,oBAAM,EAAC;oBACX,UAAU,EAAE,CAAC,CAAC,IAAI;oBAClB,YAAY,EAAE,UAAU,CAAC,QAAQ;oBACjC,QAAQ,EAAE,SAAS;oBACnB,OAAO,EAAE,WAAW;oBACpB,WAAW,EAAE,EAAE;iBAChB,CAAC,CAAC;gBAEH,MAAM,IAAI,GAAG,IAAA,oBAAQ,EAAC,WAAW,CAAC,CAAC;gBACnC,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC;gBAC9C,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CACjC,UAAU,CAAC,UAAU,EACrB,iBAAiB,CAClB,CAAC;gBACF,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;gBAE9C,MAAM,CAAC,IAAI,CAAC;oBACV,WAAW,EAAE,CAAC,CAAC,GAAG;oBAClB,WAAW,EAAE,iBAAiB;oBAC9B,eAAe,EAAE,EAAE;oBACnB,SAAS,EAAE,IAAI;oBACf,aAAa,EAAE,KAAK;oBACpB,OAAO,EAAE,EAAE;iBACZ,CAAC,CAAC;aACJ;YAAC,OAAO,CAAC,EAAE;gBAEV,mBAAmB;gBACnB,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;gBACxD,OAAO,CAAC,KAAK,CACX,qIAAqI,CACtI,CAAC;gBAEF,IAAI,UAAU,CAAC,OAAO,EAAE;oBACtB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBAClB;aACF;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AArDD,oDAqDC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NormalizedFederationConfig } from '../config/federation-config';
|
|
2
|
+
import { SharedInfo } from '@softarc/native-federation-runtime';
|
|
3
|
+
import { FederationOptions } from './federation-options';
|
|
4
|
+
export declare function bundleShared(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[]): Promise<Array<SharedInfo>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundleShared = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const build_utils_1 = require("../utils/build-utils");
|
|
8
|
+
const package_info_1 = require("../utils/package-info");
|
|
9
|
+
const default_skip_list_1 = require("./default-skip-list");
|
|
10
|
+
const copy_src_map_if_exists_1 = require("../utils/copy-src-map-if-exists");
|
|
11
|
+
function bundleShared(config, fedOptions, externals) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const result = [];
|
|
14
|
+
const packageInfos = Object.keys(config.shared)
|
|
15
|
+
.filter(packageName => !default_skip_list_1.DEFAULT_SKIP_LIST.has(packageName))
|
|
16
|
+
.map(packageName => (0, package_info_1.getPackageInfo)(packageName, fedOptions.workspaceRoot))
|
|
17
|
+
.filter((pi) => !!pi);
|
|
18
|
+
for (const pi of packageInfos) {
|
|
19
|
+
// TODO: add logger
|
|
20
|
+
console.info('Bundling shared package', pi.packageName, '...');
|
|
21
|
+
const encName = pi.packageName.replace(/[^A-Za-z0-9]/g, '_');
|
|
22
|
+
const encVersion = pi.version.replace(/[^A-Za-z0-9]/g, '_');
|
|
23
|
+
const outFileName = `${encName}-${encVersion}.js`;
|
|
24
|
+
const cachePath = path.join(fedOptions.workspaceRoot, 'node_modules/.cache/native-federation');
|
|
25
|
+
fs.mkdirSync(cachePath, { recursive: true });
|
|
26
|
+
const cachedFile = path.join(cachePath, outFileName);
|
|
27
|
+
if (!fs.existsSync(cachedFile)) {
|
|
28
|
+
yield (0, build_utils_1.bundle)({
|
|
29
|
+
entryPoint: pi.entryPoint,
|
|
30
|
+
tsConfigPath: fedOptions.tsConfig,
|
|
31
|
+
external: externals,
|
|
32
|
+
outfile: cachedFile,
|
|
33
|
+
mappedPaths: config.sharedMappings,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const shared = config.shared[pi.packageName];
|
|
37
|
+
result.push({
|
|
38
|
+
packageName: pi.packageName,
|
|
39
|
+
outFileName: outFileName,
|
|
40
|
+
requiredVersion: shared.requiredVersion,
|
|
41
|
+
singleton: shared.singleton,
|
|
42
|
+
strictVersion: shared.strictVersion,
|
|
43
|
+
version: pi.version,
|
|
44
|
+
});
|
|
45
|
+
const fullOutputPath = path.join(fedOptions.workspaceRoot, fedOptions.outputPath, outFileName);
|
|
46
|
+
fs.copyFileSync(cachedFile, fullOutputPath);
|
|
47
|
+
(0, copy_src_map_if_exists_1.copySrcMapIfExists)(cachedFile, fullOutputPath);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.bundleShared = bundleShared;
|
|
53
|
+
//# sourceMappingURL=bundle-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-shared.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/bundle-shared.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,yBAAyB;AAEzB,sDAA8C;AAC9C,wDAAoE;AAGpE,2DAAwD;AACxD,4EAAqE;AAErE,SAAsB,YAAY,CAChC,MAAkC,EAClC,UAA6B,EAC7B,SAAmB;;QACnB,MAAM,MAAM,GAAsB,EAAE,CAAC;QAErC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;aAC5C,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,qCAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;aAC1D,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,IAAA,6BAAc,EAAC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;aACzE,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,C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AAC,aAAa;gBACnC,OAAO,EAAE,EAAE,CAAC,OAAO;aACpB,CAAC,CAAC;YAEH,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC9B,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,UAAU,EACrB,WAAW,CACZ,CAAC;YACF,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;YAC5C,IAAA,2CAAkB,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;SAChD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AA7DD,oCA6DC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_SKIP_LIST: Set<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SKIP_LIST = void 0;
|
|
4
|
+
exports.DEFAULT_SKIP_LIST = new Set([
|
|
5
|
+
'@softarc/module-federation-runtime',
|
|
6
|
+
'@softarc/module-federation-core',
|
|
7
|
+
'@angular-architects/native-federation',
|
|
8
|
+
'@angular-architects/native-federation-runtime',
|
|
9
|
+
'es-module-shims',
|
|
10
|
+
]);
|
|
11
|
+
//# sourceMappingURL=default-skip-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-skip-list.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/default-skip-list.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACvC,oCAAoC;IACpC,iCAAiC;IACjC,uCAAuC;IACvC,+CAA+C;IAC/C,iBAAiB;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-options.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/federation-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExternals = void 0;
|
|
4
|
+
const default_skip_list_1 = require("./default-skip-list");
|
|
5
|
+
function getExternals(config) {
|
|
6
|
+
const shared = Object.keys(config.shared);
|
|
7
|
+
const sharedMappings = config.sharedMappings.map((m) => m.key);
|
|
8
|
+
const externals = [...shared, ...sharedMappings];
|
|
9
|
+
return externals.filter((p) => !default_skip_list_1.DEFAULT_SKIP_LIST.has(p));
|
|
10
|
+
}
|
|
11
|
+
exports.getExternals = getExternals;
|
|
12
|
+
//# sourceMappingURL=get-externals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-externals.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/get-externals.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AAExD,SAAgB,YAAY,CAAC,MAAkC;IAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAE/D,MAAM,SAAS,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC;IAEjD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,qCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAPD,oCAOC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFederationConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
function loadFederationConfig(fullConfigPath) {
|
|
6
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
7
|
+
const config = (yield Promise.resolve().then(() => require(fullConfigPath)));
|
|
8
|
+
return config;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.loadFederationConfig = loadFederationConfig;
|
|
12
|
+
//# sourceMappingURL=load-federation-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-federation-config.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/load-federation-config.ts"],"names":[],"mappings":";;;;AAEA,SAAsB,oBAAoB,CAAC,cAAsB;;QAC/D,MAAM,MAAM,GAAG,CAAC,2CAAa,cAAc,EAAC,CAA+B,CAAC;QAC5E,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAHD,oDAGC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFederationInfo = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
function writeFederationInfo(federationInfo, fedOptions) {
|
|
7
|
+
const metaDataPath = path.join(fedOptions.workspaceRoot, fedOptions.outputPath, 'remoteEntry.json');
|
|
8
|
+
fs.writeFileSync(metaDataPath, JSON.stringify(federationInfo, null, 2));
|
|
9
|
+
}
|
|
10
|
+
exports.writeFederationInfo = writeFederationInfo;
|
|
11
|
+
//# sourceMappingURL=write-federation-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-federation-info.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/write-federation-info.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AAIzB,SAAgB,mBAAmB,CACjC,cAA8B,EAC9B,UAA6B;IAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAC5B,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,UAAU,EACrB,kBAAkB,CACnB,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AATD,kDASC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeImportMap = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
function writeImportMap(sharedInfo, fedOption) {
|
|
7
|
+
const imports = sharedInfo.reduce((acc, cur) => {
|
|
8
|
+
return Object.assign(Object.assign({}, acc), { [cur.packageName]: cur.outFileName });
|
|
9
|
+
}, {});
|
|
10
|
+
const importMap = { imports };
|
|
11
|
+
const importMapPath = path.join(fedOption.workspaceRoot, fedOption.outputPath, 'importmap.json');
|
|
12
|
+
fs.writeFileSync(importMapPath, JSON.stringify(importMap, null, 2));
|
|
13
|
+
}
|
|
14
|
+
exports.writeImportMap = writeImportMap;
|
|
15
|
+
//# sourceMappingURL=write-import-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-import-map.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/write-import-map.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AAIzB,SAAgB,cAAc,CAC5B,UAAwB,EACxB,SAA4B;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC7C,uCACK,GAAG,KACN,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,WAAW,IAClC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,EAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAC7B,SAAS,CAAC,aAAa,EACvB,SAAS,CAAC,UAAU,EACpB,gBAAgB,CACjB,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAjBD,wCAiBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundle = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const build_adapter_1 = require("../core/build-adapter");
|
|
6
|
+
function bundle(options) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const adapter = (0, build_adapter_1.getBuildAdapter)();
|
|
9
|
+
yield adapter(options);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.bundle = bundle;
|
|
13
|
+
//# sourceMappingURL=build-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-utils.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/utils/build-utils.ts"],"names":[],"mappings":";;;;AAAA,yDAA6E;AAE7E,SAAsB,MAAM,CAAC,OAA4B;;QACvD,MAAM,OAAO,GAAG,IAAA,+BAAe,GAAE,CAAC;QAClC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CAAA;AAHD,wBAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copySrcMapIfExists(cachedFile: string, fullOutputPath: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copySrcMapIfExists = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
function copySrcMapIfExists(cachedFile, fullOutputPath) {
|
|
6
|
+
const mapSrc = cachedFile + '.map';
|
|
7
|
+
const mapDest = fullOutputPath + '.map';
|
|
8
|
+
if (fs.existsSync(mapSrc)) {
|
|
9
|
+
fs.copyFileSync(mapSrc, mapDest);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.copySrcMapIfExists = copySrcMapIfExists;
|
|
13
|
+
//# sourceMappingURL=copy-src-map-if-exists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-src-map-if-exists.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/utils/copy-src-map-if-exists.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AAEzB,SAAgB,kBAAkB,CAAC,UAAkB,EAAE,cAAsB;IAC3E,MAAM,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;IACnC,MAAM,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;IAExC,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QACzB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;AACH,CAAC;AAPD,gDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashFile(fileName: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashFile = void 0;
|
|
4
|
+
const crypto = require("crypto");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
function hashFile(fileName) {
|
|
7
|
+
const fileBuffer = fs.readFileSync(fileName);
|
|
8
|
+
const hashSum = crypto.createHash('md5');
|
|
9
|
+
hashSum.update(fileBuffer);
|
|
10
|
+
return hashSum.digest('hex');
|
|
11
|
+
}
|
|
12
|
+
exports.hashFile = hashFile;
|
|
13
|
+
//# sourceMappingURL=hash-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-file.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/utils/hash-file.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yBAAyB;AAEzB,SAAgB,QAAQ,CAAC,QAAgB;IACvC,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AALD,4BAKC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface MappedPath {
|
|
2
|
+
key: string;
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GetMappedPathsOptions {
|
|
6
|
+
rootTsConfigPath: string;
|
|
7
|
+
sharedMappings?: string[];
|
|
8
|
+
rootPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }: GetMappedPathsOptions): Array<MappedPath>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMappedPaths = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const JSON5 = require("json5");
|
|
7
|
+
function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }) {
|
|
8
|
+
var _a;
|
|
9
|
+
const result = [];
|
|
10
|
+
if (!path.isAbsolute(rootTsConfigPath)) {
|
|
11
|
+
throw new Error('SharedMappings.register: tsConfigPath needs to be an absolute path!');
|
|
12
|
+
}
|
|
13
|
+
if (!rootPath) {
|
|
14
|
+
rootPath = path.normalize(path.dirname(rootTsConfigPath));
|
|
15
|
+
}
|
|
16
|
+
const shareAll = !sharedMappings;
|
|
17
|
+
if (!sharedMappings) {
|
|
18
|
+
sharedMappings = [];
|
|
19
|
+
}
|
|
20
|
+
const tsConfig = JSON5.parse(fs.readFileSync(rootTsConfigPath, { encoding: 'utf-8' }));
|
|
21
|
+
const mappings = (_a = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths;
|
|
22
|
+
if (!mappings) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
for (const key in mappings) {
|
|
26
|
+
const libPath = path.normalize(path.join(rootPath, mappings[key][0]));
|
|
27
|
+
if (sharedMappings.includes(key) || shareAll) {
|
|
28
|
+
result.push({
|
|
29
|
+
key,
|
|
30
|
+
path: libPath,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
exports.getMappedPaths = getMappedPaths;
|
|
37
|
+
//# sourceMappingURL=mapped-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapped-paths.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/utils/mapped-paths.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,+BAA+B;AAa/B,SAAgB,cAAc,CAAC,EAC7B,gBAAgB,EAChB,cAAc,EACd,QAAQ,GACc;;IACtB,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;KACH;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC3D;IACD,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC;IAEjC,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAC1B,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CACzD,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe,0CAAE,KAAK,CAAC;IAElD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,MAAM,CAAC;KACf;IAED,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtE,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE;YAC5C,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG;gBACH,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;SACJ;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA5CD,wCA4CC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface PackageInfo {
|
|
2
|
+
packageName: string;
|
|
3
|
+
entryPoint: string;
|
|
4
|
+
version: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PartialPackageJson {
|
|
7
|
+
module: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function getPackageInfo(packageName: string, workspaceRoot: string): PackageInfo | null;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageInfo = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function getPackageInfo(packageName, workspaceRoot) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const projectRoot = workspaceRoot;
|
|
9
|
+
const mainPkgName = getPkgFolder(packageName);
|
|
10
|
+
const mainPkgPath = path.join(projectRoot, 'node_modules', mainPkgName);
|
|
11
|
+
const mainPkgJsonPath = path.join(mainPkgPath, 'package.json');
|
|
12
|
+
if (!fs.existsSync(mainPkgPath)) {
|
|
13
|
+
// TODO: Add logger
|
|
14
|
+
// context.logger.warn('No package.json found for ' + packageName);
|
|
15
|
+
console.warn('No package.json found for ' + packageName);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const mainPkgJson = readJson(mainPkgJsonPath);
|
|
19
|
+
const version = mainPkgJson['version'];
|
|
20
|
+
if (!version) {
|
|
21
|
+
// TODO: Add logger
|
|
22
|
+
// context.logger.warn('No version found for ' + packageName);
|
|
23
|
+
console.warn('No version found for ' + packageName);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
let relSecondaryPath = path.relative(mainPkgName, packageName);
|
|
27
|
+
if (!relSecondaryPath) {
|
|
28
|
+
relSecondaryPath = '.';
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
relSecondaryPath = './' + relSecondaryPath;
|
|
32
|
+
}
|
|
33
|
+
let cand = (_b = (_a = mainPkgJson === null || mainPkgJson === void 0 ? void 0 : mainPkgJson.exports) === null || _a === void 0 ? void 0 : _a[relSecondaryPath]) === null || _b === void 0 ? void 0 : _b.default;
|
|
34
|
+
if (cand) {
|
|
35
|
+
return {
|
|
36
|
+
entryPoint: path.join(mainPkgPath, cand),
|
|
37
|
+
packageName,
|
|
38
|
+
version,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
cand = mainPkgJson['module'];
|
|
42
|
+
if (cand && relSecondaryPath === '.') {
|
|
43
|
+
return {
|
|
44
|
+
entryPoint: path.join(mainPkgPath, cand),
|
|
45
|
+
packageName,
|
|
46
|
+
version,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const secondaryPgkPath = path.join(projectRoot, 'node_modules', packageName);
|
|
50
|
+
const secondaryPgkJsonPath = path.join(secondaryPgkPath, 'package.json');
|
|
51
|
+
let secondaryPgkJson = null;
|
|
52
|
+
if (fs.existsSync(secondaryPgkJsonPath)) {
|
|
53
|
+
secondaryPgkJson = readJson(secondaryPgkJsonPath);
|
|
54
|
+
}
|
|
55
|
+
if (secondaryPgkJson && secondaryPgkJson.module) {
|
|
56
|
+
return {
|
|
57
|
+
entryPoint: path.join(secondaryPgkPath, secondaryPgkJson.module),
|
|
58
|
+
packageName,
|
|
59
|
+
version,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
cand = path.join(secondaryPgkPath, 'index.mjs');
|
|
63
|
+
if (fs.existsSync(cand)) {
|
|
64
|
+
return {
|
|
65
|
+
entryPoint: cand,
|
|
66
|
+
packageName,
|
|
67
|
+
version,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
cand = path.join(secondaryPgkPath, 'index.js');
|
|
71
|
+
if (fs.existsSync(cand)) {
|
|
72
|
+
return {
|
|
73
|
+
entryPoint: cand,
|
|
74
|
+
packageName,
|
|
75
|
+
version,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// TODO: Add logger
|
|
79
|
+
console.warn('No esm-based entry point found for ' + packageName);
|
|
80
|
+
console.warn(' >> Did you confuse dependencies with depDependencies in your package.json or your federation config?');
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
exports.getPackageInfo = getPackageInfo;
|
|
84
|
+
function readJson(mainPkgJsonPath) {
|
|
85
|
+
return JSON.parse(fs.readFileSync(mainPkgJsonPath, 'utf-8'));
|
|
86
|
+
}
|
|
87
|
+
function getPkgFolder(packageName) {
|
|
88
|
+
const parts = packageName.split('/');
|
|
89
|
+
let folder = parts[0];
|
|
90
|
+
if (folder.startsWith('@')) {
|
|
91
|
+
folder += '/' + parts[1];
|
|
92
|
+
}
|
|
93
|
+
return folder;
|
|
94
|
+
}
|
|
95
|
+
// const pkg = process.argv[2]
|
|
96
|
+
// console.log('pkg', pkg);
|
|
97
|
+
// const r = getPackageInfo('D:/Dokumente/projekte/mf-plugin/angular-architects/', pkg);
|
|
98
|
+
// console.log('entry', r);
|
|
99
|
+
//# sourceMappingURL=package-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-info.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/utils/package-info.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAY7B,SAAgB,cAAc,CAC5B,WAAmB,EACnB,aAAqB;;IAErB,MAAM,WAAW,GAAG,aAAa,CAAC;IAClC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE9C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAE/D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAE/B,mBAAmB;QACnB,mEAAmE;QACnE,OAAO,CAAC,IAAI,CAAC,4BAA4B,GAAG,WAAW,CAAC,CAAC;QAEzD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;IAE9C,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAW,CAAC;IAEjD,IAAI,CAAC,OAAO,EAAE;QAEZ,mBAAmB;QACnB,8DAA8D;QAC9D,OAAO,CAAC,IAAI,CAAC,uBAAuB,GAAG,WAAW,CAAC,CAAC;QAEpD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC/D,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,GAAG,CAAC;KACxB;SAAM;QACL,gBAAgB,GAAG,IAAI,GAAG,gBAAgB,CAAC;KAC5C;IAED,IAAI,IAAI,GAAG,MAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,0CAAG,gBAAgB,CAAC,0CAAE,OAAO,CAAC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