@module-federation/vite 1.16.15 → 1.17.0
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/README.md +29 -0
- package/lib/index.d.ts +13 -3
- package/lib/index.js +952 -123
- package/lib/{pluginDts-Bo95ELmX.js → pluginDts-BcvLBYP3.js} +67 -0
- package/package.json +1 -1
|
@@ -277,6 +277,73 @@ const sharedCacheHelperCode = `const __mfGetSharedCacheDescriptor = (pkg, single
|
|
|
277
277
|
if (cache[alias] === undefined) cache[alias] = value;
|
|
278
278
|
}
|
|
279
279
|
return value;
|
|
280
|
+
};
|
|
281
|
+
const __mfTreeShakingSharedCacheKey = Symbol.for("module-federation.tree-shaking-shared-cache");
|
|
282
|
+
const __mfGetTreeShakingSharedCache = (cache) => {
|
|
283
|
+
let metadata = cache[__mfTreeShakingSharedCacheKey];
|
|
284
|
+
if (metadata === undefined) {
|
|
285
|
+
metadata = Object.create(null);
|
|
286
|
+
Object.defineProperty(cache, __mfTreeShakingSharedCacheKey, {
|
|
287
|
+
value: metadata,
|
|
288
|
+
enumerable: false,
|
|
289
|
+
configurable: false,
|
|
290
|
+
writable: false
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return metadata;
|
|
294
|
+
};
|
|
295
|
+
const __mfReadTreeShakingSharedCache = (cache, descriptor, requiredExports) => {
|
|
296
|
+
const fullModule = __mfReadSharedCache(cache, descriptor);
|
|
297
|
+
if (fullModule !== undefined) return fullModule;
|
|
298
|
+
if (!Array.isArray(requiredExports)) return undefined;
|
|
299
|
+
const metadata = cache[__mfTreeShakingSharedCacheKey];
|
|
300
|
+
const entries = metadata?.[descriptor.canonical] || [];
|
|
301
|
+
let compatibleEntry;
|
|
302
|
+
for (const entry of entries) {
|
|
303
|
+
if (!requiredExports.every((name) => entry.providedExports.includes(name))) continue;
|
|
304
|
+
if (!compatibleEntry || entry.providedExports.length < compatibleEntry.providedExports.length) {
|
|
305
|
+
compatibleEntry = entry;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return compatibleEntry?.value;
|
|
309
|
+
};
|
|
310
|
+
const __mfWriteTreeShakingSharedCache = (cache, descriptor, providedExports, value) => {
|
|
311
|
+
if (!Array.isArray(providedExports)) return value;
|
|
312
|
+
const normalizedExports = [...new Set(providedExports)].sort();
|
|
313
|
+
const metadata = __mfGetTreeShakingSharedCache(cache);
|
|
314
|
+
const entries = (metadata[descriptor.canonical] ||= []);
|
|
315
|
+
const existing = entries.find((entry) =>
|
|
316
|
+
entry.providedExports.length === normalizedExports.length &&
|
|
317
|
+
entry.providedExports.every((name, index) => name === normalizedExports[index])
|
|
318
|
+
);
|
|
319
|
+
if (existing) existing.value = value;
|
|
320
|
+
else entries.push({ providedExports: normalizedExports, value });
|
|
321
|
+
return value;
|
|
322
|
+
};
|
|
323
|
+
const __mfTreeShakingSelectionCacheKey = Symbol.for("module-federation.tree-shaking-shared-selection-cache");
|
|
324
|
+
const __mfGetTreeShakingSelectionCache = (cache) => {
|
|
325
|
+
let selections = cache[__mfTreeShakingSelectionCacheKey];
|
|
326
|
+
if (selections === undefined) {
|
|
327
|
+
selections = Object.create(null);
|
|
328
|
+
Object.defineProperty(cache, __mfTreeShakingSelectionCacheKey, {
|
|
329
|
+
value: selections,
|
|
330
|
+
enumerable: false,
|
|
331
|
+
configurable: false,
|
|
332
|
+
writable: false
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return selections;
|
|
336
|
+
};
|
|
337
|
+
const __mfReadTreeShakingSharedSelection = (cache, descriptor, consumer) => {
|
|
338
|
+
const fullModule = __mfReadSharedCache(cache, descriptor);
|
|
339
|
+
if (fullModule !== undefined) return fullModule;
|
|
340
|
+
return cache[__mfTreeShakingSelectionCacheKey]?.[descriptor.canonical]?.[consumer];
|
|
341
|
+
};
|
|
342
|
+
const __mfWriteTreeShakingSharedSelection = (cache, descriptor, consumer, value) => {
|
|
343
|
+
const selections = __mfGetTreeShakingSelectionCache(cache);
|
|
344
|
+
const byConsumer = (selections[descriptor.canonical] ||= Object.create(null));
|
|
345
|
+
byConsumer[consumer] = value;
|
|
346
|
+
return value;
|
|
280
347
|
};`;
|
|
281
348
|
function getInstalledPackageJson(pkg, opts) {
|
|
282
349
|
const cwd = opts?.cwd || getPackageDetectionCwd();
|