@module-federation/vite 1.22.0 → 1.22.1

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,5 +1,5 @@
1
1
  import { n as normalizePathForImport } from "./buildPaths-BoaQTkxt.js";
2
- import { _ as mfError, g as createModuleFederationError, l as hasPackageDependency, p as resolveImportPath } from "./dtsConstants-BEGrtvcw.js";
2
+ import { h as resolveImportPath, l as hasPackageDependency, v as createModuleFederationError, y as mfError } from "./dtsConstants-dDsHZFC1.js";
3
3
  import fs from "fs";
4
4
  import * as path$1 from "node:path";
5
5
  import os from "os";
@@ -82,9 +82,25 @@ function getBasePath(base) {
82
82
  function isNuxtClientBase(base) {
83
83
  return getBasePath(base).endsWith("/_nuxt");
84
84
  }
85
+ const VITE_FS_PREFIX = "/@fs/";
86
+ function stripQueryAndHash(id) {
87
+ const queryIndex = id.indexOf("?");
88
+ const hashIndex = id.indexOf("#");
89
+ const endIndex = queryIndex === -1 ? hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
90
+ return endIndex === -1 ? id : id.slice(0, endIndex);
91
+ }
92
+ function stripViteFsPrefix(id) {
93
+ if (!id.startsWith("/@fs/")) return id;
94
+ const file = id.slice(5);
95
+ return file.startsWith("/") || /^[a-z]:\//i.test(file) ? file : `/${file}`;
96
+ }
85
97
  function normalizeNodeModulePath(source) {
86
- const queryIndex = source.indexOf("?");
87
- return (queryIndex === -1 ? source : source.slice(0, queryIndex)).replace(/\\/g, "/");
98
+ return stripQueryAndHash(source).replace(/\\/g, "/");
99
+ }
100
+ function getNodeModulesSuffix(source) {
101
+ const normalized = normalizeNodeModulePath(source);
102
+ const index = normalized.lastIndexOf("/node_modules/");
103
+ return index === -1 ? void 0 : normalized.slice(index + 14);
88
104
  }
89
105
  function isNodeModulePath(source) {
90
106
  return source.includes("/node_modules/") || source.includes("\\node_modules\\");
@@ -92,31 +108,9 @@ function isNodeModulePath(source) {
92
108
  function filterId(id) {
93
109
  return typeof id === "string" && !id.includes("\0");
94
110
  }
95
- const NODE_MODULE_FILE_EXT_RE = /^\.[cm]?[jt]sx?$/i;
96
- function matchesNodeModuleCandidate(normalized, candidate) {
97
- const marker = `/node_modules/${candidate}`;
98
- let from = 0;
99
- while (from < normalized.length) {
100
- const index = normalized.indexOf(marker, from);
101
- if (index === -1) return false;
102
- const after = normalized.slice(index + marker.length);
103
- const boundary = after.search(/[?#]/);
104
- const afterPath = boundary === -1 ? after : after.slice(0, boundary);
105
- if (afterPath === "" || afterPath.startsWith("/") || NODE_MODULE_FILE_EXT_RE.test(afterPath)) return true;
106
- from = index + 1;
107
- }
108
- return false;
109
- }
110
- function getMatchingNodeModuleSubpath(source, candidates) {
111
- const normalized = normalizeNodeModulePath(source);
112
- return [...candidates].sort((a, b) => b.length - a.length).find((candidate) => matchesNodeModuleCandidate(normalized, candidate));
113
- }
114
111
  function getCommonSharedSubpaths(sharedKey) {
115
112
  return COMMON_SHARED_SUBPATHS[removeTrailingSlash(sharedKey)] || [];
116
113
  }
117
- function getCommonSharedSubpathFromNodeModulePath(source, sharedKey) {
118
- return getMatchingNodeModuleSubpath(source, getCommonSharedSubpaths(removeTrailingSlash(sharedKey)));
119
- }
120
114
  /**
121
115
  * Resolves the public path for remote entries
122
116
  * @param options - Module Federation options
@@ -195,4 +189,4 @@ function getSharedKeyMatcher(shared) {
195
189
  return matcher;
196
190
  }
197
191
  //#endregion
198
- export { filterId as a, getCommonSharedSubpaths as c, isNodeModulePath as d, isNuxtClientBase as f, resolvePublicPath as h, ensureTrailingSlash as i, getMatchingNodeModuleSubpath as l, normalizeNodeModulePath as m, invalidateSharedKeyMatcher as n, getBasePath as o, isViteOptimizableEntry as p, matchesSharedSource as r, getCommonSharedSubpathFromNodeModulePath as s, findSharedKey as t, isAssetLikeImport as u };
192
+ export { stripViteFsPrefix as _, ensureTrailingSlash as a, getCommonSharedSubpaths as c, isNodeModulePath as d, isNuxtClientBase as f, stripQueryAndHash as g, resolvePublicPath as h, VITE_FS_PREFIX as i, getNodeModulesSuffix as l, normalizeNodeModulePath as m, invalidateSharedKeyMatcher as n, filterId as o, isViteOptimizableEntry as p, matchesSharedSource as r, getBasePath as s, findSharedKey as t, isAssetLikeImport as u };
@@ -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-Cx9WlTsx.js");
669
+ const { loadViaVmStrategy, isVmStrategyAvailable } = await import("./ssrVmStrategy-Ud06y3Xf.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-DiUzRVH1.js";
2
- import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-CMVCDSsG.js";
1
+ import { t as findSharedKey } from "./sharedKeyMatcher-BRzBCbuR.js";
2
+ import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-BUXUQi0P.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-CMVCDSsG.js";
1
+ import { i as ssrEntryLoaderPlugin, n as neutralizeBrowserPreloadHelpers, r as revalidate, t as SsrEntryHttpError } from "../ssrEntryLoader-BUXUQi0P.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.22.0",
3
+ "version": "1.22.1",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",