@module-federation/esbuild 0.0.95 → 0.0.97

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.
Files changed (61) hide show
  1. package/dist/adapters/lib/collect-exports.js +151 -0
  2. package/dist/adapters/lib/collect-exports.mjs +87 -0
  3. package/dist/adapters/lib/commonjs.js +260 -0
  4. package/dist/adapters/lib/commonjs.mjs +209 -0
  5. package/dist/adapters/lib/containerPlugin.js +232 -0
  6. package/dist/adapters/lib/containerPlugin.mjs +182 -0
  7. package/dist/adapters/lib/containerReference.js +219 -0
  8. package/dist/adapters/lib/containerReference.mjs +154 -0
  9. package/dist/adapters/lib/lexer.js +184 -0
  10. package/dist/adapters/lib/lexer.mjs +138 -0
  11. package/dist/adapters/lib/linkRemotesPlugin.js +115 -0
  12. package/dist/adapters/lib/linkRemotesPlugin.mjs +50 -0
  13. package/dist/adapters/lib/manifest.js +229 -0
  14. package/dist/adapters/lib/manifest.mjs +168 -0
  15. package/dist/adapters/lib/plugin.js +339 -0
  16. package/dist/adapters/lib/plugin.mjs +282 -0
  17. package/dist/adapters/lib/react-replacements.js +81 -0
  18. package/dist/adapters/lib/react-replacements.mjs +35 -0
  19. package/dist/adapters/lib/transform.js +169 -0
  20. package/dist/adapters/lib/transform.mjs +120 -0
  21. package/dist/adapters/lib/utils.js +83 -0
  22. package/dist/adapters/lib/utils.mjs +33 -0
  23. package/dist/build.js +131 -473
  24. package/dist/build.mjs +13 -380
  25. package/dist/index.js +41 -26
  26. package/dist/index.mjs +4 -1
  27. package/dist/lib/config/configuration-context.js +70 -0
  28. package/dist/lib/config/configuration-context.mjs +20 -0
  29. package/dist/lib/config/federation-config.js +31 -0
  30. package/dist/lib/config/federation-config.mjs +4 -0
  31. package/dist/lib/config/share-utils.js +339 -0
  32. package/dist/lib/config/share-utils.mjs +254 -0
  33. package/dist/lib/config/with-native-federation.js +118 -0
  34. package/dist/lib/config/with-native-federation.mjs +71 -0
  35. package/dist/lib/core/build-adapter.js +70 -0
  36. package/dist/lib/core/build-adapter.mjs +18 -0
  37. package/dist/lib/core/createContainerTemplate.js +231 -0
  38. package/dist/lib/core/createContainerTemplate.mjs +185 -0
  39. package/dist/lib/core/default-skip-list.js +99 -0
  40. package/dist/lib/core/default-skip-list.mjs +47 -0
  41. package/dist/lib/core/federation-options.js +31 -0
  42. package/dist/lib/core/federation-options.mjs +4 -0
  43. package/dist/lib/core/get-externals.js +65 -0
  44. package/dist/lib/core/get-externals.mjs +19 -0
  45. package/dist/lib/core/load-federation-config.js +69 -0
  46. package/dist/lib/core/load-federation-config.mjs +20 -0
  47. package/dist/lib/core/write-federation-info.js +65 -0
  48. package/dist/lib/core/write-federation-info.mjs +16 -0
  49. package/dist/lib/utils/logger.js +111 -0
  50. package/dist/lib/utils/logger.mjs +46 -0
  51. package/dist/lib/utils/mapped-paths.js +94 -0
  52. package/dist/lib/utils/mapped-paths.mjs +46 -0
  53. package/dist/lib/utils/normalize.js +63 -0
  54. package/dist/lib/utils/normalize.mjs +17 -0
  55. package/dist/lib/utils/package-info.js +324 -0
  56. package/dist/lib/utils/package-info.mjs +265 -0
  57. package/dist/plugin.d.ts +1 -0
  58. package/dist/plugin.js +79 -1231
  59. package/dist/plugin.mjs +2 -1187
  60. package/dist/resolve/esm-resolver.mjs +15 -22
  61. package/package.json +2 -2
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/compat_get_default_export
14
+ (() => {
15
+ // getDefaultExport function for compatibility with non-ESM modules
16
+ __webpack_require__.n = (module) => {
17
+ var getter = module && module.__esModule ?
18
+ () => (module['default']) :
19
+ () => (module);
20
+ __webpack_require__.d(getter, { a: getter });
21
+ return getter;
22
+ };
23
+
24
+ })();
25
+ // webpack/runtime/define_property_getters
26
+ (() => {
27
+ __webpack_require__.d = (exports, definition) => {
28
+ for(var key in definition) {
29
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
+ }
32
+ }
33
+ };
34
+ })();
35
+ // webpack/runtime/has_own_property
36
+ (() => {
37
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
38
+ })();
39
+ // webpack/runtime/make_namespace_object
40
+ (() => {
41
+ // define __esModule on exports
42
+ __webpack_require__.r = (exports) => {
43
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
44
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
45
+ }
46
+ Object.defineProperty(exports, '__esModule', { value: true });
47
+ };
48
+ })();
49
+ /************************************************************************/
50
+ var __webpack_exports__ = {};
51
+ // ESM COMPAT FLAG
52
+ __webpack_require__.r(__webpack_exports__);
53
+
54
+ // EXPORTS
55
+ __webpack_require__.d(__webpack_exports__, {
56
+ createVirtualRemoteModule: () => (/* binding */ createVirtualRemoteModule),
57
+ linkRemotesPlugin: () => (/* binding */ linkRemotesPlugin)
58
+ });
59
+
60
+ ;// CONCATENATED MODULE: external "path"
61
+ const external_path_namespaceObject = require("path");
62
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
63
+ ;// CONCATENATED MODULE: ./src/adapters/lib/linkRemotesPlugin.ts
64
+
65
+ // relys on import map since i dont know the named exports of a remote to return.
66
+ const createVirtualRemoteModule = (name, ref)=>`
67
+ export * from ${JSON.stringify('federationRemote/' + ref)}
68
+ `;
69
+ const linkRemotesPlugin = (config)=>({
70
+ name: 'linkRemotes',
71
+ setup (build) {
72
+ const remotes = config.remotes || {};
73
+ const filter = new RegExp(Object.keys(remotes).reduce((acc, key)=>{
74
+ if (!key) return acc;
75
+ acc.push(`^${key}`);
76
+ return acc;
77
+ }, []).join('|'));
78
+ build.onResolve({
79
+ filter: filter
80
+ }, async (args)=>{
81
+ return {
82
+ path: args.path,
83
+ namespace: 'remote-module'
84
+ };
85
+ });
86
+ build.onResolve({
87
+ filter: /^federationRemote/
88
+ }, async (args)=>{
89
+ return {
90
+ path: args.path.replace('federationRemote/', ''),
91
+ external: true,
92
+ namespace: 'externals'
93
+ };
94
+ });
95
+ build.onLoad({
96
+ filter,
97
+ namespace: 'remote-module'
98
+ }, async (args)=>{
99
+ return {
100
+ contents: createVirtualRemoteModule(config.name, args.path),
101
+ loader: 'js',
102
+ resolveDir: external_path_default().dirname(args.path)
103
+ };
104
+ });
105
+ }
106
+ });
107
+
108
+ exports.createVirtualRemoteModule = __webpack_exports__.createVirtualRemoteModule;
109
+ exports.linkRemotesPlugin = __webpack_exports__.linkRemotesPlugin;
110
+ for(var __webpack_i__ in __webpack_exports__) {
111
+ if(["createVirtualRemoteModule","linkRemotesPlugin"].indexOf(__webpack_i__) === -1) {
112
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
113
+ }
114
+ }
115
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,50 @@
1
+ import path from "path";
2
+
3
+ ;// CONCATENATED MODULE: external "path"
4
+
5
+ ;// CONCATENATED MODULE: ./src/adapters/lib/linkRemotesPlugin.ts
6
+
7
+ // relys on import map since i dont know the named exports of a remote to return.
8
+ const createVirtualRemoteModule = (name, ref)=>`
9
+ export * from ${JSON.stringify('federationRemote/' + ref)}
10
+ `;
11
+ const linkRemotesPlugin = (config)=>({
12
+ name: 'linkRemotes',
13
+ setup (build) {
14
+ const remotes = config.remotes || {};
15
+ const filter = new RegExp(Object.keys(remotes).reduce((acc, key)=>{
16
+ if (!key) return acc;
17
+ acc.push(`^${key}`);
18
+ return acc;
19
+ }, []).join('|'));
20
+ build.onResolve({
21
+ filter: filter
22
+ }, async (args)=>{
23
+ return {
24
+ path: args.path,
25
+ namespace: 'remote-module'
26
+ };
27
+ });
28
+ build.onResolve({
29
+ filter: /^federationRemote/
30
+ }, async (args)=>{
31
+ return {
32
+ path: args.path.replace('federationRemote/', ''),
33
+ external: true,
34
+ namespace: 'externals'
35
+ };
36
+ });
37
+ build.onLoad({
38
+ filter,
39
+ namespace: 'remote-module'
40
+ }, async (args)=>{
41
+ return {
42
+ contents: createVirtualRemoteModule(config.name, args.path),
43
+ loader: 'js',
44
+ resolveDir: path.dirname(args.path)
45
+ };
46
+ });
47
+ }
48
+ });
49
+
50
+ export { createVirtualRemoteModule, linkRemotesPlugin };
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/compat_get_default_export
14
+ (() => {
15
+ // getDefaultExport function for compatibility with non-ESM modules
16
+ __webpack_require__.n = (module) => {
17
+ var getter = module && module.__esModule ?
18
+ () => (module['default']) :
19
+ () => (module);
20
+ __webpack_require__.d(getter, { a: getter });
21
+ return getter;
22
+ };
23
+
24
+ })();
25
+ // webpack/runtime/define_property_getters
26
+ (() => {
27
+ __webpack_require__.d = (exports, definition) => {
28
+ for(var key in definition) {
29
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
+ }
32
+ }
33
+ };
34
+ })();
35
+ // webpack/runtime/has_own_property
36
+ (() => {
37
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
38
+ })();
39
+ // webpack/runtime/make_namespace_object
40
+ (() => {
41
+ // define __esModule on exports
42
+ __webpack_require__.r = (exports) => {
43
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
44
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
45
+ }
46
+ Object.defineProperty(exports, '__esModule', { value: true });
47
+ };
48
+ })();
49
+ /************************************************************************/
50
+ var __webpack_exports__ = {};
51
+ // ESM COMPAT FLAG
52
+ __webpack_require__.r(__webpack_exports__);
53
+
54
+ // EXPORTS
55
+ __webpack_require__.d(__webpack_exports__, {
56
+ writeRemoteManifest: () => (/* binding */ writeRemoteManifest)
57
+ });
58
+
59
+ ;// CONCATENATED MODULE: external "fs"
60
+ const external_fs_namespaceObject = require("fs");
61
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
62
+ ;// CONCATENATED MODULE: external "path"
63
+ const external_path_namespaceObject = require("path");
64
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
65
+ ;// CONCATENATED MODULE: external "./collect-exports.js"
66
+ const external_collect_exports_js_namespaceObject = require("./collect-exports.js");
67
+ ;// CONCATENATED MODULE: external "@module-federation/esbuild/package.json"
68
+ const package_json_namespaceObject = require("@module-federation/esbuild/package.json");
69
+ ;// CONCATENATED MODULE: ./src/adapters/lib/manifest.ts
70
+
71
+
72
+
73
+ //@ts-expect-error
74
+
75
+ const writeRemoteManifest = async (config, result)=>{
76
+ var _result_metafile, _result_metafile1;
77
+ if (result.errors && result.errors.length > 0) {
78
+ console.warn('Build errors detected, skipping writeRemoteManifest.');
79
+ return;
80
+ }
81
+ let packageJson;
82
+ try {
83
+ const packageJsonPath = await (0,external_collect_exports_js_namespaceObject.resolve)(process.cwd(), '/package.json') || '';
84
+ packageJson = require(packageJsonPath);
85
+ } catch (e) {
86
+ packageJson = {
87
+ name: config.name
88
+ };
89
+ }
90
+ const envType = process.env['NODE_ENV'] === 'development' ? 'local' : process.env['NODE_ENV'] ?? '';
91
+ const publicPath = config.publicPath || 'auto';
92
+ let containerName = '';
93
+ const outputMap = Object.entries(((_result_metafile = result.metafile) === null || _result_metafile === void 0 ? void 0 : _result_metafile.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
94
+ const { entryPoint } = chunkValue;
95
+ const key = entryPoint || chunkKey;
96
+ if (key.startsWith('container:') && key.endsWith(config.filename)) {
97
+ containerName = key;
98
+ }
99
+ acc[key] = {
100
+ ...chunkValue,
101
+ chunk: chunkKey
102
+ };
103
+ return acc;
104
+ }, {});
105
+ if (!outputMap[containerName]) return;
106
+ const outputMapWithoutExt = Object.entries(((_result_metafile1 = result.metafile) === null || _result_metafile1 === void 0 ? void 0 : _result_metafile1.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
107
+ const { entryPoint } = chunkValue;
108
+ const key = entryPoint || chunkKey;
109
+ const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
110
+ acc[trimKey] = {
111
+ ...chunkValue,
112
+ chunk: chunkKey
113
+ };
114
+ return acc;
115
+ }, {});
116
+ const getChunks = (meta, outputMap)=>{
117
+ const assets = {
118
+ js: {
119
+ async: [],
120
+ sync: []
121
+ },
122
+ css: {
123
+ async: [],
124
+ sync: []
125
+ }
126
+ };
127
+ if (meta === null || meta === void 0 ? void 0 : meta.imports) {
128
+ meta.imports.forEach((imp)=>{
129
+ const importMeta = outputMap[imp.path];
130
+ if (importMeta && importMeta.kind !== 'dynamic-import') {
131
+ const childAssets = getChunks(importMeta, outputMap);
132
+ assets.js.async.push(...childAssets.js.async);
133
+ assets.js.sync.push(...childAssets.js.sync);
134
+ assets.css.async.push(...childAssets.css.async);
135
+ assets.css.sync.push(...childAssets.css.sync);
136
+ }
137
+ });
138
+ const assetType = meta.chunk.endsWith('.js') ? 'js' : 'css';
139
+ const syncOrAsync = meta.kind === 'dynamic-import' ? 'async' : 'sync';
140
+ assets[assetType][syncOrAsync].push(meta.chunk);
141
+ }
142
+ return assets;
143
+ };
144
+ const shared = config.shared ? await Promise.all(Object.entries(config.shared).map(async ([pkg, config])=>{
145
+ const meta = outputMap['esm-shares:' + pkg];
146
+ const chunks = getChunks(meta, outputMap);
147
+ let { version } = config;
148
+ if (!version) {
149
+ try {
150
+ const packageJsonPath = await (0,external_collect_exports_js_namespaceObject.resolve)(process.cwd(), `${pkg}/package.json`);
151
+ if (packageJsonPath) {
152
+ version = JSON.parse(external_fs_default().readFileSync(packageJsonPath, 'utf-8')).version;
153
+ }
154
+ } catch (e) {
155
+ console.warn(`Can't resolve ${pkg} version automatically, consider setting "version" manually`);
156
+ }
157
+ }
158
+ return {
159
+ id: `${config.name}:${pkg}`,
160
+ name: pkg,
161
+ version: version || config.version,
162
+ singleton: config.singleton || false,
163
+ requiredVersion: config.requiredVersion || '*',
164
+ assets: chunks
165
+ };
166
+ })) : [];
167
+ const remotes = config.remotes ? Object.entries(config.remotes).map(([alias, remote])=>{
168
+ const [federationContainerName, entry] = remote.includes('@') ? remote.split('@') : [
169
+ alias,
170
+ remote
171
+ ];
172
+ return {
173
+ federationContainerName,
174
+ moduleName: '',
175
+ alias,
176
+ entry
177
+ };
178
+ }) : [];
179
+ const exposes = config.exposes ? await Promise.all(Object.entries(config.exposes).map(async ([expose, value])=>{
180
+ const exposedFound = outputMapWithoutExt[value.replace('./', '')];
181
+ const chunks = getChunks(exposedFound, outputMap);
182
+ return {
183
+ id: `${config.name}:${expose.replace(/^\.\//, '')}`,
184
+ name: expose.replace(/^\.\//, ''),
185
+ assets: chunks,
186
+ path: expose
187
+ };
188
+ })) : [];
189
+ const types = {
190
+ path: '',
191
+ name: '',
192
+ zip: '@mf-types.zip',
193
+ api: '@mf-types.d.ts'
194
+ };
195
+ const manifest = {
196
+ id: config.name,
197
+ name: config.name,
198
+ metaData: {
199
+ name: config.name,
200
+ type: 'app',
201
+ buildInfo: {
202
+ buildVersion: envType,
203
+ buildName: (packageJson.name ?? 'default').replace(/[^a-zA-Z0-9]/g, '_')
204
+ },
205
+ remoteEntry: {
206
+ name: config.filename,
207
+ path: outputMap[containerName] ? external_path_default().dirname(outputMap[containerName].chunk) : '',
208
+ type: 'esm'
209
+ },
210
+ types,
211
+ globalName: config.name,
212
+ pluginVersion: package_json_namespaceObject.version,
213
+ publicPath
214
+ },
215
+ shared,
216
+ remotes,
217
+ exposes
218
+ };
219
+ const manifestPath = external_path_default().join(external_path_default().dirname(outputMap[containerName].chunk), 'mf-manifest.json');
220
+ external_fs_default().writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
221
+ };
222
+
223
+ exports.writeRemoteManifest = __webpack_exports__.writeRemoteManifest;
224
+ for(var __webpack_i__ in __webpack_exports__) {
225
+ if(["writeRemoteManifest"].indexOf(__webpack_i__) === -1) {
226
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
227
+ }
228
+ }
229
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,168 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { resolve } from "./collect-exports.mjs";
4
+ import { version as package_json_version } from "@module-federation/esbuild/package.json";
5
+
6
+ ;// CONCATENATED MODULE: external "fs"
7
+
8
+ ;// CONCATENATED MODULE: external "path"
9
+
10
+ ;// CONCATENATED MODULE: external "./collect-exports.mjs"
11
+
12
+ ;// CONCATENATED MODULE: external "@module-federation/esbuild/package.json"
13
+
14
+ ;// CONCATENATED MODULE: ./src/adapters/lib/manifest.ts
15
+
16
+
17
+
18
+ //@ts-expect-error
19
+
20
+ const writeRemoteManifest = async (config, result)=>{
21
+ var _result_metafile, _result_metafile1;
22
+ if (result.errors && result.errors.length > 0) {
23
+ console.warn('Build errors detected, skipping writeRemoteManifest.');
24
+ return;
25
+ }
26
+ let packageJson;
27
+ try {
28
+ const packageJsonPath = await resolve(process.cwd(), '/package.json') || '';
29
+ packageJson = require(packageJsonPath);
30
+ } catch (e) {
31
+ packageJson = {
32
+ name: config.name
33
+ };
34
+ }
35
+ const envType = process.env['NODE_ENV'] === 'development' ? 'local' : process.env['NODE_ENV'] ?? '';
36
+ const publicPath = config.publicPath || 'auto';
37
+ let containerName = '';
38
+ const outputMap = Object.entries(((_result_metafile = result.metafile) === null || _result_metafile === void 0 ? void 0 : _result_metafile.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
39
+ const { entryPoint } = chunkValue;
40
+ const key = entryPoint || chunkKey;
41
+ if (key.startsWith('container:') && key.endsWith(config.filename)) {
42
+ containerName = key;
43
+ }
44
+ acc[key] = {
45
+ ...chunkValue,
46
+ chunk: chunkKey
47
+ };
48
+ return acc;
49
+ }, {});
50
+ if (!outputMap[containerName]) return;
51
+ const outputMapWithoutExt = Object.entries(((_result_metafile1 = result.metafile) === null || _result_metafile1 === void 0 ? void 0 : _result_metafile1.outputs) || {}).reduce((acc, [chunkKey, chunkValue])=>{
52
+ const { entryPoint } = chunkValue;
53
+ const key = entryPoint || chunkKey;
54
+ const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
55
+ acc[trimKey] = {
56
+ ...chunkValue,
57
+ chunk: chunkKey
58
+ };
59
+ return acc;
60
+ }, {});
61
+ const getChunks = (meta, outputMap)=>{
62
+ const assets = {
63
+ js: {
64
+ async: [],
65
+ sync: []
66
+ },
67
+ css: {
68
+ async: [],
69
+ sync: []
70
+ }
71
+ };
72
+ if (meta === null || meta === void 0 ? void 0 : meta.imports) {
73
+ meta.imports.forEach((imp)=>{
74
+ const importMeta = outputMap[imp.path];
75
+ if (importMeta && importMeta.kind !== 'dynamic-import') {
76
+ const childAssets = getChunks(importMeta, outputMap);
77
+ assets.js.async.push(...childAssets.js.async);
78
+ assets.js.sync.push(...childAssets.js.sync);
79
+ assets.css.async.push(...childAssets.css.async);
80
+ assets.css.sync.push(...childAssets.css.sync);
81
+ }
82
+ });
83
+ const assetType = meta.chunk.endsWith('.js') ? 'js' : 'css';
84
+ const syncOrAsync = meta.kind === 'dynamic-import' ? 'async' : 'sync';
85
+ assets[assetType][syncOrAsync].push(meta.chunk);
86
+ }
87
+ return assets;
88
+ };
89
+ const shared = config.shared ? await Promise.all(Object.entries(config.shared).map(async ([pkg, config])=>{
90
+ const meta = outputMap['esm-shares:' + pkg];
91
+ const chunks = getChunks(meta, outputMap);
92
+ let { version } = config;
93
+ if (!version) {
94
+ try {
95
+ const packageJsonPath = await resolve(process.cwd(), `${pkg}/package.json`);
96
+ if (packageJsonPath) {
97
+ version = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')).version;
98
+ }
99
+ } catch (e) {
100
+ console.warn(`Can't resolve ${pkg} version automatically, consider setting "version" manually`);
101
+ }
102
+ }
103
+ return {
104
+ id: `${config.name}:${pkg}`,
105
+ name: pkg,
106
+ version: version || config.version,
107
+ singleton: config.singleton || false,
108
+ requiredVersion: config.requiredVersion || '*',
109
+ assets: chunks
110
+ };
111
+ })) : [];
112
+ const remotes = config.remotes ? Object.entries(config.remotes).map(([alias, remote])=>{
113
+ const [federationContainerName, entry] = remote.includes('@') ? remote.split('@') : [
114
+ alias,
115
+ remote
116
+ ];
117
+ return {
118
+ federationContainerName,
119
+ moduleName: '',
120
+ alias,
121
+ entry
122
+ };
123
+ }) : [];
124
+ const exposes = config.exposes ? await Promise.all(Object.entries(config.exposes).map(async ([expose, value])=>{
125
+ const exposedFound = outputMapWithoutExt[value.replace('./', '')];
126
+ const chunks = getChunks(exposedFound, outputMap);
127
+ return {
128
+ id: `${config.name}:${expose.replace(/^\.\//, '')}`,
129
+ name: expose.replace(/^\.\//, ''),
130
+ assets: chunks,
131
+ path: expose
132
+ };
133
+ })) : [];
134
+ const types = {
135
+ path: '',
136
+ name: '',
137
+ zip: '@mf-types.zip',
138
+ api: '@mf-types.d.ts'
139
+ };
140
+ const manifest = {
141
+ id: config.name,
142
+ name: config.name,
143
+ metaData: {
144
+ name: config.name,
145
+ type: 'app',
146
+ buildInfo: {
147
+ buildVersion: envType,
148
+ buildName: (packageJson.name ?? 'default').replace(/[^a-zA-Z0-9]/g, '_')
149
+ },
150
+ remoteEntry: {
151
+ name: config.filename,
152
+ path: outputMap[containerName] ? path.dirname(outputMap[containerName].chunk) : '',
153
+ type: 'esm'
154
+ },
155
+ types,
156
+ globalName: config.name,
157
+ pluginVersion: package_json_version,
158
+ publicPath
159
+ },
160
+ shared,
161
+ remotes,
162
+ exposes
163
+ };
164
+ const manifestPath = path.join(path.dirname(outputMap[containerName].chunk), 'mf-manifest.json');
165
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
166
+ };
167
+
168
+ export { writeRemoteManifest };