@module-federation/vite 1.22.1 → 1.23.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 +19 -0
- package/lib/{dtsConstants-dDsHZFC1.js → dtsConstants-DEMpRfBz.js} +231 -59
- package/lib/index.d.ts +14 -1
- package/lib/index.js +1076 -366
- package/lib/{pluginDts-CQ088qGF.js → pluginDts-VSLhAx6d.js} +1 -1
- package/lib/{sharedKeyMatcher-BRzBCbuR.js → sharedKeyMatcher-Od_nYxJA.js} +39 -10
- package/lib/{ssrEntryLoader-BUXUQi0P.js → ssrEntryLoader-BvAkpCyi.js} +1 -1
- package/lib/{ssrVmStrategy-Ud06y3Xf.js → ssrVmStrategy-CDbcwMnf.js} +2 -2
- package/lib/utils/ssrEntryLoader.js +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as normalizePathForImport } from "./buildPaths-BoaQTkxt.js";
|
|
2
|
-
import {
|
|
2
|
+
import { T as mfError, g as resolveImportPath, u as hasPackageDependency, w as createModuleFederationError } from "./dtsConstants-DEMpRfBz.js";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import os from "os";
|
|
@@ -129,11 +129,38 @@ function resolvePublicPath(options, viteBase, originalBase) {
|
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/utils/sharedKeyMatcher.ts
|
|
132
|
-
function
|
|
133
|
-
const
|
|
132
|
+
function getSharedRequest(key, shareItem) {
|
|
133
|
+
const request = shareItem?.shareConfig?.request;
|
|
134
|
+
return typeof request === "string" ? request : key;
|
|
135
|
+
}
|
|
136
|
+
/** `prefix` ends with `/` and `source` is its base or a subpath under it. */
|
|
137
|
+
function isUnderPrefix(prefix, source) {
|
|
138
|
+
return prefix.endsWith("/") && (source === prefix.slice(0, -1) || source.startsWith(prefix));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve the runtime share-scope key for a concrete request. The configured
|
|
142
|
+
* property name is the default runtime key; `shareKey` only changes it when
|
|
143
|
+
* explicitly provided. Prefix requests carry their concrete suffix to the
|
|
144
|
+
* runtime key as required by the Module Federation shared contract.
|
|
145
|
+
*/
|
|
146
|
+
function getSharedRuntimeKey(source, shareItem) {
|
|
147
|
+
const name = typeof shareItem?.name === "string" ? shareItem.name : void 0;
|
|
148
|
+
const request = getSharedRequest(name ?? source, shareItem);
|
|
149
|
+
const configuredShareKey = shareItem?.shareConfig?.shareKey;
|
|
150
|
+
const sourceMatchesRequest = source === request || isUnderPrefix(request, source);
|
|
151
|
+
const shareKey = typeof configuredShareKey === "string" ? configuredShareKey : name !== void 0 && sourceMatchesRequest ? name : source;
|
|
152
|
+
if (!request.endsWith("/")) return shareKey;
|
|
153
|
+
const requestBase = request.slice(0, -1);
|
|
154
|
+
if (source === requestBase) return shareKey.endsWith("/") ? shareKey.slice(0, -1) : shareKey;
|
|
155
|
+
if (source.startsWith(`${requestBase}/`)) return shareKey + source.slice(request.length);
|
|
156
|
+
return isUnderPrefix(shareKey, source) ? source : shareKey;
|
|
157
|
+
}
|
|
158
|
+
function matchesSharedSource(source, key, shareItem) {
|
|
159
|
+
const request = getSharedRequest(key, shareItem);
|
|
160
|
+
const keyBase = request.endsWith("/") ? request.slice(0, -1) : request;
|
|
134
161
|
if (keyBase === "vue" && (source === "vue/dist/vue.esm-bundler.js" || source === "vue/dist/vue.runtime.esm-bundler.js")) return true;
|
|
135
|
-
if (
|
|
136
|
-
if (getCommonSharedSubpaths(keyBase).includes(source)) return true;
|
|
162
|
+
if (request.endsWith("/")) return source === keyBase || source.startsWith(`${keyBase}/`);
|
|
163
|
+
if (shareItem?.shareConfig?.request === void 0 && shareItem?.shareConfig?.shareKey === void 0 && getCommonSharedSubpaths(keyBase).includes(source)) return true;
|
|
137
164
|
return source === keyBase;
|
|
138
165
|
}
|
|
139
166
|
const emptySharedKeyMatcher = { find: () => void 0 };
|
|
@@ -157,26 +184,28 @@ function getSharedKeyMatcher(shared) {
|
|
|
157
184
|
const cached = sharedKeyMatcherCache.get(shared);
|
|
158
185
|
if (cached) return cached;
|
|
159
186
|
const keys = Object.keys(shared);
|
|
160
|
-
const exactKeys = new
|
|
187
|
+
const exactKeys = /* @__PURE__ */ new Map();
|
|
161
188
|
const commonSubpathKeys = /* @__PURE__ */ new Map();
|
|
162
189
|
const wildcardKeys = [];
|
|
163
190
|
let vueKey;
|
|
164
191
|
for (const key of keys) {
|
|
165
|
-
const keyBase = key.endsWith("/") ? key.slice(0, -1) : key;
|
|
166
192
|
const shareItem = shared[key];
|
|
193
|
+
const request = getSharedRequest(key, shareItem);
|
|
194
|
+
const keyBase = request.endsWith("/") ? request.slice(0, -1) : request;
|
|
195
|
+
if (!exactKeys.has(request) || request === key) exactKeys.set(request, key);
|
|
167
196
|
if (!vueKey && keyBase === "vue") vueKey = key;
|
|
168
|
-
if (
|
|
197
|
+
if (request.endsWith("/")) wildcardKeys.push({
|
|
169
198
|
key,
|
|
170
199
|
base: keyBase
|
|
171
200
|
});
|
|
172
|
-
if (shareItem?.shareConfig?.import !== false) {
|
|
201
|
+
if (shareItem?.shareConfig?.import !== false && shareItem?.shareConfig?.request === void 0 && shareItem?.shareConfig?.shareKey === void 0) {
|
|
173
202
|
for (const subpath of getCommonSharedSubpaths(keyBase)) if (!commonSubpathKeys.has(subpath)) commonSubpathKeys.set(subpath, key);
|
|
174
203
|
}
|
|
175
204
|
}
|
|
176
205
|
const sourceCache = /* @__PURE__ */ new Map();
|
|
177
206
|
const matcher = { find(source) {
|
|
178
207
|
if (sourceCache.has(source)) return sourceCache.get(source);
|
|
179
|
-
let result = exactKeys.
|
|
208
|
+
let result = exactKeys.get(source);
|
|
180
209
|
if (!result && vueKey) {
|
|
181
210
|
if (source === "vue/dist/vue.esm-bundler.js" || source === "vue/dist/vue.runtime.esm-bundler.js") result = vueKey;
|
|
182
211
|
}
|
|
@@ -189,4 +218,4 @@ function getSharedKeyMatcher(shared) {
|
|
|
189
218
|
return matcher;
|
|
190
219
|
}
|
|
191
220
|
//#endregion
|
|
192
|
-
export {
|
|
221
|
+
export { resolvePublicPath as _, matchesSharedSource as a, filterId as c, getNodeModulesSuffix as d, isAssetLikeImport as f, normalizeNodeModulePath as g, isViteOptimizableEntry as h, invalidateSharedKeyMatcher as i, getBasePath as l, isNuxtClientBase as m, getSharedRequest as n, VITE_FS_PREFIX as o, isNodeModulePath as p, getSharedRuntimeKey as r, ensureTrailingSlash as s, findSharedKey as t, getCommonSharedSubpaths as u, stripQueryAndHash as v, stripViteFsPrefix as y };
|
|
@@ -666,7 +666,7 @@ async function importTempModule(filePath, versionKey) {
|
|
|
666
666
|
}
|
|
667
667
|
let warnedVmUnavailable = false;
|
|
668
668
|
async function tryVmStrategy(ssrEntry, options) {
|
|
669
|
-
const { loadViaVmStrategy, isVmStrategyAvailable } = await import("./ssrVmStrategy-
|
|
669
|
+
const { loadViaVmStrategy, isVmStrategyAvailable } = await import("./ssrVmStrategy-CDbcwMnf.js");
|
|
670
670
|
if (!await isVmStrategyAvailable()) {
|
|
671
671
|
if (!warnedVmUnavailable) {
|
|
672
672
|
warnedVmUnavailable = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as findSharedKey } from "./sharedKeyMatcher-
|
|
2
|
-
import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-
|
|
1
|
+
import { t as findSharedKey } from "./sharedKeyMatcher-Od_nYxJA.js";
|
|
2
|
+
import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-BvAkpCyi.js";
|
|
3
3
|
//#region src/utils/ssrVmStrategy.ts
|
|
4
4
|
/**
|
|
5
5
|
* vm.SourceTextModule strategy for loading remote SSR entries.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ssrEntryLoaderPlugin, n as neutralizeBrowserPreloadHelpers, r as revalidate, t as SsrEntryHttpError } from "../ssrEntryLoader-
|
|
1
|
+
import { i as ssrEntryLoaderPlugin, n as neutralizeBrowserPreloadHelpers, r as revalidate, t as SsrEntryHttpError } from "../ssrEntryLoader-BvAkpCyi.js";
|
|
2
2
|
export { SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Vite plugin for Module Federation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@module-federation/dts-plugin": "2.9.
|
|
81
|
-
"@module-federation/runtime": "2.9.
|
|
82
|
-
"@module-federation/sdk": "2.9.
|
|
80
|
+
"@module-federation/dts-plugin": "2.9.1",
|
|
81
|
+
"@module-federation/runtime": "2.9.1",
|
|
82
|
+
"@module-federation/sdk": "2.9.1"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@playwright/test": "1.62.0",
|