@module-federation/esbuild 0.0.0-next-20240524034417 → 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.
@@ -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
- const { entryPoint } = chunkValue;
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;
@@ -592,9 +595,6 @@ const createContainerPlugin = (config)=>({
592
595
  }
593
596
  };
594
597
  }
595
- await build.resolve(args.path, {
596
- resolveDir: args.resolveDir
597
- });
598
598
  return undefined;
599
599
  });
600
600
  build.onLoad({
@@ -817,7 +817,6 @@ const createVirtualShareModule = (name, ref, exports)=>`
817
817
 
818
818
  ${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
819
819
  `;
820
- // Plugin to initialize the federation host
821
820
  // Plugin to transform CommonJS modules to ESM
822
821
  const cjsToEsmPlugin = {
823
822
  name: 'cjs-to-esm',
@@ -826,22 +825,25 @@ const cjsToEsmPlugin = {
826
825
  filter: /.*/,
827
826
  namespace: 'esm-shares'
828
827
  }, async (args)=>{
829
- const { transform } = await eval("import('@chialab/cjs-to-esm')");
828
+ const { transform } = await new Function('return import("@chialab/cjs-to-esm")')();
830
829
  const resolver = await resolve(args.pluginData.resolveDir, args.path);
831
830
  if (typeof resolver !== 'string') {
832
831
  throw new Error(`Unable to resolve path: ${args.path}`);
833
832
  }
834
833
  const fileContent = fs__default["default"].readFileSync(resolver, 'utf-8');
835
834
  try {
836
- const { code } = await transform(fileContent);
837
- return {
838
- contents: code,
839
- loader: 'js',
840
- resolveDir: path__default["default"].dirname(resolver),
841
- pluginData: _extends$1({}, args.pluginData, {
842
- path: resolver
843
- })
844
- };
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
+ }
845
847
  } catch (e) {
846
848
  return {
847
849
  contents: fileContent,
@@ -852,6 +854,7 @@ const cjsToEsmPlugin = {
852
854
  })
853
855
  };
854
856
  }
857
+ return undefined;
855
858
  });
856
859
  }
857
860
  };
@@ -944,7 +947,6 @@ const moduleFederationPlugin = (config)=>({
944
947
  }
945
948
  if (exposes) {
946
949
  if (Array.isArray(entryPoints)) {
947
- //@ts-ignore
948
950
  entryPoints.push(filename);
949
951
  } else if (entryPoints && typeof entryPoints === 'object') {
950
952
  entryPoints[filename] = filename;
@@ -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
- const { entryPoint } = chunkValue;
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;
@@ -580,9 +583,6 @@ const createContainerPlugin = (config)=>({
580
583
  }
581
584
  };
582
585
  }
583
- await build.resolve(args.path, {
584
- resolveDir: args.resolveDir
585
- });
586
586
  return undefined;
587
587
  });
588
588
  build.onLoad({
@@ -805,7 +805,6 @@ const createVirtualShareModule = (name, ref, exports)=>`
805
805
 
806
806
  ${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
807
807
  `;
808
- // Plugin to initialize the federation host
809
808
  // Plugin to transform CommonJS modules to ESM
810
809
  const cjsToEsmPlugin = {
811
810
  name: 'cjs-to-esm',
@@ -814,22 +813,25 @@ const cjsToEsmPlugin = {
814
813
  filter: /.*/,
815
814
  namespace: 'esm-shares'
816
815
  }, async (args)=>{
817
- const { transform } = await eval("import('@chialab/cjs-to-esm')");
816
+ const { transform } = await new Function('return import("@chialab/cjs-to-esm")')();
818
817
  const resolver = await resolve(args.pluginData.resolveDir, args.path);
819
818
  if (typeof resolver !== 'string') {
820
819
  throw new Error(`Unable to resolve path: ${args.path}`);
821
820
  }
822
821
  const fileContent = fs__default.readFileSync(resolver, 'utf-8');
823
822
  try {
824
- const { code } = await transform(fileContent);
825
- return {
826
- contents: code,
827
- loader: 'js',
828
- resolveDir: path__default.dirname(resolver),
829
- pluginData: _extends$1({}, args.pluginData, {
830
- path: resolver
831
- })
832
- };
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
+ }
833
835
  } catch (e) {
834
836
  return {
835
837
  contents: fileContent,
@@ -840,6 +842,7 @@ const cjsToEsmPlugin = {
840
842
  })
841
843
  };
842
844
  }
845
+ return undefined;
843
846
  });
844
847
  }
845
848
  };
@@ -932,7 +935,6 @@ const moduleFederationPlugin = (config)=>({
932
935
  }
933
936
  if (exposes) {
934
937
  if (Array.isArray(entryPoints)) {
935
- //@ts-ignore
936
938
  entryPoints.push(filename);
937
939
  } else if (entryPoints && typeof entryPoints === 'object') {
938
940
  entryPoints[filename] = filename;
@@ -1,17 +1,2 @@
1
- interface BuildResult {
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-20240524034417",
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-20240524034417"
68
+ "@module-federation/sdk": "0.0.0-next-20240524213250"
69
69
  }
70
70
  }