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