@module-federation/esbuild 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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