@module-federation/esbuild 0.0.80 → 0.0.82
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/dist/build.d.ts +5 -1
- package/dist/build.js +481 -0
- package/dist/build.mjs +380 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -0
- package/dist/index.mjs +2 -0
- package/dist/plugin.js +1247 -0
- package/dist/{plugin.esm.js → plugin.mjs} +198 -317
- package/dist/resolve/esm-resolver.mjs +22 -15
- package/package.json +18 -25
- package/dist/build.cjs.js +0 -532
- package/dist/build.cjs.js.map +0 -1
- package/dist/build.esm.js +0 -494
- package/dist/build.esm.js.map +0 -1
- package/dist/get-externals.cjs.js +0 -22
- package/dist/get-externals.cjs.js.map +0 -1
- package/dist/get-externals.esm.js +0 -20
- package/dist/get-externals.esm.js.map +0 -1
- package/dist/index.cjs.js +0 -6
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -4
- package/dist/index.esm.js.map +0 -1
- package/dist/plugin.cjs.js +0 -1313
- package/dist/plugin.cjs.js.map +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.esm.js.map +0 -1
- package/dist/src/build.d.ts +0 -5
- package/dist/src/index.d.ts +0 -2
- /package/dist/{src/adapters → adapters}/lib/collect-exports.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/commonjs.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/containerPlugin.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/containerReference.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/lexer.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/linkRemotesPlugin.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/manifest.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/plugin.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/react-replacements.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/transform.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/lib/utils.d.ts +0 -0
- /package/dist/{src/lib → lib}/config/configuration-context.d.ts +0 -0
- /package/dist/{src/lib → lib}/config/federation-config.d.ts +0 -0
- /package/dist/{src/lib → lib}/config/share-utils.d.ts +0 -0
- /package/dist/{src/lib → lib}/config/with-native-federation.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/build-adapter.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/createContainerTemplate.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/default-skip-list.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/federation-options.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/get-externals.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/load-federation-config.d.ts +0 -0
- /package/dist/{src/lib → lib}/core/write-federation-info.d.ts +0 -0
- /package/dist/{src/lib → lib}/utils/logger.d.ts +0 -0
- /package/dist/{src/lib → lib}/utils/mapped-paths.d.ts +0 -0
- /package/dist/{src/lib → lib}/utils/normalize.d.ts +0 -0
- /package/dist/{src/lib → lib}/utils/package-info.d.ts +0 -0
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import
|
|
3
|
-
export default (path, options = {})
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import 'path';
|
|
3
|
+
export default ((path, options = {})=>{
|
|
4
|
+
const p = options.path || void 0;
|
|
5
|
+
const mode = options.mode || 'esm';
|
|
6
|
+
if ('cjs' === mode) {
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
if (!p) return require.resolve(path);
|
|
9
|
+
return require.resolve(path, {
|
|
10
|
+
paths: [
|
|
11
|
+
p
|
|
12
|
+
]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
11
15
|
try {
|
|
12
|
-
|
|
16
|
+
return import.meta.resolve(path.join(p, path)).replace(/^file:\/\//, '');
|
|
13
17
|
} catch (e) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const require = createRequire(import.meta.url);
|
|
19
|
+
if (!p) return require.resolve(path);
|
|
20
|
+
return require.resolve(path, {
|
|
21
|
+
paths: [
|
|
22
|
+
p
|
|
23
|
+
]
|
|
24
|
+
});
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
};
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/esbuild",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.82",
|
|
4
4
|
"author": "Zack Jackson (@ScriptedAlchemy)",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/index.
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -21,23 +21,18 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"import": "./dist/index.
|
|
25
|
-
"require": "./dist/index.
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
26
|
},
|
|
27
27
|
"./plugin": {
|
|
28
|
-
"types": "./dist/
|
|
29
|
-
"import": "./dist/plugin.
|
|
30
|
-
"require": "./dist/plugin.
|
|
28
|
+
"types": "./dist/adapters/lib/plugin.d.ts",
|
|
29
|
+
"import": "./dist/plugin.mjs",
|
|
30
|
+
"require": "./dist/plugin.js"
|
|
31
31
|
},
|
|
32
32
|
"./build": {
|
|
33
33
|
"types": "./dist/build.d.ts",
|
|
34
|
-
"import": "./dist/build.
|
|
35
|
-
"require": "./dist/build.
|
|
36
|
-
},
|
|
37
|
-
"./types": {
|
|
38
|
-
"types": "./dist/types.d.ts",
|
|
39
|
-
"import": "./dist/types.esm.js",
|
|
40
|
-
"require": "./dist/types.cjs.js"
|
|
34
|
+
"import": "./dist/build.mjs",
|
|
35
|
+
"require": "./dist/build.js"
|
|
41
36
|
},
|
|
42
37
|
"./*": "./*"
|
|
43
38
|
},
|
|
@@ -46,28 +41,26 @@
|
|
|
46
41
|
".": [
|
|
47
42
|
"./dist/index.d.ts"
|
|
48
43
|
],
|
|
49
|
-
"
|
|
50
|
-
"./dist/
|
|
44
|
+
"build": [
|
|
45
|
+
"./dist/build.d.ts"
|
|
51
46
|
],
|
|
52
|
-
"
|
|
53
|
-
"./dist/
|
|
47
|
+
"plugin": [
|
|
48
|
+
"./dist/adapters/lib/plugin.d.ts"
|
|
54
49
|
]
|
|
55
50
|
}
|
|
56
51
|
},
|
|
57
52
|
"dependencies": {
|
|
58
53
|
"@chialab/esbuild-plugin-commonjs": "^0.18.0",
|
|
59
54
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
|
60
|
-
"@rollup/plugin-commonjs": "^28.0.0",
|
|
61
|
-
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
62
|
-
"@rollup/plugin-replace": "^6.0.1",
|
|
63
55
|
"cjs-module-lexer": "^1.3.1",
|
|
64
56
|
"enhanced-resolve": "^5.16.1",
|
|
65
57
|
"es-module-lexer": "^1.5.3",
|
|
66
58
|
"esbuild": "^0.25.0",
|
|
67
59
|
"json5": "^2.2.3",
|
|
68
60
|
"npmlog": "^7.0.1",
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
"@module-federation/sdk": "0.20.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@rslib/core": "^0.12.4"
|
|
72
65
|
}
|
|
73
66
|
}
|
package/dist/build.cjs.js
DELETED
|
@@ -1,532 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var getExternals = require('./get-externals.cjs.js');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var fs = require('fs');
|
|
6
|
-
var process = require('process');
|
|
7
|
-
var npmlog = require('npmlog');
|
|
8
|
-
require('json5');
|
|
9
|
-
|
|
10
|
-
function _interopNamespaceDefault(e) {
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
|
-
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
29
|
-
|
|
30
|
-
async function loadFederationConfig(fedOptions) {
|
|
31
|
-
const fullConfigPath = path__namespace.join(fedOptions.workspaceRoot, fedOptions.federationConfig);
|
|
32
|
-
if (!fs__namespace.existsSync(fullConfigPath)) {
|
|
33
|
-
throw new Error('Expected ' + fullConfigPath);
|
|
34
|
-
}
|
|
35
|
-
const config = await import(`${fullConfigPath}`);
|
|
36
|
-
return config;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const DEFAULT_SKIP_LIST = [
|
|
40
|
-
'@module-federation/native-federation-runtime',
|
|
41
|
-
'@module-federation/native-federation',
|
|
42
|
-
'@module-federation/native-federation-core',
|
|
43
|
-
'@module-federation/native-federation-esbuild',
|
|
44
|
-
'@angular-architects/native-federation',
|
|
45
|
-
'@angular-architects/native-federation-runtime',
|
|
46
|
-
'es-module-shims',
|
|
47
|
-
'zone.js',
|
|
48
|
-
'tslib/',
|
|
49
|
-
'@angular/localize',
|
|
50
|
-
'@angular/localize/init',
|
|
51
|
-
'@angular/localize/tools',
|
|
52
|
-
'@angular/platform-server',
|
|
53
|
-
'@angular/platform-server/init',
|
|
54
|
-
'@angular/ssr',
|
|
55
|
-
'express',
|
|
56
|
-
/\/schematics(\/|$)/,
|
|
57
|
-
/^@nx\/angular/,
|
|
58
|
-
(pkg)=>pkg.startsWith('@angular/') && !!pkg.match(/\/testing(\/|$)/),
|
|
59
|
-
(pkg)=>pkg.startsWith('@types/'),
|
|
60
|
-
(pkg)=>pkg.startsWith('@module-federation/')
|
|
61
|
-
];
|
|
62
|
-
const PREPARED_DEFAULT_SKIP_LIST = prepareSkipList(DEFAULT_SKIP_LIST);
|
|
63
|
-
function prepareSkipList(skipList) {
|
|
64
|
-
return {
|
|
65
|
-
strings: new Set(skipList.filter((e)=>typeof e === 'string')),
|
|
66
|
-
functions: skipList.filter((e)=>typeof e === 'function'),
|
|
67
|
-
regexps: skipList.filter((e)=>e instanceof RegExp)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function isInSkipList(entry, skipList) {
|
|
71
|
-
if (skipList.strings.has(entry)) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (skipList.functions.some((f)=>f(entry))) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
if (skipList.regexps.some((r)=>r.test(entry))) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let _context = {};
|
|
84
|
-
function getConfigContext() {
|
|
85
|
-
return _context;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */ //@ts-ignore
|
|
89
|
-
const levels = npmlog.levels;
|
|
90
|
-
npmlog.addLevel('error', levels.error, {
|
|
91
|
-
fg: 'brightWhite',
|
|
92
|
-
bg: 'red'
|
|
93
|
-
}, ' ERR! ');
|
|
94
|
-
npmlog.addLevel('warn', levels.info, {
|
|
95
|
-
fg: 'brightWhite',
|
|
96
|
-
bg: 'yellow'
|
|
97
|
-
}, ' WARN ');
|
|
98
|
-
npmlog.addLevel('info', levels.warn, {
|
|
99
|
-
fg: 'brightWhite',
|
|
100
|
-
bg: 'green'
|
|
101
|
-
}, ' INFO ');
|
|
102
|
-
npmlog.addLevel('notice', levels.notice, {
|
|
103
|
-
fg: 'black',
|
|
104
|
-
bg: 'brightYellow'
|
|
105
|
-
}, ' NOTE ');
|
|
106
|
-
npmlog.addLevel('verbose', levels.verbose, {
|
|
107
|
-
fg: 'brightWhite',
|
|
108
|
-
bg: 'brightBlue'
|
|
109
|
-
}, ' VRB! ');
|
|
110
|
-
npmlog.addLevel('silly', levels.silly, {
|
|
111
|
-
fg: 'black',
|
|
112
|
-
bg: 'white'
|
|
113
|
-
}, ' DBG! ');
|
|
114
|
-
const logger = {
|
|
115
|
-
error: (msg)=>npmlog.error('', msg),
|
|
116
|
-
warn: (msg)=>npmlog.warn('', msg),
|
|
117
|
-
notice: (msg)=>npmlog.notice('', msg),
|
|
118
|
-
info: (msg)=>npmlog.info('', msg),
|
|
119
|
-
verbose: (msg)=>npmlog.verbose('', msg),
|
|
120
|
-
debug: (msg)=>npmlog.silly('', msg)
|
|
121
|
-
};
|
|
122
|
-
const setLogLevel = (level)=>{
|
|
123
|
-
npmlog.level = level === 'debug' ? 'silly' : level;
|
|
124
|
-
};
|
|
125
|
-
setLogLevel('info');
|
|
126
|
-
|
|
127
|
-
function normalize(path, trailingSlash) {
|
|
128
|
-
let cand = path.replace(/\\/g, '/');
|
|
129
|
-
while(cand.endsWith('/')){
|
|
130
|
-
cand = cand.substring(0, cand.length - 1);
|
|
131
|
-
}
|
|
132
|
-
{
|
|
133
|
-
return cand + '/';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function _extends$2() {
|
|
138
|
-
_extends$2 = Object.assign || function(target) {
|
|
139
|
-
for(var i = 1; i < arguments.length; i++){
|
|
140
|
-
var source = arguments[i];
|
|
141
|
-
for(var key in source){
|
|
142
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
143
|
-
target[key] = source[key];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return target;
|
|
148
|
-
};
|
|
149
|
-
return _extends$2.apply(this, arguments);
|
|
150
|
-
}
|
|
151
|
-
const packageCache = {};
|
|
152
|
-
function findPackageJsonFiles(project, workspace) {
|
|
153
|
-
return expandFolders(project, workspace).map((f)=>path__namespace.join(f, 'package.json')).filter((f)=>fs__namespace.existsSync(f));
|
|
154
|
-
}
|
|
155
|
-
function expandFolders(child, parent) {
|
|
156
|
-
const result = [];
|
|
157
|
-
parent = normalize(parent);
|
|
158
|
-
child = normalize(child);
|
|
159
|
-
if (!child.startsWith(parent)) {
|
|
160
|
-
throw new Error(`Workspace folder ${parent} needs to be a parent of the project folder ${child}`);
|
|
161
|
-
}
|
|
162
|
-
let current = child;
|
|
163
|
-
while(current !== parent){
|
|
164
|
-
result.push(current);
|
|
165
|
-
const cand = normalize(path__namespace.dirname(current));
|
|
166
|
-
if (cand === current) {
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
current = cand;
|
|
170
|
-
}
|
|
171
|
-
result.push(parent);
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
function getVersionMapCacheKey(project, workspace) {
|
|
175
|
-
return `${project}**${workspace}`;
|
|
176
|
-
}
|
|
177
|
-
function getVersionMaps(project, workspace) {
|
|
178
|
-
return getPackageJsonFiles(project, workspace).map((json)=>_extends$2({}, json.content['dependencies']));
|
|
179
|
-
}
|
|
180
|
-
function getPackageJsonFiles(project, workspace) {
|
|
181
|
-
const cacheKey = getVersionMapCacheKey(project, workspace);
|
|
182
|
-
let maps = packageCache[cacheKey];
|
|
183
|
-
if (maps) {
|
|
184
|
-
return maps;
|
|
185
|
-
}
|
|
186
|
-
maps = findPackageJsonFiles(project, workspace).map((f)=>{
|
|
187
|
-
const content = JSON.parse(fs__namespace.readFileSync(f, 'utf-8'));
|
|
188
|
-
const directory = normalize(path__namespace.dirname(f));
|
|
189
|
-
const result = {
|
|
190
|
-
content,
|
|
191
|
-
directory
|
|
192
|
-
};
|
|
193
|
-
return result;
|
|
194
|
-
});
|
|
195
|
-
packageCache[cacheKey] = maps;
|
|
196
|
-
return maps;
|
|
197
|
-
}
|
|
198
|
-
function findDepPackageJson(packageName, projectRoot) {
|
|
199
|
-
const mainPkgName = getPkgFolder(packageName);
|
|
200
|
-
let mainPkgPath = path__namespace.join(projectRoot, 'node_modules', mainPkgName);
|
|
201
|
-
let mainPkgJsonPath = path__namespace.join(mainPkgPath, 'package.json');
|
|
202
|
-
let directory = projectRoot;
|
|
203
|
-
while(path__namespace.dirname(directory) !== directory){
|
|
204
|
-
if (fs__namespace.existsSync(mainPkgJsonPath)) {
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
directory = normalize(path__namespace.dirname(directory));
|
|
208
|
-
mainPkgPath = path__namespace.join(directory, 'node_modules', mainPkgName);
|
|
209
|
-
mainPkgJsonPath = path__namespace.join(mainPkgPath, 'package.json');
|
|
210
|
-
}
|
|
211
|
-
if (!fs__namespace.existsSync(mainPkgJsonPath)) {
|
|
212
|
-
logger.verbose('No package.json found for ' + packageName + ' in ' + mainPkgPath);
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
return mainPkgJsonPath;
|
|
216
|
-
}
|
|
217
|
-
function getPkgFolder(packageName) {
|
|
218
|
-
const parts = packageName.split('/');
|
|
219
|
-
let folder = parts[0];
|
|
220
|
-
if (folder.startsWith('@')) {
|
|
221
|
-
folder += '/' + parts[1];
|
|
222
|
-
}
|
|
223
|
-
return folder;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function _extends$1() {
|
|
227
|
-
_extends$1 = Object.assign || function(target) {
|
|
228
|
-
for(var i = 1; i < arguments.length; i++){
|
|
229
|
-
var source = arguments[i];
|
|
230
|
-
for(var key in source){
|
|
231
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
232
|
-
target[key] = source[key];
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return target;
|
|
237
|
-
};
|
|
238
|
-
return _extends$1.apply(this, arguments);
|
|
239
|
-
}
|
|
240
|
-
let inferVersion = false;
|
|
241
|
-
const DEFAULT_SECONARIES_SKIP_LIST = [
|
|
242
|
-
'@angular/router/upgrade',
|
|
243
|
-
'@angular/common/upgrade'
|
|
244
|
-
];
|
|
245
|
-
function findRootTsConfigJson() {
|
|
246
|
-
const packageJson = findPackageJson(process.cwd());
|
|
247
|
-
const projectRoot = path.dirname(packageJson);
|
|
248
|
-
const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
|
|
249
|
-
const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
|
|
250
|
-
if (fs.existsSync(tsConfigBaseJson)) {
|
|
251
|
-
return tsConfigBaseJson;
|
|
252
|
-
} else if (fs.existsSync(tsConfigJson)) {
|
|
253
|
-
return tsConfigJson;
|
|
254
|
-
}
|
|
255
|
-
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
256
|
-
}
|
|
257
|
-
function findPackageJson(folder) {
|
|
258
|
-
while(!fs.existsSync(path.join(folder, 'package.json')) && path.dirname(folder) !== folder){
|
|
259
|
-
folder = path.dirname(folder);
|
|
260
|
-
}
|
|
261
|
-
const filePath = path.join(folder, 'package.json');
|
|
262
|
-
if (fs.existsSync(filePath)) {
|
|
263
|
-
return filePath;
|
|
264
|
-
}
|
|
265
|
-
throw new Error(`No package.json found. Searched the following folder and all parents: ${folder}`);
|
|
266
|
-
}
|
|
267
|
-
function lookupVersion(key, workspaceRoot) {
|
|
268
|
-
const versionMaps = getVersionMaps(workspaceRoot, workspaceRoot);
|
|
269
|
-
for (const versionMap of versionMaps){
|
|
270
|
-
const version = lookupVersionInMap(key, versionMap);
|
|
271
|
-
if (version) {
|
|
272
|
-
return version;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
|
|
276
|
-
}
|
|
277
|
-
function lookupVersionInMap(key, versions) {
|
|
278
|
-
const parts = key.split('/');
|
|
279
|
-
if (parts.length >= 2 && parts[0].startsWith('@')) {
|
|
280
|
-
key = `${parts[0]}/${parts[1]}`;
|
|
281
|
-
} else {
|
|
282
|
-
key = parts[0];
|
|
283
|
-
}
|
|
284
|
-
if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
|
|
285
|
-
key = '@angular-architects/module-federation';
|
|
286
|
-
}
|
|
287
|
-
return versions[key] || null;
|
|
288
|
-
}
|
|
289
|
-
function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
290
|
-
const files = fs.readdirSync(libPath);
|
|
291
|
-
const dirs = files.map((f)=>path.join(libPath, f)).filter((f)=>fs.lstatSync(f).isDirectory() && f !== 'node_modules');
|
|
292
|
-
const secondaries = dirs.filter((d)=>fs.existsSync(path.join(d, 'package.json')));
|
|
293
|
-
for (const s of secondaries){
|
|
294
|
-
const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
|
|
295
|
-
if (excludes.includes(secondaryLibName)) {
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
if (isInSkipList(secondaryLibName, PREPARED_DEFAULT_SKIP_LIST)) {
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
acc[secondaryLibName] = _extends$1({}, shareObject);
|
|
302
|
-
_findSecondaries(s, excludes, shareObject, acc);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function findSecondaries(libPath, excludes, shareObject) {
|
|
306
|
-
const acc = {};
|
|
307
|
-
_findSecondaries(libPath, excludes, shareObject, acc);
|
|
308
|
-
return acc;
|
|
309
|
-
}
|
|
310
|
-
function getSecondaries(includeSecondaries, libPath, key, shareObject) {
|
|
311
|
-
let exclude = [
|
|
312
|
-
...DEFAULT_SECONARIES_SKIP_LIST
|
|
313
|
-
];
|
|
314
|
-
if (typeof includeSecondaries === 'object') {
|
|
315
|
-
if (Array.isArray(includeSecondaries.skip)) {
|
|
316
|
-
exclude = includeSecondaries.skip;
|
|
317
|
-
} else if (typeof includeSecondaries.skip === 'string') {
|
|
318
|
-
exclude = [
|
|
319
|
-
includeSecondaries.skip
|
|
320
|
-
];
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (!fs.existsSync(libPath)) {
|
|
324
|
-
return {};
|
|
325
|
-
}
|
|
326
|
-
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
|
|
327
|
-
if (configured) {
|
|
328
|
-
return configured;
|
|
329
|
-
}
|
|
330
|
-
// Fallback: Search folders
|
|
331
|
-
return findSecondaries(libPath, exclude, shareObject);
|
|
332
|
-
}
|
|
333
|
-
function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
334
|
-
const libPackageJson = path.join(libPath, 'package.json');
|
|
335
|
-
if (!fs.existsSync(libPackageJson)) {
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
|
|
339
|
-
const exports = packageJson['exports'];
|
|
340
|
-
if (!exports) {
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
const keys = Object.keys(exports).filter((key)=>key !== '.' && key !== './package.json' && !key.endsWith('*') && (exports[key]['default'] || typeof exports[key] === 'string'));
|
|
344
|
-
const result = {};
|
|
345
|
-
for (const key of keys){
|
|
346
|
-
const secondaryName = path.join(parent, key).replace(/\\/g, '/');
|
|
347
|
-
if (exclude.includes(secondaryName)) {
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
if (isInSkipList(secondaryName, PREPARED_DEFAULT_SKIP_LIST)) {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
const entry = getDefaultEntry(exports, key);
|
|
354
|
-
if (typeof entry !== 'string') {
|
|
355
|
-
console.log(`No entry point found for ${secondaryName}`);
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
if ([
|
|
359
|
-
'.css',
|
|
360
|
-
'.scss',
|
|
361
|
-
'.less'
|
|
362
|
-
].some((ext)=>entry.endsWith(ext))) {
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
result[secondaryName] = _extends$1({}, shareObject);
|
|
366
|
-
}
|
|
367
|
-
return result;
|
|
368
|
-
}
|
|
369
|
-
function getDefaultEntry(exports, key) {
|
|
370
|
-
let entry;
|
|
371
|
-
if (typeof exports[key] === 'string') {
|
|
372
|
-
entry = exports[key];
|
|
373
|
-
} else {
|
|
374
|
-
var _exports_key;
|
|
375
|
-
entry = (_exports_key = exports[key]) == null ? void 0 : _exports_key['default'];
|
|
376
|
-
if (typeof entry === 'object') {
|
|
377
|
-
entry = entry['default'];
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return entry;
|
|
381
|
-
}
|
|
382
|
-
function shareAll(config, skip = DEFAULT_SKIP_LIST, projectPath = '') {
|
|
383
|
-
projectPath = inferProjectPath(projectPath);
|
|
384
|
-
const versionMaps = getVersionMaps(projectPath, projectPath);
|
|
385
|
-
const shareConfig = {};
|
|
386
|
-
for (const versions of versionMaps){
|
|
387
|
-
const preparedSkipList = prepareSkipList(skip);
|
|
388
|
-
for(const key in versions){
|
|
389
|
-
if (isInSkipList(key, preparedSkipList)) {
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
|
|
393
|
-
const requiredVersion = inferVersion ? versions[key] : config.requiredVersion;
|
|
394
|
-
if (!shareConfig[key]) {
|
|
395
|
-
shareConfig[key] = _extends$1({}, config, {
|
|
396
|
-
requiredVersion
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return share(share, projectPath);
|
|
402
|
-
}
|
|
403
|
-
function inferProjectPath(projectPath) {
|
|
404
|
-
if (!projectPath) {
|
|
405
|
-
projectPath = path.dirname(getConfigContext().packageJson || '');
|
|
406
|
-
}
|
|
407
|
-
if (!projectPath && getConfigContext().workspaceRoot) {
|
|
408
|
-
projectPath = getConfigContext().workspaceRoot || '';
|
|
409
|
-
}
|
|
410
|
-
if (!projectPath) {
|
|
411
|
-
projectPath = process.cwd();
|
|
412
|
-
}
|
|
413
|
-
return projectPath;
|
|
414
|
-
}
|
|
415
|
-
function setInferVersion(infer) {
|
|
416
|
-
inferVersion = infer;
|
|
417
|
-
}
|
|
418
|
-
function share(shareObjects, projectPath = '') {
|
|
419
|
-
projectPath = inferProjectPath(projectPath);
|
|
420
|
-
const packagePath = findPackageJson(projectPath);
|
|
421
|
-
const result = {};
|
|
422
|
-
let includeSecondaries;
|
|
423
|
-
for(const key in shareObjects){
|
|
424
|
-
includeSecondaries = false;
|
|
425
|
-
const shareObject = shareObjects[key];
|
|
426
|
-
if (shareObject.requiredVersion === 'auto' || inferVersion && typeof shareObject.requiredVersion === 'undefined') {
|
|
427
|
-
const version = lookupVersion(key, projectPath);
|
|
428
|
-
shareObject.requiredVersion = version;
|
|
429
|
-
shareObject.version = version.replace(/^\D*/, '');
|
|
430
|
-
}
|
|
431
|
-
if (typeof shareObject.includeSecondaries === 'undefined') {
|
|
432
|
-
shareObject.includeSecondaries = true;
|
|
433
|
-
}
|
|
434
|
-
if (shareObject.includeSecondaries) {
|
|
435
|
-
includeSecondaries = shareObject.includeSecondaries;
|
|
436
|
-
delete shareObject.includeSecondaries;
|
|
437
|
-
}
|
|
438
|
-
result[key] = shareObject;
|
|
439
|
-
if (includeSecondaries) {
|
|
440
|
-
const libPackageJson = findDepPackageJson(key, path.dirname(packagePath));
|
|
441
|
-
if (!libPackageJson) {
|
|
442
|
-
logger.error(`Could not find folder containing dep ${key}`);
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
const libPath = path.dirname(libPackageJson);
|
|
446
|
-
const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
|
|
447
|
-
if (secondaries) {
|
|
448
|
-
addSecondaries(secondaries, result);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
function addSecondaries(secondaries, result) {
|
|
455
|
-
Object.assign(result, secondaries);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
function _extends() {
|
|
459
|
-
_extends = Object.assign || function(target) {
|
|
460
|
-
for(var i = 1; i < arguments.length; i++){
|
|
461
|
-
var source = arguments[i];
|
|
462
|
-
for(var key in source){
|
|
463
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
464
|
-
target[key] = source[key];
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return target;
|
|
469
|
-
};
|
|
470
|
-
return _extends.apply(this, arguments);
|
|
471
|
-
}
|
|
472
|
-
function withFederation(config) {
|
|
473
|
-
var _config_skip;
|
|
474
|
-
const skip = prepareSkipList((_config_skip = config.skip) != null ? _config_skip : []);
|
|
475
|
-
var _config_name, _config_filename, _config_exposes, _config_remotes;
|
|
476
|
-
return {
|
|
477
|
-
name: (_config_name = config.name) != null ? _config_name : '',
|
|
478
|
-
filename: (_config_filename = config.filename) != null ? _config_filename : 'remoteEntry',
|
|
479
|
-
exposes: (_config_exposes = config.exposes) != null ? _config_exposes : {},
|
|
480
|
-
remotes: (_config_remotes = config.remotes) != null ? _config_remotes : {},
|
|
481
|
-
shared: normalizeShared(config, skip)
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
function normalizeShared(config, skip) {
|
|
485
|
-
let result = {};
|
|
486
|
-
const shared = config.shared;
|
|
487
|
-
if (!shared) {
|
|
488
|
-
result = shareAll({
|
|
489
|
-
singleton: true,
|
|
490
|
-
strictVersion: true,
|
|
491
|
-
requiredVersion: 'auto'
|
|
492
|
-
});
|
|
493
|
-
} else {
|
|
494
|
-
result = Object.keys(shared).reduce((acc, cur)=>{
|
|
495
|
-
var _shared_cur_requiredVersion, _shared_cur_singleton, _shared_cur_strictVersion;
|
|
496
|
-
return _extends({}, acc, {
|
|
497
|
-
[cur]: {
|
|
498
|
-
requiredVersion: (_shared_cur_requiredVersion = shared[cur].requiredVersion) != null ? _shared_cur_requiredVersion : 'auto',
|
|
499
|
-
singleton: (_shared_cur_singleton = shared[cur].singleton) != null ? _shared_cur_singleton : false,
|
|
500
|
-
strictVersion: (_shared_cur_strictVersion = shared[cur].strictVersion) != null ? _shared_cur_strictVersion : false,
|
|
501
|
-
version: shared[cur].version,
|
|
502
|
-
includeSecondaries: shared[cur].includeSecondaries
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}, {});
|
|
506
|
-
}
|
|
507
|
-
result = Object.keys(result).filter((key)=>!isInSkipList(key, skip)).reduce((acc, cur)=>_extends({}, acc, {
|
|
508
|
-
[cur]: result[cur]
|
|
509
|
-
}), {});
|
|
510
|
-
return result;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
exports.getExternals = getExternals.getExternals;
|
|
514
|
-
exports.DEFAULT_SECONARIES_SKIP_LIST = DEFAULT_SECONARIES_SKIP_LIST;
|
|
515
|
-
exports._findSecondaries = _findSecondaries;
|
|
516
|
-
exports.addSecondaries = addSecondaries;
|
|
517
|
-
exports.findPackageJson = findPackageJson;
|
|
518
|
-
exports.findRootTsConfigJson = findRootTsConfigJson;
|
|
519
|
-
exports.findSecondaries = findSecondaries;
|
|
520
|
-
exports.getDefaultEntry = getDefaultEntry;
|
|
521
|
-
exports.getSecondaries = getSecondaries;
|
|
522
|
-
exports.loadFederationConfig = loadFederationConfig;
|
|
523
|
-
exports.logger = logger;
|
|
524
|
-
exports.lookupVersion = lookupVersion;
|
|
525
|
-
exports.lookupVersionInMap = lookupVersionInMap;
|
|
526
|
-
exports.readConfiguredSecondaries = readConfiguredSecondaries;
|
|
527
|
-
exports.setInferVersion = setInferVersion;
|
|
528
|
-
exports.setLogLevel = setLogLevel;
|
|
529
|
-
exports.share = share;
|
|
530
|
-
exports.shareAll = shareAll;
|
|
531
|
-
exports.withFederation = withFederation;
|
|
532
|
-
//# sourceMappingURL=build.cjs.js.map
|