@module-federation/esbuild 0.0.0-next-20240524042957 → 0.0.0-next-20240524213250
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/esbuild.cjs.js +20 -15
- package/dist/esbuild.esm.js +20 -15
- package/dist/src/adapters/lib/manifest.d.ts +1 -16
- package/package.json +2 -2
package/dist/esbuild.cjs.js
CHANGED
|
@@ -102,6 +102,7 @@ function _extends$2() {
|
|
|
102
102
|
return _extends$2.apply(this, arguments);
|
|
103
103
|
}
|
|
104
104
|
const writeRemoteManifest = async (config, result)=>{
|
|
105
|
+
var _result_metafile, _result_metafile1;
|
|
105
106
|
if (result.errors && result.errors.length > 0) {
|
|
106
107
|
console.warn('Build errors detected, skipping writeRemoteManifest.');
|
|
107
108
|
return;
|
|
@@ -120,19 +121,21 @@ const writeRemoteManifest = async (config, result)=>{
|
|
|
120
121
|
const envType = process.env['NODE_ENV'] === 'development' ? 'local' : (_process_env_NODE_ENV = process.env['NODE_ENV']) != null ? _process_env_NODE_ENV : '';
|
|
121
122
|
const publicPath = config.publicPath || 'auto';
|
|
122
123
|
let containerName = '';
|
|
123
|
-
const outputMap = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
|
|
124
|
-
|
|
124
|
+
const outputMap = Object.entries(((_result_metafile = result.metafile) == null ? void 0 : _result_metafile.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
const { entryPoint, kind = 'static-import' } = chunkValue;
|
|
125
127
|
const key = entryPoint || chunkKey;
|
|
126
128
|
if (key.startsWith('container:') && key.endsWith(mfConfig.filename)) {
|
|
127
129
|
containerName = key;
|
|
128
130
|
}
|
|
129
131
|
acc[key] = _extends$2({}, chunkValue, {
|
|
132
|
+
kind,
|
|
130
133
|
chunk: chunkKey
|
|
131
134
|
});
|
|
132
135
|
return acc;
|
|
133
136
|
}, {});
|
|
134
137
|
if (!outputMap[containerName]) return;
|
|
135
|
-
const outputMapWithoutExt = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
|
|
138
|
+
const outputMapWithoutExt = Object.entries(((_result_metafile1 = result.metafile) == null ? void 0 : _result_metafile1.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
|
|
136
139
|
const { entryPoint } = chunkValue;
|
|
137
140
|
const key = entryPoint || chunkKey;
|
|
138
141
|
const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
|
|
@@ -814,7 +817,6 @@ const createVirtualShareModule = (name, ref, exports)=>`
|
|
|
814
817
|
|
|
815
818
|
${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
|
|
816
819
|
`;
|
|
817
|
-
// Plugin to initialize the federation host
|
|
818
820
|
// Plugin to transform CommonJS modules to ESM
|
|
819
821
|
const cjsToEsmPlugin = {
|
|
820
822
|
name: 'cjs-to-esm',
|
|
@@ -823,22 +825,25 @@ const cjsToEsmPlugin = {
|
|
|
823
825
|
filter: /.*/,
|
|
824
826
|
namespace: 'esm-shares'
|
|
825
827
|
}, async (args)=>{
|
|
826
|
-
const { transform } = await
|
|
828
|
+
const { transform } = await new Function('return import("@chialab/cjs-to-esm")')();
|
|
827
829
|
const resolver = await resolve(args.pluginData.resolveDir, args.path);
|
|
828
830
|
if (typeof resolver !== 'string') {
|
|
829
831
|
throw new Error(`Unable to resolve path: ${args.path}`);
|
|
830
832
|
}
|
|
831
833
|
const fileContent = fs__default["default"].readFileSync(resolver, 'utf-8');
|
|
832
834
|
try {
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
835
|
+
const result = await transform(fileContent);
|
|
836
|
+
if (result) {
|
|
837
|
+
const { code } = result;
|
|
838
|
+
return {
|
|
839
|
+
contents: code,
|
|
840
|
+
loader: 'js',
|
|
841
|
+
resolveDir: path__default["default"].dirname(resolver),
|
|
842
|
+
pluginData: _extends$1({}, args.pluginData, {
|
|
843
|
+
path: resolver
|
|
844
|
+
})
|
|
845
|
+
};
|
|
846
|
+
}
|
|
842
847
|
} catch (e) {
|
|
843
848
|
return {
|
|
844
849
|
contents: fileContent,
|
|
@@ -849,6 +854,7 @@ const cjsToEsmPlugin = {
|
|
|
849
854
|
})
|
|
850
855
|
};
|
|
851
856
|
}
|
|
857
|
+
return undefined;
|
|
852
858
|
});
|
|
853
859
|
}
|
|
854
860
|
};
|
|
@@ -941,7 +947,6 @@ const moduleFederationPlugin = (config)=>({
|
|
|
941
947
|
}
|
|
942
948
|
if (exposes) {
|
|
943
949
|
if (Array.isArray(entryPoints)) {
|
|
944
|
-
//@ts-ignore
|
|
945
950
|
entryPoints.push(filename);
|
|
946
951
|
} else if (entryPoints && typeof entryPoints === 'object') {
|
|
947
952
|
entryPoints[filename] = filename;
|
package/dist/esbuild.esm.js
CHANGED
|
@@ -90,6 +90,7 @@ function _extends$2() {
|
|
|
90
90
|
return _extends$2.apply(this, arguments);
|
|
91
91
|
}
|
|
92
92
|
const writeRemoteManifest = async (config, result)=>{
|
|
93
|
+
var _result_metafile, _result_metafile1;
|
|
93
94
|
if (result.errors && result.errors.length > 0) {
|
|
94
95
|
console.warn('Build errors detected, skipping writeRemoteManifest.');
|
|
95
96
|
return;
|
|
@@ -108,19 +109,21 @@ const writeRemoteManifest = async (config, result)=>{
|
|
|
108
109
|
const envType = process.env['NODE_ENV'] === 'development' ? 'local' : (_process_env_NODE_ENV = process.env['NODE_ENV']) != null ? _process_env_NODE_ENV : '';
|
|
109
110
|
const publicPath = config.publicPath || 'auto';
|
|
110
111
|
let containerName = '';
|
|
111
|
-
const outputMap = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
|
|
112
|
-
|
|
112
|
+
const outputMap = Object.entries(((_result_metafile = result.metafile) == null ? void 0 : _result_metafile.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
|
|
113
|
+
//@ts-ignore
|
|
114
|
+
const { entryPoint, kind = 'static-import' } = chunkValue;
|
|
113
115
|
const key = entryPoint || chunkKey;
|
|
114
116
|
if (key.startsWith('container:') && key.endsWith(mfConfig.filename)) {
|
|
115
117
|
containerName = key;
|
|
116
118
|
}
|
|
117
119
|
acc[key] = _extends$2({}, chunkValue, {
|
|
120
|
+
kind,
|
|
118
121
|
chunk: chunkKey
|
|
119
122
|
});
|
|
120
123
|
return acc;
|
|
121
124
|
}, {});
|
|
122
125
|
if (!outputMap[containerName]) return;
|
|
123
|
-
const outputMapWithoutExt = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
|
|
126
|
+
const outputMapWithoutExt = Object.entries(((_result_metafile1 = result.metafile) == null ? void 0 : _result_metafile1.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
|
|
124
127
|
const { entryPoint } = chunkValue;
|
|
125
128
|
const key = entryPoint || chunkKey;
|
|
126
129
|
const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
|
|
@@ -802,7 +805,6 @@ const createVirtualShareModule = (name, ref, exports)=>`
|
|
|
802
805
|
|
|
803
806
|
${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
|
|
804
807
|
`;
|
|
805
|
-
// Plugin to initialize the federation host
|
|
806
808
|
// Plugin to transform CommonJS modules to ESM
|
|
807
809
|
const cjsToEsmPlugin = {
|
|
808
810
|
name: 'cjs-to-esm',
|
|
@@ -811,22 +813,25 @@ const cjsToEsmPlugin = {
|
|
|
811
813
|
filter: /.*/,
|
|
812
814
|
namespace: 'esm-shares'
|
|
813
815
|
}, async (args)=>{
|
|
814
|
-
const { transform } = await
|
|
816
|
+
const { transform } = await new Function('return import("@chialab/cjs-to-esm")')();
|
|
815
817
|
const resolver = await resolve(args.pluginData.resolveDir, args.path);
|
|
816
818
|
if (typeof resolver !== 'string') {
|
|
817
819
|
throw new Error(`Unable to resolve path: ${args.path}`);
|
|
818
820
|
}
|
|
819
821
|
const fileContent = fs__default.readFileSync(resolver, 'utf-8');
|
|
820
822
|
try {
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
823
|
+
const result = await transform(fileContent);
|
|
824
|
+
if (result) {
|
|
825
|
+
const { code } = result;
|
|
826
|
+
return {
|
|
827
|
+
contents: code,
|
|
828
|
+
loader: 'js',
|
|
829
|
+
resolveDir: path__default.dirname(resolver),
|
|
830
|
+
pluginData: _extends$1({}, args.pluginData, {
|
|
831
|
+
path: resolver
|
|
832
|
+
})
|
|
833
|
+
};
|
|
834
|
+
}
|
|
830
835
|
} catch (e) {
|
|
831
836
|
return {
|
|
832
837
|
contents: fileContent,
|
|
@@ -837,6 +842,7 @@ const cjsToEsmPlugin = {
|
|
|
837
842
|
})
|
|
838
843
|
};
|
|
839
844
|
}
|
|
845
|
+
return undefined;
|
|
840
846
|
});
|
|
841
847
|
}
|
|
842
848
|
};
|
|
@@ -929,7 +935,6 @@ const moduleFederationPlugin = (config)=>({
|
|
|
929
935
|
}
|
|
930
936
|
if (exposes) {
|
|
931
937
|
if (Array.isArray(entryPoints)) {
|
|
932
|
-
//@ts-ignore
|
|
933
938
|
entryPoints.push(filename);
|
|
934
939
|
} else if (entryPoints && typeof entryPoints === 'object') {
|
|
935
940
|
entryPoints[filename] = filename;
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
errors?: any[];
|
|
3
|
-
metafile: {
|
|
4
|
-
outputs: Record<string, OutputFile>;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
interface OutputFile {
|
|
8
|
-
entryPoint?: string;
|
|
9
|
-
imports?: {
|
|
10
|
-
path: string;
|
|
11
|
-
}[];
|
|
12
|
-
exports?: string[];
|
|
13
|
-
kind: string;
|
|
14
|
-
chunk: string;
|
|
15
|
-
}
|
|
1
|
+
import { BuildResult } from 'esbuild';
|
|
16
2
|
export declare const writeRemoteManifest: (config: any, result: BuildResult) => Promise<void>;
|
|
17
|
-
export {};
|
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-20240524213250",
|
|
4
4
|
"author": "Zack Jackson (@ScriptedAlchemy)",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"esbuild": "^0.18.12",
|
|
66
66
|
"npmlog": "^6.0.2",
|
|
67
67
|
"acorn": "^8.8.1",
|
|
68
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
68
|
+
"@module-federation/sdk": "0.0.0-next-20240524213250"
|
|
69
69
|
}
|
|
70
70
|
}
|