@medusajs/admin-vite-plugin
Advanced tools
Comparing version 0.0.2-snapshot-20240523143641 to 0.0.2-snapshot-20240523153451
@@ -283,3 +283,3 @@ "use strict"; | ||
} | ||
async function generateRouteEntrypoint(sources, type, base = "") { | ||
async function generateRouteEntrypoint(sources, type) { | ||
const files = (await Promise.all( | ||
@@ -307,3 +307,3 @@ Array.from(sources).map( | ||
${type}s: [${validatedRoutes.map((file, index) => { | ||
return type === "page" ? `{ path: "${createRoutePath(file)}", file: "${base + file}" }` : `{ path: "${createRoutePath(file)}", ...routeConfig${index} }`; | ||
return type === "page" ? `{ path: "${createRoutePath(file)}", Component: RouteExt${index} }` : `{ path: "${createRoutePath(file)}", ...routeConfig${index} }`; | ||
}).join(", ")}], | ||
@@ -318,3 +318,2 @@ }`; | ||
const _sources = new Set(options?.sources ?? []); | ||
let _base = ""; | ||
let server; | ||
@@ -328,3 +327,3 @@ let watcher; | ||
case "route": | ||
return await generateRouteEntrypoint(_sources, options2.get, _base); | ||
return await generateRouteEntrypoint(_sources, options2.get); | ||
default: | ||
@@ -379,2 +378,33 @@ return null; | ||
} | ||
if (_extensionGraph.has(file)) { | ||
const modules = _extensionGraph.get(file); | ||
if (!modules) { | ||
return; | ||
} | ||
for (const moduleId of modules) { | ||
const module2 = server?.moduleGraph.getModuleById(moduleId); | ||
if (!module2 || !module2.id) { | ||
continue; | ||
} | ||
const matchedInjectionZone = (0, import_admin_shared.getWidgetZone)(module2.id); | ||
if (!zoneValues.includes(matchedInjectionZone)) { | ||
modules.delete(moduleId); | ||
await server?.reloadModule(module2); | ||
} | ||
} | ||
const imports = new Set(modules); | ||
for (const zoneValue of zoneValues) { | ||
const zonePath = (0, import_admin_shared.getWidgetImport)(zoneValue); | ||
const moduleId = (0, import_admin_shared.getVirtualId)(zonePath); | ||
const resolvedModuleId = (0, import_admin_shared.resolveVirtualId)(moduleId); | ||
if (!modules.has(resolvedModuleId)) { | ||
const module2 = server?.moduleGraph.getModuleById(resolvedModuleId); | ||
if (module2) { | ||
imports.add(resolvedModuleId); | ||
await server?.reloadModule(module2); | ||
} | ||
} | ||
} | ||
_extensionGraph.set(file, imports); | ||
} | ||
} | ||
@@ -481,7 +511,2 @@ if (event === "add") { | ||
enforce: "pre", | ||
configResolved(config) { | ||
if (config.server?.middlewareMode) { | ||
_base = `${config.base}@fs`; | ||
} | ||
}, | ||
configureServer(_server) { | ||
@@ -488,0 +513,0 @@ server = _server; |
{ | ||
"name": "@medusajs/admin-vite-plugin", | ||
"version": "0.0.2-snapshot-20240523143641", | ||
"version": "0.0.2-snapshot-20240523153451", | ||
"main": "dist/index.js", | ||
@@ -36,3 +36,3 @@ "module": "dist/index.mjs", | ||
"@babel/traverse": "7.23.5", | ||
"@medusajs/admin-shared": "0.0.2-snapshot-20240523143641", | ||
"@medusajs/admin-shared": "0.0.2-snapshot-20240523153451", | ||
"chokidar": "3.5.3", | ||
@@ -39,0 +39,0 @@ "fdir": "6.1.1", |
Sorry, the diff of this file is not supported yet
37334
1084
+ Added@medusajs/admin-shared@0.0.2-snapshot-20240523153451(transitive)
- Removed@medusajs/admin-shared@0.0.2-snapshot-20240523143641(transitive)