fix(vite-plugin-admin): Ensure UI Routes are HMR (#7982)
* fix(vite-plugin-admin): Ensure UI Routes are HMR * cleanup
This commit is contained in:
committed by
GitHub
parent
b24c8503d5
commit
50df3cea00
@@ -695,28 +695,17 @@ export const medusaVitePlugin: MedusaVitePlugin = (options) => {
|
||||
* We also need to reload all modules that import the route.
|
||||
*/
|
||||
if (!_extensionGraph.has(file)) {
|
||||
const moduleId = getVirtualId(file)
|
||||
const resolvedModuleId = resolveVirtualId(moduleId)
|
||||
const module = server?.moduleGraph.getModuleById(resolvedModuleId)
|
||||
if (module) {
|
||||
await server?.reloadModule(module)
|
||||
}
|
||||
}
|
||||
|
||||
if (_extensionGraph.has(file)) {
|
||||
const modules = _extensionGraph.get(file)
|
||||
|
||||
if (!modules) {
|
||||
return
|
||||
}
|
||||
|
||||
for (const moduleId of modules) {
|
||||
const module = server?.moduleGraph.getModuleById(moduleId)
|
||||
const imports = new Set<string>()
|
||||
|
||||
for (const resolvedModuleId of RESOLVED_ROUTE_MODULES) {
|
||||
const module = server?.moduleGraph.getModuleById(resolvedModuleId)
|
||||
if (module) {
|
||||
imports.add(resolvedModuleId)
|
||||
await server?.reloadModule(module)
|
||||
}
|
||||
}
|
||||
|
||||
_extensionGraph.set(file, imports)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +802,6 @@ export const medusaVitePlugin: MedusaVitePlugin = (options) => {
|
||||
async load(id) {
|
||||
if (RESOLVED_WIDGET_MODULES.includes(id)) {
|
||||
const zone = getWidgetZone(id)
|
||||
|
||||
return register(id, { type: "widget", get: zone })
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ import * as Collapsible from "@radix-ui/react-collapsible"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useStore } from "../../../hooks/api/store"
|
||||
import { settingsRouteRegex } from "../../../lib/extension-helpers"
|
||||
import { Divider } from "../../common/divider"
|
||||
import { Skeleton } from "../../common/skeleton"
|
||||
import { NavItem, NavItemProps } from "../../layout/nav-item"
|
||||
import { Shell } from "../../layout/shell"
|
||||
|
||||
import routes from "virtual:medusa/routes/links"
|
||||
import { settingsRouteRegex } from "../../../lib/extension-helpers"
|
||||
import { Divider } from "../../common/divider"
|
||||
|
||||
export const MainLayout = () => {
|
||||
return (
|
||||
@@ -173,9 +173,9 @@ const ExtensionRouteSection = () => {
|
||||
|
||||
const links = routes.links
|
||||
|
||||
const extensionLinks = links.filter(
|
||||
(link) => !settingsRouteRegex.test(link.path)
|
||||
)
|
||||
const extensionLinks = links
|
||||
.filter((link) => !settingsRouteRegex.test(link.path))
|
||||
.sort((a, b) => a.label.localeCompare(b.label))
|
||||
|
||||
if (!extensionLinks.length) {
|
||||
return null
|
||||
|
||||
@@ -262,7 +262,7 @@ export const PriceListDetailsForm = ({ form }: PriceListDetailsFormProps) => {
|
||||
<StackedFocusModal.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="bg-ui-bg-field shadow-borders-base txt-compact-small text-ui-fg-muted flex flex-1 items-center gap-x-2 rounded-md px-2 py-1.5"
|
||||
className="bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover shadow-borders-base txt-compact-small text-ui-fg-muted transition-fg focus-visible:shadow-borders-interactive-with-active flex flex-1 items-center gap-x-2 rounded-md px-2 py-1.5 outline-none"
|
||||
>
|
||||
<MagnifyingGlass />
|
||||
{t(
|
||||
|
||||
Reference in New Issue
Block a user