@module-federation/vite 1.14.1 → 1.14.2
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/lib/index.cjs +3 -7
- package/lib/index.mjs +3 -7
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -234,11 +234,11 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry" }) => {
|
|
|
234
234
|
if (!injectHtml()) return;
|
|
235
235
|
clientInjected = true;
|
|
236
236
|
const base = viteConfig.base.replace(/\/$/, "");
|
|
237
|
-
const stripBase = (p) => base && p.startsWith(base) ? p.slice(base.length) : p;
|
|
237
|
+
const stripBase = (p) => base && p.startsWith(base + "/") ? p.slice(base.length) : p;
|
|
238
238
|
const html = rewriteEntryScripts(c, (originalSrc) => {
|
|
239
239
|
return `/@id/${DEV_HTML_PROXY_PREFIX}${new URLSearchParams({
|
|
240
240
|
init: sanitizeDevEntryPath(stripBase(devEntryPath)),
|
|
241
|
-
entry: originalSrc
|
|
241
|
+
entry: sanitizeDevEntryPath(stripBase(originalSrc))
|
|
242
242
|
}).toString()}`;
|
|
243
243
|
});
|
|
244
244
|
return html === c ? injectEntryScript(c, stripBase(devEntryPath)) : html;
|
|
@@ -253,11 +253,7 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry" }) => {
|
|
|
253
253
|
const initSrc = params.get("init");
|
|
254
254
|
const entrySrc = params.get("entry");
|
|
255
255
|
if (!initSrc || !entrySrc) return;
|
|
256
|
-
return `
|
|
257
|
-
const baseUrl = document.baseURI || window.location.href;
|
|
258
|
-
await import(new URL(${JSON.stringify(initSrc)}, baseUrl).href);
|
|
259
|
-
await import(new URL(${JSON.stringify(entrySrc)}, baseUrl).href);
|
|
260
|
-
`;
|
|
256
|
+
return `import ${JSON.stringify(initSrc)};\nimport ${JSON.stringify(entrySrc)};\n`;
|
|
261
257
|
},
|
|
262
258
|
transform(code, id) {
|
|
263
259
|
if (id.includes("node_modules") || inject !== "html" || htmlFilePath) return;
|
package/lib/index.mjs
CHANGED
|
@@ -212,11 +212,11 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry" }) => {
|
|
|
212
212
|
if (!injectHtml()) return;
|
|
213
213
|
clientInjected = true;
|
|
214
214
|
const base = viteConfig.base.replace(/\/$/, "");
|
|
215
|
-
const stripBase = (p) => base && p.startsWith(base) ? p.slice(base.length) : p;
|
|
215
|
+
const stripBase = (p) => base && p.startsWith(base + "/") ? p.slice(base.length) : p;
|
|
216
216
|
const html = rewriteEntryScripts(c, (originalSrc) => {
|
|
217
217
|
return `/@id/${DEV_HTML_PROXY_PREFIX}${new URLSearchParams({
|
|
218
218
|
init: sanitizeDevEntryPath(stripBase(devEntryPath)),
|
|
219
|
-
entry: originalSrc
|
|
219
|
+
entry: sanitizeDevEntryPath(stripBase(originalSrc))
|
|
220
220
|
}).toString()}`;
|
|
221
221
|
});
|
|
222
222
|
return html === c ? injectEntryScript(c, stripBase(devEntryPath)) : html;
|
|
@@ -231,11 +231,7 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry" }) => {
|
|
|
231
231
|
const initSrc = params.get("init");
|
|
232
232
|
const entrySrc = params.get("entry");
|
|
233
233
|
if (!initSrc || !entrySrc) return;
|
|
234
|
-
return `
|
|
235
|
-
const baseUrl = document.baseURI || window.location.href;
|
|
236
|
-
await import(new URL(${JSON.stringify(initSrc)}, baseUrl).href);
|
|
237
|
-
await import(new URL(${JSON.stringify(entrySrc)}, baseUrl).href);
|
|
238
|
-
`;
|
|
234
|
+
return `import ${JSON.stringify(initSrc)};\nimport ${JSON.stringify(entrySrc)};\n`;
|
|
239
235
|
},
|
|
240
236
|
transform(code, id) {
|
|
241
237
|
if (id.includes("node_modules") || inject !== "html" || htmlFilePath) return;
|