@module-federation/esbuild 0.0.0-next-20240930063850 → 0.0.0-next-20240930091801
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.cjs.js +60 -47
- package/dist/build.esm.js +10 -6
- package/dist/package.json +3 -3
- package/dist/plugin.cjs.js +40 -14
- package/dist/plugin.esm.js +1 -1
- package/package.json +3 -3
- package/dist/build.esm.d.ts +0 -1
- package/dist/index.esm.d.ts +0 -2
- package/dist/plugin.esm.d.ts +0 -1
package/dist/build.cjs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var getExternals = require('./get-externals.cjs.js');
|
|
4
6
|
var path = require('path');
|
|
5
7
|
var fs = require('fs');
|
|
@@ -7,7 +9,10 @@ var process = require('process');
|
|
|
7
9
|
var npmlog = require('npmlog');
|
|
8
10
|
require('json5');
|
|
9
11
|
|
|
10
|
-
function
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
11
16
|
var n = Object.create(null);
|
|
12
17
|
if (e) {
|
|
13
18
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,19 +25,23 @@ function _interopNamespaceDefault(e) {
|
|
|
20
25
|
}
|
|
21
26
|
});
|
|
22
27
|
}
|
|
23
|
-
n
|
|
28
|
+
n["default"] = e;
|
|
24
29
|
return Object.freeze(n);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
var path__namespace = /*#__PURE__*/
|
|
28
|
-
var
|
|
32
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
33
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
34
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
35
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
36
|
+
var process__default = /*#__PURE__*/_interopDefaultLegacy(process);
|
|
37
|
+
var npmlog__default = /*#__PURE__*/_interopDefaultLegacy(npmlog);
|
|
29
38
|
|
|
30
39
|
async function loadFederationConfig(fedOptions) {
|
|
31
40
|
const fullConfigPath = path__namespace.join(fedOptions.workspaceRoot, fedOptions.federationConfig);
|
|
32
41
|
if (!fs__namespace.existsSync(fullConfigPath)) {
|
|
33
42
|
throw new Error('Expected ' + fullConfigPath);
|
|
34
43
|
}
|
|
35
|
-
const config = await
|
|
44
|
+
const config = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(`${fullConfigPath}`);
|
|
36
45
|
return config;
|
|
37
46
|
}
|
|
38
47
|
|
|
@@ -86,52 +95,56 @@ function getConfigContext() {
|
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
/* eslint-disable @typescript-eslint/no-explicit-any */ //@ts-ignore
|
|
89
|
-
const levels =
|
|
90
|
-
|
|
98
|
+
const levels = npmlog__default["default"].levels;
|
|
99
|
+
npmlog__default["default"].addLevel('error', levels.error, {
|
|
91
100
|
fg: 'brightWhite',
|
|
92
101
|
bg: 'red'
|
|
93
102
|
}, ' ERR! ');
|
|
94
|
-
|
|
103
|
+
npmlog__default["default"].addLevel('warn', levels.info, {
|
|
95
104
|
fg: 'brightWhite',
|
|
96
105
|
bg: 'yellow'
|
|
97
106
|
}, ' WARN ');
|
|
98
|
-
|
|
107
|
+
npmlog__default["default"].addLevel('info', levels.warn, {
|
|
99
108
|
fg: 'brightWhite',
|
|
100
109
|
bg: 'green'
|
|
101
110
|
}, ' INFO ');
|
|
102
|
-
|
|
111
|
+
npmlog__default["default"].addLevel('notice', levels.notice, {
|
|
103
112
|
fg: 'black',
|
|
104
113
|
bg: 'brightYellow'
|
|
105
114
|
}, ' NOTE ');
|
|
106
|
-
|
|
115
|
+
npmlog__default["default"].addLevel('verbose', levels.verbose, {
|
|
107
116
|
fg: 'brightWhite',
|
|
108
117
|
bg: 'brightBlue'
|
|
109
118
|
}, ' VRB! ');
|
|
110
|
-
|
|
119
|
+
npmlog__default["default"].addLevel('silly', levels.silly, {
|
|
111
120
|
fg: 'black',
|
|
112
121
|
bg: 'white'
|
|
113
122
|
}, ' DBG! ');
|
|
114
123
|
const logger = {
|
|
115
|
-
error: (msg)=>
|
|
116
|
-
warn: (msg)=>
|
|
117
|
-
notice: (msg)=>
|
|
118
|
-
info: (msg)=>
|
|
119
|
-
verbose: (msg)=>
|
|
120
|
-
debug: (msg)=>
|
|
124
|
+
error: (msg)=>npmlog__default["default"].error('', msg),
|
|
125
|
+
warn: (msg)=>npmlog__default["default"].warn('', msg),
|
|
126
|
+
notice: (msg)=>npmlog__default["default"].notice('', msg),
|
|
127
|
+
info: (msg)=>npmlog__default["default"].info('', msg),
|
|
128
|
+
verbose: (msg)=>npmlog__default["default"].verbose('', msg),
|
|
129
|
+
debug: (msg)=>npmlog__default["default"].silly('', msg)
|
|
121
130
|
};
|
|
122
131
|
const setLogLevel = (level)=>{
|
|
123
|
-
|
|
132
|
+
npmlog__default["default"].level = level === 'debug' ? 'silly' : level;
|
|
124
133
|
};
|
|
125
134
|
setLogLevel('info');
|
|
126
135
|
|
|
127
136
|
function normalize(path, trailingSlash) {
|
|
128
137
|
let cand = path.replace(/\\/g, '/');
|
|
138
|
+
if (typeof trailingSlash === 'undefined') {
|
|
139
|
+
return cand;
|
|
140
|
+
}
|
|
129
141
|
while(cand.endsWith('/')){
|
|
130
142
|
cand = cand.substring(0, cand.length - 1);
|
|
131
143
|
}
|
|
132
|
-
{
|
|
144
|
+
if (trailingSlash) {
|
|
133
145
|
return cand + '/';
|
|
134
146
|
}
|
|
147
|
+
return cand;
|
|
135
148
|
}
|
|
136
149
|
|
|
137
150
|
function _extends$2() {
|
|
@@ -154,15 +167,15 @@ function findPackageJsonFiles(project, workspace) {
|
|
|
154
167
|
}
|
|
155
168
|
function expandFolders(child, parent) {
|
|
156
169
|
const result = [];
|
|
157
|
-
parent = normalize(parent);
|
|
158
|
-
child = normalize(child);
|
|
170
|
+
parent = normalize(parent, true);
|
|
171
|
+
child = normalize(child, true);
|
|
159
172
|
if (!child.startsWith(parent)) {
|
|
160
173
|
throw new Error(`Workspace folder ${parent} needs to be a parent of the project folder ${child}`);
|
|
161
174
|
}
|
|
162
175
|
let current = child;
|
|
163
176
|
while(current !== parent){
|
|
164
177
|
result.push(current);
|
|
165
|
-
const cand = normalize(path__namespace.dirname(current));
|
|
178
|
+
const cand = normalize(path__namespace.dirname(current), true);
|
|
166
179
|
if (cand === current) {
|
|
167
180
|
break;
|
|
168
181
|
}
|
|
@@ -185,7 +198,7 @@ function getPackageJsonFiles(project, workspace) {
|
|
|
185
198
|
}
|
|
186
199
|
maps = findPackageJsonFiles(project, workspace).map((f)=>{
|
|
187
200
|
const content = JSON.parse(fs__namespace.readFileSync(f, 'utf-8'));
|
|
188
|
-
const directory = normalize(path__namespace.dirname(f));
|
|
201
|
+
const directory = normalize(path__namespace.dirname(f), true);
|
|
189
202
|
const result = {
|
|
190
203
|
content,
|
|
191
204
|
directory
|
|
@@ -204,7 +217,7 @@ function findDepPackageJson(packageName, projectRoot) {
|
|
|
204
217
|
if (fs__namespace.existsSync(mainPkgJsonPath)) {
|
|
205
218
|
break;
|
|
206
219
|
}
|
|
207
|
-
directory = normalize(path__namespace.dirname(directory));
|
|
220
|
+
directory = normalize(path__namespace.dirname(directory), true);
|
|
208
221
|
mainPkgPath = path__namespace.join(directory, 'node_modules', mainPkgName);
|
|
209
222
|
mainPkgJsonPath = path__namespace.join(mainPkgPath, 'package.json');
|
|
210
223
|
}
|
|
@@ -243,23 +256,23 @@ const DEFAULT_SECONARIES_SKIP_LIST = [
|
|
|
243
256
|
'@angular/common/upgrade'
|
|
244
257
|
];
|
|
245
258
|
function findRootTsConfigJson() {
|
|
246
|
-
const packageJson = findPackageJson(
|
|
247
|
-
const projectRoot =
|
|
248
|
-
const tsConfigBaseJson =
|
|
249
|
-
const tsConfigJson =
|
|
250
|
-
if (
|
|
259
|
+
const packageJson = findPackageJson(process__default["default"].cwd());
|
|
260
|
+
const projectRoot = path__default["default"].dirname(packageJson);
|
|
261
|
+
const tsConfigBaseJson = path__default["default"].join(projectRoot, 'tsconfig.base.json');
|
|
262
|
+
const tsConfigJson = path__default["default"].join(projectRoot, 'tsconfig.json');
|
|
263
|
+
if (fs__default["default"].existsSync(tsConfigBaseJson)) {
|
|
251
264
|
return tsConfigBaseJson;
|
|
252
|
-
} else if (
|
|
265
|
+
} else if (fs__default["default"].existsSync(tsConfigJson)) {
|
|
253
266
|
return tsConfigJson;
|
|
254
267
|
}
|
|
255
268
|
throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
|
|
256
269
|
}
|
|
257
270
|
function findPackageJson(folder) {
|
|
258
|
-
while(!
|
|
259
|
-
folder =
|
|
271
|
+
while(!fs__default["default"].existsSync(path__default["default"].join(folder, 'package.json')) && path__default["default"].dirname(folder) !== folder){
|
|
272
|
+
folder = path__default["default"].dirname(folder);
|
|
260
273
|
}
|
|
261
|
-
const filePath =
|
|
262
|
-
if (
|
|
274
|
+
const filePath = path__default["default"].join(folder, 'package.json');
|
|
275
|
+
if (fs__default["default"].existsSync(filePath)) {
|
|
263
276
|
return filePath;
|
|
264
277
|
}
|
|
265
278
|
throw new Error(`No package.json found. Searched the following folder and all parents: ${folder}`);
|
|
@@ -287,9 +300,9 @@ function lookupVersionInMap(key, versions) {
|
|
|
287
300
|
return versions[key] || null;
|
|
288
301
|
}
|
|
289
302
|
function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
290
|
-
const files =
|
|
291
|
-
const dirs = files.map((f)=>
|
|
292
|
-
const secondaries = dirs.filter((d)=>
|
|
303
|
+
const files = fs__default["default"].readdirSync(libPath);
|
|
304
|
+
const dirs = files.map((f)=>path__default["default"].join(libPath, f)).filter((f)=>fs__default["default"].lstatSync(f).isDirectory() && f !== 'node_modules');
|
|
305
|
+
const secondaries = dirs.filter((d)=>fs__default["default"].existsSync(path__default["default"].join(d, 'package.json')));
|
|
293
306
|
for (const s of secondaries){
|
|
294
307
|
const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
|
|
295
308
|
if (excludes.includes(secondaryLibName)) {
|
|
@@ -320,7 +333,7 @@ function getSecondaries(includeSecondaries, libPath, key, shareObject) {
|
|
|
320
333
|
];
|
|
321
334
|
}
|
|
322
335
|
}
|
|
323
|
-
if (!
|
|
336
|
+
if (!fs__default["default"].existsSync(libPath)) {
|
|
324
337
|
return {};
|
|
325
338
|
}
|
|
326
339
|
const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
|
|
@@ -331,11 +344,11 @@ function getSecondaries(includeSecondaries, libPath, key, shareObject) {
|
|
|
331
344
|
return findSecondaries(libPath, exclude, shareObject);
|
|
332
345
|
}
|
|
333
346
|
function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
334
|
-
const libPackageJson =
|
|
335
|
-
if (!
|
|
347
|
+
const libPackageJson = path__default["default"].join(libPath, 'package.json');
|
|
348
|
+
if (!fs__default["default"].existsSync(libPackageJson)) {
|
|
336
349
|
return null;
|
|
337
350
|
}
|
|
338
|
-
const packageJson = JSON.parse(
|
|
351
|
+
const packageJson = JSON.parse(fs__default["default"].readFileSync(libPackageJson, 'utf-8'));
|
|
339
352
|
const exports = packageJson['exports'];
|
|
340
353
|
if (!exports) {
|
|
341
354
|
return null;
|
|
@@ -343,7 +356,7 @@ function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
|
343
356
|
const keys = Object.keys(exports).filter((key)=>key !== '.' && key !== './package.json' && !key.endsWith('*') && (exports[key]['default'] || typeof exports[key] === 'string'));
|
|
344
357
|
const result = {};
|
|
345
358
|
for (const key of keys){
|
|
346
|
-
const secondaryName =
|
|
359
|
+
const secondaryName = path__default["default"].join(parent, key).replace(/\\/g, '/');
|
|
347
360
|
if (exclude.includes(secondaryName)) {
|
|
348
361
|
continue;
|
|
349
362
|
}
|
|
@@ -402,13 +415,13 @@ function shareAll(config, skip = DEFAULT_SKIP_LIST, projectPath = '') {
|
|
|
402
415
|
}
|
|
403
416
|
function inferProjectPath(projectPath) {
|
|
404
417
|
if (!projectPath) {
|
|
405
|
-
projectPath =
|
|
418
|
+
projectPath = path__default["default"].dirname(getConfigContext().packageJson || '');
|
|
406
419
|
}
|
|
407
420
|
if (!projectPath && getConfigContext().workspaceRoot) {
|
|
408
421
|
projectPath = getConfigContext().workspaceRoot || '';
|
|
409
422
|
}
|
|
410
423
|
if (!projectPath) {
|
|
411
|
-
projectPath =
|
|
424
|
+
projectPath = process__default["default"].cwd();
|
|
412
425
|
}
|
|
413
426
|
return projectPath;
|
|
414
427
|
}
|
|
@@ -437,12 +450,12 @@ function share(shareObjects, projectPath = '') {
|
|
|
437
450
|
}
|
|
438
451
|
result[key] = shareObject;
|
|
439
452
|
if (includeSecondaries) {
|
|
440
|
-
const libPackageJson = findDepPackageJson(key,
|
|
453
|
+
const libPackageJson = findDepPackageJson(key, path__default["default"].dirname(packagePath));
|
|
441
454
|
if (!libPackageJson) {
|
|
442
455
|
logger.error(`Could not find folder containing dep ${key}`);
|
|
443
456
|
continue;
|
|
444
457
|
}
|
|
445
|
-
const libPath =
|
|
458
|
+
const libPath = path__default["default"].dirname(libPackageJson);
|
|
446
459
|
const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
|
|
447
460
|
if (secondaries) {
|
|
448
461
|
addSecondaries(secondaries, result);
|
package/dist/build.esm.js
CHANGED
|
@@ -106,12 +106,16 @@ setLogLevel('info');
|
|
|
106
106
|
|
|
107
107
|
function normalize(path, trailingSlash) {
|
|
108
108
|
let cand = path.replace(/\\/g, '/');
|
|
109
|
+
if (typeof trailingSlash === 'undefined') {
|
|
110
|
+
return cand;
|
|
111
|
+
}
|
|
109
112
|
while(cand.endsWith('/')){
|
|
110
113
|
cand = cand.substring(0, cand.length - 1);
|
|
111
114
|
}
|
|
112
|
-
{
|
|
115
|
+
if (trailingSlash) {
|
|
113
116
|
return cand + '/';
|
|
114
117
|
}
|
|
118
|
+
return cand;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
function _extends$2() {
|
|
@@ -134,15 +138,15 @@ function findPackageJsonFiles(project, workspace) {
|
|
|
134
138
|
}
|
|
135
139
|
function expandFolders(child, parent) {
|
|
136
140
|
const result = [];
|
|
137
|
-
parent = normalize(parent);
|
|
138
|
-
child = normalize(child);
|
|
141
|
+
parent = normalize(parent, true);
|
|
142
|
+
child = normalize(child, true);
|
|
139
143
|
if (!child.startsWith(parent)) {
|
|
140
144
|
throw new Error(`Workspace folder ${parent} needs to be a parent of the project folder ${child}`);
|
|
141
145
|
}
|
|
142
146
|
let current = child;
|
|
143
147
|
while(current !== parent){
|
|
144
148
|
result.push(current);
|
|
145
|
-
const cand = normalize(path.dirname(current));
|
|
149
|
+
const cand = normalize(path.dirname(current), true);
|
|
146
150
|
if (cand === current) {
|
|
147
151
|
break;
|
|
148
152
|
}
|
|
@@ -165,7 +169,7 @@ function getPackageJsonFiles(project, workspace) {
|
|
|
165
169
|
}
|
|
166
170
|
maps = findPackageJsonFiles(project, workspace).map((f)=>{
|
|
167
171
|
const content = JSON.parse(fs.readFileSync(f, 'utf-8'));
|
|
168
|
-
const directory = normalize(path.dirname(f));
|
|
172
|
+
const directory = normalize(path.dirname(f), true);
|
|
169
173
|
const result = {
|
|
170
174
|
content,
|
|
171
175
|
directory
|
|
@@ -184,7 +188,7 @@ function findDepPackageJson(packageName, projectRoot) {
|
|
|
184
188
|
if (fs.existsSync(mainPkgJsonPath)) {
|
|
185
189
|
break;
|
|
186
190
|
}
|
|
187
|
-
directory = normalize(path.dirname(directory));
|
|
191
|
+
directory = normalize(path.dirname(directory), true);
|
|
188
192
|
mainPkgPath = path.join(directory, 'node_modules', mainPkgName);
|
|
189
193
|
mainPkgJsonPath = path.join(mainPkgPath, 'package.json');
|
|
190
194
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/esbuild",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"author": "Zack Jackson (@ScriptedAlchemy)",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"module": "./index.esm.js",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
59
59
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
60
60
|
"@rollup/plugin-replace": "^5.0.7",
|
|
61
|
-
"rollup": "^2.79.
|
|
61
|
+
"rollup": "^2.79.0",
|
|
62
62
|
"@chialab/esbuild-plugin-commonjs": "^0.18.0",
|
|
63
63
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
|
64
64
|
"rollup-plugin-node-externals": "^4.1.1",
|
|
65
65
|
"esbuild": "^0.18.12",
|
|
66
66
|
"npmlog": "^6.0.2"
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var fs = require('fs');
|
|
4
6
|
var esModuleLexer = require('es-module-lexer');
|
|
5
7
|
var cjsModuleLexer = require('cjs-module-lexer');
|
|
@@ -8,7 +10,31 @@ var enhancedResolve = require('enhanced-resolve');
|
|
|
8
10
|
var path = require('path');
|
|
9
11
|
var getExternals = require('./get-externals.cjs.js');
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
Object.keys(e).forEach(function (k) {
|
|
20
|
+
if (k !== 'default') {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return e[k]; }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
n["default"] = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
34
|
+
var enhancedResolve__default = /*#__PURE__*/_interopDefaultLegacy(enhancedResolve);
|
|
35
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
36
|
+
|
|
37
|
+
const resolve = util.promisify(enhancedResolve__default["default"].create({
|
|
12
38
|
mainFields: [
|
|
13
39
|
'browser',
|
|
14
40
|
'module',
|
|
@@ -28,7 +54,7 @@ async function getExports(modulePath) {
|
|
|
28
54
|
while(paths.length > 0){
|
|
29
55
|
const currentPath = paths.pop();
|
|
30
56
|
if (currentPath) {
|
|
31
|
-
const content = await
|
|
57
|
+
const content = await fs__default["default"].promises.readFile(currentPath, 'utf8');
|
|
32
58
|
try {
|
|
33
59
|
const { exports: cjsExports } = cjsModuleLexer.parse(content);
|
|
34
60
|
exports.push(...cjsExports);
|
|
@@ -51,7 +77,7 @@ async function getExports(modulePath) {
|
|
|
51
77
|
}
|
|
52
78
|
}
|
|
53
79
|
|
|
54
|
-
var version = "0.0.
|
|
80
|
+
var version = "0.0.24";
|
|
55
81
|
|
|
56
82
|
function _extends$1() {
|
|
57
83
|
_extends$1 = Object.assign || function(target) {
|
|
@@ -143,7 +169,7 @@ const writeRemoteManifest = async (config, result)=>{
|
|
|
143
169
|
try {
|
|
144
170
|
const packageJsonPath = await resolve(process.cwd(), `${pkg}/package.json`);
|
|
145
171
|
if (packageJsonPath) {
|
|
146
|
-
version = JSON.parse(
|
|
172
|
+
version = JSON.parse(fs__default["default"].readFileSync(packageJsonPath, 'utf-8')).version;
|
|
147
173
|
}
|
|
148
174
|
} catch (e) {
|
|
149
175
|
console.warn(`Can't resolve ${pkg} version automatically, consider setting "version" manually`);
|
|
@@ -199,7 +225,7 @@ const writeRemoteManifest = async (config, result)=>{
|
|
|
199
225
|
},
|
|
200
226
|
remoteEntry: {
|
|
201
227
|
name: config.filename,
|
|
202
|
-
path: outputMap[containerName] ?
|
|
228
|
+
path: outputMap[containerName] ? path__default["default"].dirname(outputMap[containerName].chunk) : '',
|
|
203
229
|
type: 'esm'
|
|
204
230
|
},
|
|
205
231
|
types,
|
|
@@ -211,8 +237,8 @@ const writeRemoteManifest = async (config, result)=>{
|
|
|
211
237
|
remotes,
|
|
212
238
|
exposes
|
|
213
239
|
};
|
|
214
|
-
const manifestPath =
|
|
215
|
-
|
|
240
|
+
const manifestPath = path__default["default"].join(path__default["default"].dirname(outputMap[containerName].chunk), 'mf-manifest.json');
|
|
241
|
+
fs__default["default"].writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
216
242
|
};
|
|
217
243
|
|
|
218
244
|
const createContainerCode = `
|
|
@@ -692,7 +718,7 @@ const initializeHostPlugin = (config)=>({
|
|
|
692
718
|
filter: new RegExp(`\\${ext}$`),
|
|
693
719
|
namespace: 'file'
|
|
694
720
|
}, async (args)=>{
|
|
695
|
-
const contents = await
|
|
721
|
+
const contents = await fs__default["default"].promises.readFile(args.path, 'utf8');
|
|
696
722
|
return {
|
|
697
723
|
contents: buildFederationHost(config) + contents,
|
|
698
724
|
loader
|
|
@@ -710,7 +736,7 @@ const initializeHostPlugin = (config)=>({
|
|
|
710
736
|
if (!build.initialOptions.entryPoints.some((e)=>args.path.includes(e))) {
|
|
711
737
|
return;
|
|
712
738
|
}
|
|
713
|
-
const contents = await
|
|
739
|
+
const contents = await fs__default["default"].promises.readFile(args.path, 'utf8');
|
|
714
740
|
return {
|
|
715
741
|
contents: 'import "federation-host"; \n ' + contents
|
|
716
742
|
};
|
|
@@ -756,7 +782,7 @@ const linkRemotesPlugin = (config)=>({
|
|
|
756
782
|
return {
|
|
757
783
|
contents: createVirtualRemoteModule$1(config.name, args.path),
|
|
758
784
|
loader: 'js',
|
|
759
|
-
resolveDir:
|
|
785
|
+
resolveDir: path__default["default"].dirname(args.path)
|
|
760
786
|
};
|
|
761
787
|
});
|
|
762
788
|
}
|
|
@@ -928,7 +954,7 @@ const makeLegalIdentifier = function makeLegalIdentifier(str) {
|
|
|
928
954
|
};
|
|
929
955
|
|
|
930
956
|
function commonjs({ filter = /\.c?js$/, transform = true, transformConfig, requireReturnsDefault = true, ignore } = {}) {
|
|
931
|
-
const init_cjs_module_lexer = transform ?
|
|
957
|
+
const init_cjs_module_lexer = transform ? Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('cjs-module-lexer')); }) : undefined;
|
|
932
958
|
const use_default_export = typeof requireReturnsDefault === 'function' ? requireReturnsDefault : (_path)=>requireReturnsDefault;
|
|
933
959
|
const is_ignored = typeof ignore === 'function' ? ignore : Array.isArray(ignore) ? (path)=>ignore.includes(path) : ()=>false;
|
|
934
960
|
return {
|
|
@@ -1211,7 +1237,7 @@ const linkSharedPlugin = (config)=>({
|
|
|
1211
1237
|
return {
|
|
1212
1238
|
contents: createVirtualShareModule(config.name, args.path, exp),
|
|
1213
1239
|
loader: 'js',
|
|
1214
|
-
resolveDir:
|
|
1240
|
+
resolveDir: path__default["default"].dirname(args.path)
|
|
1215
1241
|
};
|
|
1216
1242
|
});
|
|
1217
1243
|
}
|
|
@@ -1296,9 +1322,9 @@ const moduleFederationPlugin = (config)=>({
|
|
|
1296
1322
|
if (!value.entryPoint) continue;
|
|
1297
1323
|
if (!value.entryPoint.startsWith('container:')) continue;
|
|
1298
1324
|
if (!value.entryPoint.endsWith(remoteFile)) continue;
|
|
1299
|
-
const container =
|
|
1325
|
+
const container = fs__default["default"].readFileSync(outputPath, 'utf-8');
|
|
1300
1326
|
const withExports = container.replace('"__MODULE_MAP__"', `${JSON.stringify(exposedEntries)}`).replace("'__MODULE_MAP__'", `${JSON.stringify(exposedEntries)}`);
|
|
1301
|
-
|
|
1327
|
+
fs__default["default"].writeFileSync(outputPath, withExports, 'utf-8');
|
|
1302
1328
|
}
|
|
1303
1329
|
}
|
|
1304
1330
|
await writeRemoteManifest(config, result);
|
package/dist/plugin.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/esbuild",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240930091801",
|
|
4
4
|
"author": "Zack Jackson (@ScriptedAlchemy)",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
59
59
|
"@rollup/plugin-replace": "^5.0.7",
|
|
60
|
-
"rollup": "^2.79.
|
|
60
|
+
"rollup": "^2.79.0",
|
|
61
61
|
"@chialab/esbuild-plugin-commonjs": "^0.18.0",
|
|
62
62
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
|
63
63
|
"rollup-plugin-node-externals": "^4.1.1",
|
|
64
64
|
"esbuild": "^0.18.12",
|
|
65
65
|
"npmlog": "^6.0.2",
|
|
66
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
66
|
+
"@module-federation/sdk": "0.0.0-next-20240930091801"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/dist/build.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/build";
|
package/dist/index.esm.d.ts
DELETED
package/dist/plugin.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/adapters/lib/plugin";
|