@module-federation/vite 1.23.0 → 1.23.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.
@@ -1,66 +0,0 @@
1
- //#region src/utils/buildPaths.ts
2
- /**
3
- * Rebase an import path for a bootstrap file that moved from root into `dir`.
4
- *
5
- * When entryFileNames places entries in a subdirectory (e.g. `static/js/`),
6
- * the bootstrap file moves there too. Paths that resolved from the HTML root
7
- * must resolve from the new directory instead.
8
- *
9
- * Cases: `/static/js/hostInit.js` → `./hostInit.js` (strip dir prefix)
10
- * `./src/main.tsx` → `../../src/main.tsx` (climb back up for each dir level)
11
- * `https://cdn.example.com` → unchanged (absolute URL)
12
- */
13
- function rebaseImport(importSrc, dir) {
14
- if (!dir) return importSrc;
15
- if (isAbsoluteUrl(importSrc)) return importSrc;
16
- const normalizedDir = dir.replace(/^\/+|\/+$/g, "");
17
- if (!normalizedDir) return importSrc;
18
- const stripDirPrefix = (src, prefix) => {
19
- if (src === prefix) return "";
20
- if (src.startsWith(prefix + "/")) return src.slice(prefix.length);
21
- };
22
- const absoluteRemainder = stripDirPrefix(importSrc, "/" + normalizedDir);
23
- if (absoluteRemainder !== void 0) {
24
- const remainder = absoluteRemainder.replace(/^\/+/, "");
25
- return remainder ? "./" + remainder : "./";
26
- }
27
- const relativeRemainder = stripDirPrefix(importSrc, normalizedDir);
28
- if (relativeRemainder !== void 0) {
29
- const remainder = relativeRemainder.replace(/^\/+/, "");
30
- return remainder ? "./" + remainder : "./";
31
- }
32
- const upLevels = normalizedDir.split("/").filter(Boolean).length;
33
- const prefix = upLevels > 0 ? "../".repeat(upLevels) : "./";
34
- if (importSrc.startsWith("./")) return prefix + importSrc.slice(2);
35
- if (importSrc.startsWith("/")) return prefix + importSrc.slice(1);
36
- return prefix + importSrc;
37
- }
38
- function normalizePathForImport(path) {
39
- return path.replace(/\\/g, "/");
40
- }
41
- const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i;
42
- function isAbsoluteUrl(src) {
43
- if (/^[a-z]:[\\/]/i.test(src)) return false;
44
- return EXTERNAL_URL_RE.test(src);
45
- }
46
- const HASH_PLACEHOLDER_RE = /(?:[._-]?\[hash(?::\d+)?\])/g;
47
- function hasFileExtension(fileName) {
48
- return fileName.slice(Math.max(fileName.lastIndexOf("/"), fileName.lastIndexOf("\\")) + 1).lastIndexOf(".") > 0;
49
- }
50
- /**
51
- * Resolve a bundler `filename` template that still contains `[hash]` placeholders
52
- * into the concrete, stable file name Module Federation serves.
53
- *
54
- * The federation entries are emitted by us rather than hashed by the bundler, so
55
- * the placeholder is dropped instead of being substituted. When stripping it also
56
- * removes the extension (`mf-[hash:8]` → `mf`), `.js` is appended so the result
57
- * stays a loadable module. The extension check deliberately looks at the basename
58
- * only — a dotted directory (`assets/v1.2/entry`) must not be mistaken for one.
59
- */
60
- function resolveHashPlaceholderFileName(fileName) {
61
- if (!fileName.includes("[hash")) return fileName;
62
- const normalized = fileName.replace(HASH_PLACEHOLDER_RE, "");
63
- return hasFileExtension(normalized) ? normalized : `${normalized}.js`;
64
- }
65
- //#endregion
66
- export { resolveHashPlaceholderFileName as i, normalizePathForImport as n, rebaseImport as r, EXTERNAL_URL_RE as t };