@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,259 @@
1
+ import { logger } from "./logger.mjs";
2
+ import { normalize } from "./normalize.mjs";
3
+
4
+ import * as __rspack_external_fs from "fs";
5
+ import * as __rspack_external_path from "path";
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ const packageCache = {};
15
+ function findPackageJsonFiles(project, workspace) {
16
+ return expandFolders(project, workspace).map((f)=>__rspack_external_path.join(f, 'package.json')).filter((f)=>__rspack_external_fs.existsSync(f));
17
+ }
18
+ function expandFolders(child, parent) {
19
+ const result = [];
20
+ parent = normalize(parent, true);
21
+ child = normalize(child, true);
22
+ if (!child.startsWith(parent)) {
23
+ throw new Error(`Workspace folder ${parent} needs to be a parent of the project folder ${child}`);
24
+ }
25
+ let current = child;
26
+ while(current !== parent){
27
+ result.push(current);
28
+ const cand = normalize(__rspack_external_path.dirname(current), true);
29
+ if (cand === current) {
30
+ break;
31
+ }
32
+ current = cand;
33
+ }
34
+ result.push(parent);
35
+ return result;
36
+ }
37
+ function getPackageInfo(packageName, workspaceRoot) {
38
+ workspaceRoot = normalize(workspaceRoot, true);
39
+ const packageJsonInfos = getPackageJsonFiles(workspaceRoot, workspaceRoot);
40
+ for (const info of packageJsonInfos){
41
+ const cand = _getPackageInfo(packageName, info.directory);
42
+ if (cand) {
43
+ return cand;
44
+ }
45
+ }
46
+ logger.warn('No meta data found for shared lib ' + packageName);
47
+ return null;
48
+ }
49
+ function getVersionMapCacheKey(project, workspace) {
50
+ return `${project}**${workspace}`;
51
+ }
52
+ function getVersionMaps(project, workspace) {
53
+ return getPackageJsonFiles(project, workspace).map((json)=>({
54
+ ...json.content['dependencies']
55
+ }));
56
+ }
57
+ function getPackageJsonFiles(project, workspace) {
58
+ const cacheKey = getVersionMapCacheKey(project, workspace);
59
+ let maps = packageCache[cacheKey];
60
+ if (maps) {
61
+ return maps;
62
+ }
63
+ maps = findPackageJsonFiles(project, workspace).map((f)=>{
64
+ const content = JSON.parse(__rspack_external_fs.readFileSync(f, 'utf-8'));
65
+ const directory = normalize(__rspack_external_path.dirname(f), true);
66
+ const result = {
67
+ content,
68
+ directory
69
+ };
70
+ return result;
71
+ });
72
+ packageCache[cacheKey] = maps;
73
+ return maps;
74
+ }
75
+ function findDepPackageJson(packageName, projectRoot) {
76
+ const mainPkgName = getPkgFolder(packageName);
77
+ let mainPkgPath = __rspack_external_path.join(projectRoot, 'node_modules', mainPkgName);
78
+ let mainPkgJsonPath = __rspack_external_path.join(mainPkgPath, 'package.json');
79
+ let directory = projectRoot;
80
+ while(__rspack_external_path.dirname(directory) !== directory){
81
+ if (__rspack_external_fs.existsSync(mainPkgJsonPath)) {
82
+ break;
83
+ }
84
+ directory = normalize(__rspack_external_path.dirname(directory), true);
85
+ mainPkgPath = __rspack_external_path.join(directory, 'node_modules', mainPkgName);
86
+ mainPkgJsonPath = __rspack_external_path.join(mainPkgPath, 'package.json');
87
+ }
88
+ if (!__rspack_external_fs.existsSync(mainPkgJsonPath)) {
89
+ logger.verbose('No package.json found for ' + packageName + ' in ' + mainPkgPath);
90
+ return null;
91
+ }
92
+ return mainPkgJsonPath;
93
+ }
94
+ function _getPackageInfo(packageName, directory) {
95
+ const mainPkgName = getPkgFolder(packageName);
96
+ const mainPkgJsonPath = findDepPackageJson(packageName, directory);
97
+ if (!mainPkgJsonPath) {
98
+ return null;
99
+ }
100
+ const mainPkgPath = __rspack_external_path.dirname(mainPkgJsonPath);
101
+ const mainPkgJson = readJson(mainPkgJsonPath);
102
+ const version = mainPkgJson['version'];
103
+ const esm = mainPkgJson['type'] === 'module';
104
+ if (!version) {
105
+ logger.warn('No version found for ' + packageName);
106
+ return null;
107
+ }
108
+ let relSecondaryPath = __rspack_external_path.relative(mainPkgName, packageName);
109
+ if (!relSecondaryPath) {
110
+ relSecondaryPath = '.';
111
+ } else {
112
+ relSecondaryPath = './' + relSecondaryPath.replace(/\\/g, '/');
113
+ }
114
+ let cand = mainPkgJson?.exports?.[relSecondaryPath];
115
+ if (typeof cand === 'string') {
116
+ return {
117
+ entryPoint: __rspack_external_path.join(mainPkgPath, cand),
118
+ packageName,
119
+ version,
120
+ esm
121
+ };
122
+ }
123
+ cand = mainPkgJson?.exports?.[relSecondaryPath]?.import;
124
+ if (typeof cand === 'object') {
125
+ if (cand.module) {
126
+ cand = cand.module;
127
+ } else if (cand.import) {
128
+ cand = cand.import;
129
+ } else if (cand.default) {
130
+ cand = cand.default;
131
+ } else {
132
+ cand = null;
133
+ }
134
+ }
135
+ if (cand) {
136
+ if (typeof cand === 'object') {
137
+ if (cand.module) {
138
+ cand = cand.module;
139
+ } else if (cand.import) {
140
+ cand = cand.import;
141
+ } else if (cand.default) {
142
+ cand = cand.default;
143
+ } else {
144
+ cand = null;
145
+ }
146
+ }
147
+ return {
148
+ entryPoint: __rspack_external_path.join(mainPkgPath, cand),
149
+ packageName,
150
+ version,
151
+ esm
152
+ };
153
+ }
154
+ cand = mainPkgJson?.exports?.[relSecondaryPath]?.module;
155
+ if (typeof cand === 'object') {
156
+ if (cand.module) {
157
+ cand = cand.module;
158
+ } else if (cand.import) {
159
+ cand = cand.import;
160
+ } else if (cand.default) {
161
+ cand = cand.default;
162
+ } else {
163
+ cand = null;
164
+ }
165
+ }
166
+ if (cand) {
167
+ return {
168
+ entryPoint: __rspack_external_path.join(mainPkgPath, cand),
169
+ packageName,
170
+ version,
171
+ esm
172
+ };
173
+ }
174
+ cand = mainPkgJson?.exports?.[relSecondaryPath]?.default;
175
+ if (cand) {
176
+ if (typeof cand === 'object') {
177
+ if (cand.module) {
178
+ cand = cand.module;
179
+ } else if (cand.import) {
180
+ cand = cand.import;
181
+ } else if (cand.default) {
182
+ cand = cand.default;
183
+ } else {
184
+ cand = null;
185
+ }
186
+ }
187
+ return {
188
+ entryPoint: __rspack_external_path.join(mainPkgPath, cand),
189
+ packageName,
190
+ version,
191
+ esm
192
+ };
193
+ }
194
+ cand = mainPkgJson['module'];
195
+ if (cand && relSecondaryPath === '.') {
196
+ return {
197
+ entryPoint: __rspack_external_path.join(mainPkgPath, cand),
198
+ packageName,
199
+ version,
200
+ esm: true
201
+ };
202
+ }
203
+ const secondaryPgkPath = __rspack_external_path.join(mainPkgPath, relSecondaryPath);
204
+ const secondaryPgkJsonPath = __rspack_external_path.join(secondaryPgkPath, 'package.json');
205
+ let secondaryPgkJson = null;
206
+ if (__rspack_external_fs.existsSync(secondaryPgkJsonPath)) {
207
+ secondaryPgkJson = readJson(secondaryPgkJsonPath);
208
+ }
209
+ if (secondaryPgkJson && secondaryPgkJson.module) {
210
+ return {
211
+ entryPoint: __rspack_external_path.join(secondaryPgkPath, secondaryPgkJson.module),
212
+ packageName,
213
+ version,
214
+ esm: true
215
+ };
216
+ }
217
+ cand = __rspack_external_path.join(secondaryPgkPath, 'index.mjs');
218
+ if (__rspack_external_fs.existsSync(cand)) {
219
+ return {
220
+ entryPoint: cand,
221
+ packageName,
222
+ version,
223
+ esm: true
224
+ };
225
+ }
226
+ if (secondaryPgkJson && secondaryPgkJson.main) {
227
+ return {
228
+ entryPoint: __rspack_external_path.join(secondaryPgkPath, secondaryPgkJson.main),
229
+ packageName,
230
+ version,
231
+ esm
232
+ };
233
+ }
234
+ cand = __rspack_external_path.join(secondaryPgkPath, 'index.js');
235
+ if (__rspack_external_fs.existsSync(cand)) {
236
+ return {
237
+ entryPoint: cand,
238
+ packageName,
239
+ version,
240
+ esm
241
+ };
242
+ }
243
+ logger.warn('No entry point found for ' + packageName);
244
+ logger.warn("If you don't need this package, skip it in your federation.config.js or consider moving it into depDependencies in your package.json");
245
+ return null;
246
+ }
247
+ function readJson(mainPkgJsonPath) {
248
+ return JSON.parse(__rspack_external_fs.readFileSync(mainPkgJsonPath, 'utf-8'));
249
+ }
250
+ function getPkgFolder(packageName) {
251
+ const parts = packageName.split('/');
252
+ let folder = parts[0];
253
+ if (folder.startsWith('@')) {
254
+ folder += '/' + parts[1];
255
+ }
256
+ return folder;
257
+ }
258
+
259
+ export { _getPackageInfo, expandFolders, findDepPackageJson, findPackageJsonFiles, getPackageInfo, getPackageJsonFiles, getVersionMaps };
@@ -0,0 +1 @@
1
+ export * from './adapters/lib/plugin';