@softarc/native-federation 1.1.1-beta.0 → 1.1.2
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 +9 -9
- package/build.d.ts +1 -1
- package/build.js +4 -4
- package/package.json +4 -3
- package/src/build.d.ts +18 -18
- package/src/build.js +34 -34
- package/src/config.d.ts +1 -1
- package/src/config.js +5 -5
- package/src/index.d.ts +1 -1
- package/src/index.js +4 -4
- package/src/lib/config/configuration-context.d.ts +7 -7
- package/src/lib/config/configuration-context.js +16 -16
- package/src/lib/config/configuration-context.js.map +1 -1
- package/src/lib/config/federation-config.d.ts +29 -29
- package/src/lib/config/federation-config.js +2 -2
- package/src/lib/config/share-utils.d.ts +16 -16
- package/src/lib/config/share-utils.js +235 -235
- package/src/lib/config/share-utils.js.map +1 -1
- package/src/lib/config/with-native-federation.d.ts +2 -2
- package/src/lib/config/with-native-federation.js +58 -58
- package/src/lib/core/build-adapter.d.ts +17 -15
- package/src/lib/core/build-adapter.js +17 -17
- package/src/lib/core/build-adapter.js.map +1 -1
- package/src/lib/core/build-for-federation.d.ts +9 -8
- package/src/lib/core/build-for-federation.js +34 -33
- package/src/lib/core/build-for-federation.js.map +1 -1
- package/src/lib/core/bundle-exposed.d.ts +5 -5
- package/src/lib/core/bundle-exposed.js +74 -73
- package/src/lib/core/bundle-exposed.js.map +1 -1
- package/src/lib/core/bundle-shared-mappings.d.ts +5 -5
- package/src/lib/core/bundle-shared-mappings.js +103 -102
- package/src/lib/core/bundle-shared-mappings.js.map +1 -1
- package/src/lib/core/bundle-shared.d.ts +4 -4
- package/src/lib/core/bundle-shared.js +91 -99
- package/src/lib/core/bundle-shared.js.map +1 -1
- package/src/lib/core/default-skip-list.d.ts +12 -12
- package/src/lib/core/default-skip-list.js +39 -39
- package/src/lib/core/default-skip-list.js.map +1 -1
- package/src/lib/core/federation-builder.d.ts +18 -16
- package/src/lib/core/federation-builder.js +44 -39
- package/src/lib/core/federation-builder.js.map +1 -1
- package/src/lib/core/federation-options.d.ts +10 -10
- package/src/lib/core/federation-options.js +2 -2
- package/src/lib/core/get-externals.d.ts +2 -2
- package/src/lib/core/get-externals.js +12 -11
- package/src/lib/core/get-externals.js.map +1 -1
- package/src/lib/core/load-federation-config.d.ts +3 -3
- package/src/lib/core/load-federation-config.js +17 -17
- package/src/lib/core/load-federation-config.js.map +1 -1
- package/src/lib/core/write-federation-info.d.ts +3 -3
- package/src/lib/core/write-federation-info.js +11 -11
- package/src/lib/core/write-import-map.d.ts +3 -3
- package/src/lib/core/write-import-map.js +15 -15
- package/src/lib/utils/build-utils.d.ts +2 -2
- package/src/lib/utils/build-utils.js +12 -12
- package/src/lib/utils/copy-src-map-if-exists.d.ts +1 -1
- package/src/lib/utils/copy-src-map-if-exists.js +13 -13
- package/src/lib/utils/hash-file.d.ts +1 -1
- package/src/lib/utils/hash-file.js +13 -13
- package/src/lib/utils/logger.d.ts +10 -10
- package/src/lib/utils/logger.js +38 -38
- package/src/lib/utils/mapped-paths.d.ts +10 -10
- package/src/lib/utils/mapped-paths.js +37 -37
- package/src/lib/utils/normalize.d.ts +1 -1
- package/src/lib/utils/normalize.js +17 -17
- package/src/lib/utils/normalize.js.map +1 -1
- package/src/lib/utils/package-info.d.ts +22 -22
- package/src/lib/utils/package-info.js +270 -250
- package/src/lib/utils/package-info.js.map +1 -1
|
@@ -1,236 +1,236 @@
|
|
|
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
|
-
const package_info_1 = require("../utils/package-info");
|
|
9
|
-
const configuration_context_1 = require("./configuration-context");
|
|
10
|
-
const logger_1 = require("../utils/logger");
|
|
11
|
-
let inferVersion = false;
|
|
12
|
-
exports.DEFAULT_SECONARIES_SKIP_LIST = [
|
|
13
|
-
'@angular/router/upgrade',
|
|
14
|
-
'@angular/common/upgrade',
|
|
15
|
-
];
|
|
16
|
-
function findRootTsConfigJson() {
|
|
17
|
-
const packageJson = findPackageJson((0, process_1.cwd)());
|
|
18
|
-
const projectRoot = path.dirname(packageJson);
|
|
19
|
-
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
20
|
-
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
21
|
-
if (fs.existsSync(tsConfigBaseJson)) {
|
|
22
|
-
return tsConfigBaseJson;
|
|
23
|
-
}
|
|
24
|
-
else if (fs.existsSync(tsConfigJson)) {
|
|
25
|
-
return tsConfigJson;
|
|
26
|
-
}
|
|
27
|
-
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
28
|
-
}
|
|
29
|
-
exports.findRootTsConfigJson = findRootTsConfigJson;
|
|
30
|
-
function findPackageJson(folder) {
|
|
31
|
-
while (!fs.existsSync(path.join(folder, 'package.json')) &&
|
|
32
|
-
path.dirname(folder) !== folder) {
|
|
33
|
-
folder = path.dirname(folder);
|
|
34
|
-
}
|
|
35
|
-
const filePath = path.join(folder, 'package.json');
|
|
36
|
-
if (fs.existsSync(filePath)) {
|
|
37
|
-
return filePath;
|
|
38
|
-
}
|
|
39
|
-
throw new Error('no package.json found. Searched the following folder and all parents: ' +
|
|
40
|
-
folder);
|
|
41
|
-
}
|
|
42
|
-
function readVersionMap(packagePath) {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
44
|
-
const json = require(packagePath);
|
|
45
|
-
const versions = Object.assign({}, json['dependencies']);
|
|
46
|
-
return versions;
|
|
47
|
-
}
|
|
48
|
-
function lookupVersion(key, workspaceRoot) {
|
|
49
|
-
const versionMaps = (0, package_info_1.getVersionMaps)(workspaceRoot, workspaceRoot);
|
|
50
|
-
for (const versionMap of versionMaps) {
|
|
51
|
-
const version = lookupVersionInMap(key, versionMap);
|
|
52
|
-
if (version) {
|
|
53
|
-
return version;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
|
|
57
|
-
}
|
|
58
|
-
function lookupVersionInMap(key, versions) {
|
|
59
|
-
const parts = key.split('/');
|
|
60
|
-
if (parts.length >= 2 && parts[0].startsWith('@')) {
|
|
61
|
-
key = parts[0] + '/' + parts[1];
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
key = parts[0];
|
|
65
|
-
}
|
|
66
|
-
if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
|
|
67
|
-
key = '@angular-architects/module-federation';
|
|
68
|
-
}
|
|
69
|
-
if (!versions[key]) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return versions[key];
|
|
73
|
-
}
|
|
74
|
-
function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
75
|
-
const files = fs.readdirSync(libPath);
|
|
76
|
-
const dirs = files
|
|
77
|
-
.map((f) => path.join(libPath, f))
|
|
78
|
-
.filter((f) => fs.lstatSync(f).isDirectory() && f !== 'node_modules');
|
|
79
|
-
const secondaries = dirs.filter((d) => fs.existsSync(path.join(d, 'package.json')));
|
|
80
|
-
for (const s of secondaries) {
|
|
81
|
-
const secondaryLibName = s
|
|
82
|
-
.replace(/\\/g, '/')
|
|
83
|
-
.replace(/^.*node_modules[/]/, '');
|
|
84
|
-
if (excludes.includes(secondaryLibName)) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
if ((0, default_skip_list_1.isInSkipList)(secondaryLibName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
acc[secondaryLibName] = Object.assign({}, shareObject);
|
|
91
|
-
_findSecondaries(s, excludes, shareObject, acc);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function findSecondaries(libPath, excludes, shareObject) {
|
|
95
|
-
const acc = {};
|
|
96
|
-
_findSecondaries(libPath, excludes, shareObject, acc);
|
|
97
|
-
return acc;
|
|
98
|
-
}
|
|
99
|
-
function getSecondaries(includeSecondaries, libPath, key, shareObject) {
|
|
100
|
-
let exclude = [...exports.DEFAULT_SECONARIES_SKIP_LIST];
|
|
101
|
-
if (typeof includeSecondaries === 'object') {
|
|
102
|
-
if (Array.isArray(includeSecondaries.skip)) {
|
|
103
|
-
exclude = includeSecondaries.skip;
|
|
104
|
-
}
|
|
105
|
-
else if (typeof includeSecondaries.skip === 'string') {
|
|
106
|
-
exclude = [includeSecondaries.skip];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// const libPath = path.join(path.dirname(packagePath), 'node_modules', key);
|
|
110
|
-
if (!fs.existsSync(libPath)) {
|
|
111
|
-
return {};
|
|
112
|
-
}
|
|
113
|
-
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
|
|
114
|
-
if (configured) {
|
|
115
|
-
return configured;
|
|
116
|
-
}
|
|
117
|
-
// Fallback: Search folders
|
|
118
|
-
const secondaries = findSecondaries(libPath, exclude, shareObject);
|
|
119
|
-
return secondaries;
|
|
120
|
-
}
|
|
121
|
-
function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
122
|
-
const libPackageJson = path.join(libPath, 'package.json');
|
|
123
|
-
if (!fs.existsSync(libPackageJson)) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
|
|
127
|
-
const exports = packageJson['exports'];
|
|
128
|
-
if (!exports) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const keys = Object.keys(exports).filter((key) => key != '.' &&
|
|
132
|
-
key != './package.json' &&
|
|
133
|
-
!key.endsWith('*') &&
|
|
134
|
-
(exports[key]['default'] || typeof exports[key] === 'string'));
|
|
135
|
-
const result = {};
|
|
136
|
-
for (const key of keys) {
|
|
137
|
-
// const relPath = exports[key]['default'];
|
|
138
|
-
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
139
|
-
if (exclude.includes(secondaryName)) {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if ((0, default_skip_list_1.isInSkipList)(secondaryName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
result[secondaryName] = Object.assign({}, shareObject);
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
function shareAll(config = {}, skip = default_skip_list_1.DEFAULT_SKIP_LIST, projectPath = '') {
|
|
150
|
-
// let workspacePath: string | undefined = undefined;
|
|
151
|
-
projectPath = inferProjectPath(projectPath);
|
|
152
|
-
// workspacePath = getConfigContext().workspaceRoot ?? '';
|
|
153
|
-
// if (!workspacePath) {
|
|
154
|
-
// workspacePath = projectPath;
|
|
155
|
-
// }
|
|
156
|
-
const versionMaps = (0, package_info_1.getVersionMaps)(projectPath, projectPath);
|
|
157
|
-
const share = {};
|
|
158
|
-
for (const versions of versionMaps) {
|
|
159
|
-
const preparedSkipList = (0, default_skip_list_1.prepareSkipList)(skip);
|
|
160
|
-
for (const key in versions) {
|
|
161
|
-
if ((0, default_skip_list_1.isInSkipList)(key, preparedSkipList)) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
const inferVersion =
|
|
165
|
-
const requiredVersion = inferVersion
|
|
166
|
-
versions[key]
|
|
167
|
-
config.requiredVersion;
|
|
168
|
-
if (!share[key]) {
|
|
169
|
-
share[key] = Object.assign(Object.assign({}, config), { requiredVersion });
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return module.exports.share(share, projectPath);
|
|
174
|
-
}
|
|
175
|
-
exports.shareAll = shareAll;
|
|
176
|
-
function inferProjectPath(projectPath) {
|
|
177
|
-
if (!projectPath && (0, configuration_context_1.getConfigContext)().packageJson) {
|
|
178
|
-
projectPath = path.dirname((0, configuration_context_1.getConfigContext)().packageJson || '');
|
|
179
|
-
}
|
|
180
|
-
if (!projectPath && (0, configuration_context_1.getConfigContext)().workspaceRoot) {
|
|
181
|
-
projectPath = (0, configuration_context_1.getConfigContext)().workspaceRoot || '';
|
|
182
|
-
}
|
|
183
|
-
if (!projectPath) {
|
|
184
|
-
projectPath = (0, process_1.cwd)();
|
|
185
|
-
}
|
|
186
|
-
return projectPath;
|
|
187
|
-
}
|
|
188
|
-
function setInferVersion(infer) {
|
|
189
|
-
inferVersion = infer;
|
|
190
|
-
}
|
|
191
|
-
exports.setInferVersion = setInferVersion;
|
|
192
|
-
function share(shareObjects, projectPath = '') {
|
|
193
|
-
projectPath = inferProjectPath(projectPath);
|
|
194
|
-
const packagePath = findPackageJson(projectPath);
|
|
195
|
-
// const versions = readVersionMap(packagePath);
|
|
196
|
-
const result = {};
|
|
197
|
-
let includeSecondaries;
|
|
198
|
-
for (const key in shareObjects) {
|
|
199
|
-
includeSecondaries = false;
|
|
200
|
-
const shareObject = shareObjects[key];
|
|
201
|
-
if (shareObject.requiredVersion === 'auto' ||
|
|
202
|
-
(inferVersion && typeof shareObject.requiredVersion === 'undefined')) {
|
|
203
|
-
const version = lookupVersion(key, projectPath);
|
|
204
|
-
shareObject.requiredVersion = version;
|
|
205
|
-
shareObject.version = version.replace(/^\D*/, '');
|
|
206
|
-
}
|
|
207
|
-
if (typeof shareObject.includeSecondaries === 'undefined') {
|
|
208
|
-
shareObject.includeSecondaries = true;
|
|
209
|
-
}
|
|
210
|
-
if (shareObject.includeSecondaries) {
|
|
211
|
-
includeSecondaries = shareObject.includeSecondaries;
|
|
212
|
-
delete shareObject.includeSecondaries;
|
|
213
|
-
}
|
|
214
|
-
result[key] = shareObject;
|
|
215
|
-
if (includeSecondaries) {
|
|
216
|
-
const libPackageJson = (0, package_info_1.findDepPackageJson)(key, path.dirname(packagePath));
|
|
217
|
-
if (!libPackageJson) {
|
|
218
|
-
logger_1.logger.error('Could not find folder containing dep ' + key);
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
const libPath = path.dirname(libPackageJson);
|
|
222
|
-
const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
|
|
223
|
-
if (secondaries) {
|
|
224
|
-
addSecondaries(secondaries, result);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return result;
|
|
229
|
-
}
|
|
230
|
-
exports.share = share;
|
|
231
|
-
function addSecondaries(secondaries, result) {
|
|
232
|
-
for (const key in secondaries) {
|
|
233
|
-
result[key] = secondaries[key];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
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
|
+
const package_info_1 = require("../utils/package-info");
|
|
9
|
+
const configuration_context_1 = require("./configuration-context");
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
let inferVersion = false;
|
|
12
|
+
exports.DEFAULT_SECONARIES_SKIP_LIST = [
|
|
13
|
+
'@angular/router/upgrade',
|
|
14
|
+
'@angular/common/upgrade',
|
|
15
|
+
];
|
|
16
|
+
function findRootTsConfigJson() {
|
|
17
|
+
const packageJson = findPackageJson((0, process_1.cwd)());
|
|
18
|
+
const projectRoot = path.dirname(packageJson);
|
|
19
|
+
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
20
|
+
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
21
|
+
if (fs.existsSync(tsConfigBaseJson)) {
|
|
22
|
+
return tsConfigBaseJson;
|
|
23
|
+
}
|
|
24
|
+
else if (fs.existsSync(tsConfigJson)) {
|
|
25
|
+
return tsConfigJson;
|
|
26
|
+
}
|
|
27
|
+
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
28
|
+
}
|
|
29
|
+
exports.findRootTsConfigJson = findRootTsConfigJson;
|
|
30
|
+
function findPackageJson(folder) {
|
|
31
|
+
while (!fs.existsSync(path.join(folder, 'package.json')) &&
|
|
32
|
+
path.dirname(folder) !== folder) {
|
|
33
|
+
folder = path.dirname(folder);
|
|
34
|
+
}
|
|
35
|
+
const filePath = path.join(folder, 'package.json');
|
|
36
|
+
if (fs.existsSync(filePath)) {
|
|
37
|
+
return filePath;
|
|
38
|
+
}
|
|
39
|
+
throw new Error('no package.json found. Searched the following folder and all parents: ' +
|
|
40
|
+
folder);
|
|
41
|
+
}
|
|
42
|
+
function readVersionMap(packagePath) {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
44
|
+
const json = require(packagePath);
|
|
45
|
+
const versions = Object.assign({}, json['dependencies']);
|
|
46
|
+
return versions;
|
|
47
|
+
}
|
|
48
|
+
function lookupVersion(key, workspaceRoot) {
|
|
49
|
+
const versionMaps = (0, package_info_1.getVersionMaps)(workspaceRoot, workspaceRoot);
|
|
50
|
+
for (const versionMap of versionMaps) {
|
|
51
|
+
const version = lookupVersionInMap(key, versionMap);
|
|
52
|
+
if (version) {
|
|
53
|
+
return version;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
|
|
57
|
+
}
|
|
58
|
+
function lookupVersionInMap(key, versions) {
|
|
59
|
+
const parts = key.split('/');
|
|
60
|
+
if (parts.length >= 2 && parts[0].startsWith('@')) {
|
|
61
|
+
key = parts[0] + '/' + parts[1];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
key = parts[0];
|
|
65
|
+
}
|
|
66
|
+
if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
|
|
67
|
+
key = '@angular-architects/module-federation';
|
|
68
|
+
}
|
|
69
|
+
if (!versions[key]) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return versions[key];
|
|
73
|
+
}
|
|
74
|
+
function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
75
|
+
const files = fs.readdirSync(libPath);
|
|
76
|
+
const dirs = files
|
|
77
|
+
.map((f) => path.join(libPath, f))
|
|
78
|
+
.filter((f) => fs.lstatSync(f).isDirectory() && f !== 'node_modules');
|
|
79
|
+
const secondaries = dirs.filter((d) => fs.existsSync(path.join(d, 'package.json')));
|
|
80
|
+
for (const s of secondaries) {
|
|
81
|
+
const secondaryLibName = s
|
|
82
|
+
.replace(/\\/g, '/')
|
|
83
|
+
.replace(/^.*node_modules[/]/, '');
|
|
84
|
+
if (excludes.includes(secondaryLibName)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if ((0, default_skip_list_1.isInSkipList)(secondaryLibName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
acc[secondaryLibName] = Object.assign({}, shareObject);
|
|
91
|
+
_findSecondaries(s, excludes, shareObject, acc);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function findSecondaries(libPath, excludes, shareObject) {
|
|
95
|
+
const acc = {};
|
|
96
|
+
_findSecondaries(libPath, excludes, shareObject, acc);
|
|
97
|
+
return acc;
|
|
98
|
+
}
|
|
99
|
+
function getSecondaries(includeSecondaries, libPath, key, shareObject) {
|
|
100
|
+
let exclude = [...exports.DEFAULT_SECONARIES_SKIP_LIST];
|
|
101
|
+
if (typeof includeSecondaries === 'object') {
|
|
102
|
+
if (Array.isArray(includeSecondaries.skip)) {
|
|
103
|
+
exclude = includeSecondaries.skip;
|
|
104
|
+
}
|
|
105
|
+
else if (typeof includeSecondaries.skip === 'string') {
|
|
106
|
+
exclude = [includeSecondaries.skip];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// const libPath = path.join(path.dirname(packagePath), 'node_modules', key);
|
|
110
|
+
if (!fs.existsSync(libPath)) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
|
|
114
|
+
if (configured) {
|
|
115
|
+
return configured;
|
|
116
|
+
}
|
|
117
|
+
// Fallback: Search folders
|
|
118
|
+
const secondaries = findSecondaries(libPath, exclude, shareObject);
|
|
119
|
+
return secondaries;
|
|
120
|
+
}
|
|
121
|
+
function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
122
|
+
const libPackageJson = path.join(libPath, 'package.json');
|
|
123
|
+
if (!fs.existsSync(libPackageJson)) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
|
|
127
|
+
const exports = packageJson['exports'];
|
|
128
|
+
if (!exports) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const keys = Object.keys(exports).filter((key) => key != '.' &&
|
|
132
|
+
key != './package.json' &&
|
|
133
|
+
!key.endsWith('*') &&
|
|
134
|
+
(exports[key]['default'] || typeof exports[key] === 'string'));
|
|
135
|
+
const result = {};
|
|
136
|
+
for (const key of keys) {
|
|
137
|
+
// const relPath = exports[key]['default'];
|
|
138
|
+
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
139
|
+
if (exclude.includes(secondaryName)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if ((0, default_skip_list_1.isInSkipList)(secondaryName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
result[secondaryName] = Object.assign({}, shareObject);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function shareAll(config = {}, skip = default_skip_list_1.DEFAULT_SKIP_LIST, projectPath = '') {
|
|
150
|
+
// let workspacePath: string | undefined = undefined;
|
|
151
|
+
projectPath = inferProjectPath(projectPath);
|
|
152
|
+
// workspacePath = getConfigContext().workspaceRoot ?? '';
|
|
153
|
+
// if (!workspacePath) {
|
|
154
|
+
// workspacePath = projectPath;
|
|
155
|
+
// }
|
|
156
|
+
const versionMaps = (0, package_info_1.getVersionMaps)(projectPath, projectPath);
|
|
157
|
+
const share = {};
|
|
158
|
+
for (const versions of versionMaps) {
|
|
159
|
+
const preparedSkipList = (0, default_skip_list_1.prepareSkipList)(skip);
|
|
160
|
+
for (const key in versions) {
|
|
161
|
+
if ((0, default_skip_list_1.isInSkipList)(key, preparedSkipList)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
|
|
165
|
+
const requiredVersion = inferVersion
|
|
166
|
+
? versions[key]
|
|
167
|
+
: config.requiredVersion;
|
|
168
|
+
if (!share[key]) {
|
|
169
|
+
share[key] = Object.assign(Object.assign({}, config), { requiredVersion });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return module.exports.share(share, projectPath);
|
|
174
|
+
}
|
|
175
|
+
exports.shareAll = shareAll;
|
|
176
|
+
function inferProjectPath(projectPath) {
|
|
177
|
+
if (!projectPath && (0, configuration_context_1.getConfigContext)().packageJson) {
|
|
178
|
+
projectPath = path.dirname((0, configuration_context_1.getConfigContext)().packageJson || '');
|
|
179
|
+
}
|
|
180
|
+
if (!projectPath && (0, configuration_context_1.getConfigContext)().workspaceRoot) {
|
|
181
|
+
projectPath = (0, configuration_context_1.getConfigContext)().workspaceRoot || '';
|
|
182
|
+
}
|
|
183
|
+
if (!projectPath) {
|
|
184
|
+
projectPath = (0, process_1.cwd)();
|
|
185
|
+
}
|
|
186
|
+
return projectPath;
|
|
187
|
+
}
|
|
188
|
+
function setInferVersion(infer) {
|
|
189
|
+
inferVersion = infer;
|
|
190
|
+
}
|
|
191
|
+
exports.setInferVersion = setInferVersion;
|
|
192
|
+
function share(shareObjects, projectPath = '') {
|
|
193
|
+
projectPath = inferProjectPath(projectPath);
|
|
194
|
+
const packagePath = findPackageJson(projectPath);
|
|
195
|
+
// const versions = readVersionMap(packagePath);
|
|
196
|
+
const result = {};
|
|
197
|
+
let includeSecondaries;
|
|
198
|
+
for (const key in shareObjects) {
|
|
199
|
+
includeSecondaries = false;
|
|
200
|
+
const shareObject = shareObjects[key];
|
|
201
|
+
if (shareObject.requiredVersion === 'auto' ||
|
|
202
|
+
(inferVersion && typeof shareObject.requiredVersion === 'undefined')) {
|
|
203
|
+
const version = lookupVersion(key, projectPath);
|
|
204
|
+
shareObject.requiredVersion = version;
|
|
205
|
+
shareObject.version = version.replace(/^\D*/, '');
|
|
206
|
+
}
|
|
207
|
+
if (typeof shareObject.includeSecondaries === 'undefined') {
|
|
208
|
+
shareObject.includeSecondaries = true;
|
|
209
|
+
}
|
|
210
|
+
if (shareObject.includeSecondaries) {
|
|
211
|
+
includeSecondaries = shareObject.includeSecondaries;
|
|
212
|
+
delete shareObject.includeSecondaries;
|
|
213
|
+
}
|
|
214
|
+
result[key] = shareObject;
|
|
215
|
+
if (includeSecondaries) {
|
|
216
|
+
const libPackageJson = (0, package_info_1.findDepPackageJson)(key, path.dirname(packagePath));
|
|
217
|
+
if (!libPackageJson) {
|
|
218
|
+
logger_1.logger.error('Could not find folder containing dep ' + key);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const libPath = path.dirname(libPackageJson);
|
|
222
|
+
const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
|
|
223
|
+
if (secondaries) {
|
|
224
|
+
addSecondaries(secondaries, result);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
exports.share = share;
|
|
231
|
+
function addSecondaries(secondaries, result) {
|
|
232
|
+
for (const key in secondaries) {
|
|
233
|
+
result[key] = secondaries[key];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
236
|
//# sourceMappingURL=share-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-utils.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/share-utils.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,yBAA0B;AAC1B,qCAA8B;AAE9B,iEAMmC;AACnC,
|
|
1
|
+
{"version":3,"file":"share-utils.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/share-utils.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,yBAA0B;AAC1B,qCAA8B;AAE9B,iEAMmC;AACnC,wDAK+B;AAC/B,mEAA2D;AAC3D,4CAAyC;AAEzC,IAAI,YAAY,GAAG,KAAK,CAAC;AAEZ,QAAA,4BAA4B,GAAG;IAC1C,yBAAyB;IACzB,yBAAyB;CAC1B,CAAC;AASF,SAAgB,oBAAoB;IAClC,MAAM,WAAW,GAAG,eAAe,CAAC,IAAA,aAAG,GAAE,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAE7D,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,gBAAgB,CAAC;KACzB;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QACtC,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;AAChF,CAAC;AAbD,oDAaC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,OAC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CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;QAE1B,IAAI,kBAAkB,EAAE;YACtB,MAAM,cAAc,GAAG,IAAA,iCAAkB,EAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YAE1E,IAAI,CAAC,cAAc,EAAE;gBACnB,eAAM,CAAC,KAAK,CAAC,uCAAuC,GAAG,GAAG,CAAC,CAAC;gBAC5D,SAAS;aACV;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAE7C,MAAM,WAAW,GAAG,cAAc,CAChC,kBAAkB,EAClB,OAAO,EACP,GAAG,EACH,WAAW,CACZ,CAAC;YACF,IAAI,WAAW,EAAE;gBACf,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aACrC;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAzDD,sBAyDC;AAED,SAAS,cAAc,CACrB,WAAyC,EACzC,MAAW;IAEX,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;KAChC;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FederationConfig, NormalizedFederationConfig } from './federation-config';
|
|
2
|
-
export declare function withNativeFederation(config: FederationConfig): NormalizedFederationConfig;
|
|
1
|
+
import { FederationConfig, NormalizedFederationConfig } from './federation-config';
|
|
2
|
+
export declare function withNativeFederation(config: FederationConfig): NormalizedFederationConfig;
|
|
@@ -1,59 +1,59 @@
|
|
|
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 share_utils_1 = require("./share-utils");
|
|
6
|
-
const default_skip_list_1 = require("../core/default-skip-list");
|
|
7
|
-
const logger_1 = require("../utils/logger");
|
|
8
|
-
function withNativeFederation(config) {
|
|
9
|
-
var _a, _b, _c;
|
|
10
|
-
const skip = (0, default_skip_list_1.prepareSkipList)((_a = config.skip) !== null && _a !== void 0 ? _a : []);
|
|
11
|
-
return {
|
|
12
|
-
name: (_b = config.name) !== null && _b !== void 0 ? _b : '',
|
|
13
|
-
exposes: (_c = config.exposes) !== null && _c !== void 0 ? _c : {},
|
|
14
|
-
shared: normalizeShared(config, skip),
|
|
15
|
-
sharedMappings: normalizeSharedMappings(config, skip),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.withNativeFederation = withNativeFederation;
|
|
19
|
-
function normalizeShared(config, skip) {
|
|
20
|
-
let result = {};
|
|
21
|
-
const shared = config.shared;
|
|
22
|
-
if (!shared) {
|
|
23
|
-
result = (0, share_utils_1.shareAll)({
|
|
24
|
-
singleton: true,
|
|
25
|
-
strictVersion: true,
|
|
26
|
-
requiredVersion: 'auto',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
result = Object.keys(shared).reduce((acc, cur) => {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
-
return (Object.assign(Object.assign({}, acc), { [cur]: {
|
|
33
|
-
requiredVersion: (_a = shared[cur].requiredVersion) !== null && _a !== void 0 ? _a : 'auto',
|
|
34
|
-
singleton: (_b = shared[cur].singleton) !== null && _b !== void 0 ? _b : false,
|
|
35
|
-
strictVersion: (_c = shared[cur].strictVersion) !== null && _c !== void 0 ? _c : false,
|
|
36
|
-
version: shared[cur].version,
|
|
37
|
-
includeSecondaries: shared[cur].includeSecondaries,
|
|
38
|
-
} }));
|
|
39
|
-
}, {});
|
|
40
|
-
//result = share(result) as Record<string, NormalizedSharedConfig>;
|
|
41
|
-
}
|
|
42
|
-
result = Object.keys(result)
|
|
43
|
-
.filter((key) => !(0, default_skip_list_1.isInSkipList)(key, skip))
|
|
44
|
-
.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), { [cur]: result[cur] })), {});
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
function normalizeSharedMappings(config, skip) {
|
|
48
|
-
const rootTsConfigPath = (0, share_utils_1.findRootTsConfigJson)();
|
|
49
|
-
const paths = (0, mapped_paths_1.getMappedPaths)({
|
|
50
|
-
rootTsConfigPath,
|
|
51
|
-
sharedMappings: config.sharedMappings,
|
|
52
|
-
});
|
|
53
|
-
const result = paths.filter((p) => !(0, default_skip_list_1.isInSkipList)(p.key, skip) && !p.key.includes('*'));
|
|
54
|
-
if (paths.find((p) => p.key.includes('*'))) {
|
|
55
|
-
logger_1.logger.warn('Sharing mapped paths with wildcards (*) not supported');
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
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 share_utils_1 = require("./share-utils");
|
|
6
|
+
const default_skip_list_1 = require("../core/default-skip-list");
|
|
7
|
+
const logger_1 = require("../utils/logger");
|
|
8
|
+
function withNativeFederation(config) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const skip = (0, default_skip_list_1.prepareSkipList)((_a = config.skip) !== null && _a !== void 0 ? _a : []);
|
|
11
|
+
return {
|
|
12
|
+
name: (_b = config.name) !== null && _b !== void 0 ? _b : '',
|
|
13
|
+
exposes: (_c = config.exposes) !== null && _c !== void 0 ? _c : {},
|
|
14
|
+
shared: normalizeShared(config, skip),
|
|
15
|
+
sharedMappings: normalizeSharedMappings(config, skip),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.withNativeFederation = withNativeFederation;
|
|
19
|
+
function normalizeShared(config, skip) {
|
|
20
|
+
let result = {};
|
|
21
|
+
const shared = config.shared;
|
|
22
|
+
if (!shared) {
|
|
23
|
+
result = (0, share_utils_1.shareAll)({
|
|
24
|
+
singleton: true,
|
|
25
|
+
strictVersion: true,
|
|
26
|
+
requiredVersion: 'auto',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
result = Object.keys(shared).reduce((acc, cur) => {
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
return (Object.assign(Object.assign({}, acc), { [cur]: {
|
|
33
|
+
requiredVersion: (_a = shared[cur].requiredVersion) !== null && _a !== void 0 ? _a : 'auto',
|
|
34
|
+
singleton: (_b = shared[cur].singleton) !== null && _b !== void 0 ? _b : false,
|
|
35
|
+
strictVersion: (_c = shared[cur].strictVersion) !== null && _c !== void 0 ? _c : false,
|
|
36
|
+
version: shared[cur].version,
|
|
37
|
+
includeSecondaries: shared[cur].includeSecondaries,
|
|
38
|
+
} }));
|
|
39
|
+
}, {});
|
|
40
|
+
//result = share(result) as Record<string, NormalizedSharedConfig>;
|
|
41
|
+
}
|
|
42
|
+
result = Object.keys(result)
|
|
43
|
+
.filter((key) => !(0, default_skip_list_1.isInSkipList)(key, skip))
|
|
44
|
+
.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), { [cur]: result[cur] })), {});
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function normalizeSharedMappings(config, skip) {
|
|
48
|
+
const rootTsConfigPath = (0, share_utils_1.findRootTsConfigJson)();
|
|
49
|
+
const paths = (0, mapped_paths_1.getMappedPaths)({
|
|
50
|
+
rootTsConfigPath,
|
|
51
|
+
sharedMappings: config.sharedMappings,
|
|
52
|
+
});
|
|
53
|
+
const result = paths.filter((p) => !(0, default_skip_list_1.isInSkipList)(p.key, skip) && !p.key.includes('*'));
|
|
54
|
+
if (paths.find((p) => p.key.includes('*'))) {
|
|
55
|
+
logger_1.logger.warn('Sharing mapped paths with wildcards (*) not supported');
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
59
|
//# sourceMappingURL=with-native-federation.js.map
|