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:
@@ -695,28 +695,17 @@ export const medusaVitePlugin: MedusaVitePlugin = (options) => {
|
|||||||
* We also need to reload all modules that import the route.
|
* We also need to reload all modules that import the route.
|
||||||
*/
|
*/
|
||||||
if (!_extensionGraph.has(file)) {
|
if (!_extensionGraph.has(file)) {
|
||||||
const moduleId = getVirtualId(file)
|
const imports = new Set<string>()
|
||||||
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)
|
|
||||||
|
|
||||||
|
for (const resolvedModuleId of RESOLVED_ROUTE_MODULES) {
|
||||||
|
const module = server?.moduleGraph.getModuleById(resolvedModuleId)
|
||||||
if (module) {
|
if (module) {
|
||||||
|
imports.add(resolvedModuleId)
|
||||||
await server?.reloadModule(module)
|
await server?.reloadModule(module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_extensionGraph.set(file, imports)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +802,6 @@ export const medusaVitePlugin: MedusaVitePlugin = (options) => {
|
|||||||
async load(id) {
|
async load(id) {
|
||||||
if (RESOLVED_WIDGET_MODULES.includes(id)) {
|
if (RESOLVED_WIDGET_MODULES.includes(id)) {
|
||||||
const zone = getWidgetZone(id)
|
const zone = getWidgetZone(id)
|
||||||
|
|
||||||
return register(id, { type: "widget", get: zone })
|
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 { useTranslation } from "react-i18next"
|
||||||
|
|
||||||
import { useStore } from "../../../hooks/api/store"
|
import { useStore } from "../../../hooks/api/store"
|
||||||
|
import { settingsRouteRegex } from "../../../lib/extension-helpers"
|
||||||
|
import { Divider } from "../../common/divider"
|
||||||
import { Skeleton } from "../../common/skeleton"
|
import { Skeleton } from "../../common/skeleton"
|
||||||
import { NavItem, NavItemProps } from "../../layout/nav-item"
|
import { NavItem, NavItemProps } from "../../layout/nav-item"
|
||||||
import { Shell } from "../../layout/shell"
|
import { Shell } from "../../layout/shell"
|
||||||
|
|
||||||
import routes from "virtual:medusa/routes/links"
|
import routes from "virtual:medusa/routes/links"
|
||||||
import { settingsRouteRegex } from "../../../lib/extension-helpers"
|
|
||||||
import { Divider } from "../../common/divider"
|
|
||||||
|
|
||||||
export const MainLayout = () => {
|
export const MainLayout = () => {
|
||||||
return (
|
return (
|
||||||
@@ -173,9 +173,9 @@ const ExtensionRouteSection = () => {
|
|||||||
|
|
||||||
const links = routes.links
|
const links = routes.links
|
||||||
|
|
||||||
const extensionLinks = links.filter(
|
const extensionLinks = links
|
||||||
(link) => !settingsRouteRegex.test(link.path)
|
.filter((link) => !settingsRouteRegex.test(link.path))
|
||||||
)
|
.sort((a, b) => a.label.localeCompare(b.label))
|
||||||
|
|
||||||
if (!extensionLinks.length) {
|
if (!extensionLinks.length) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
+1
-1
@@ -262,7 +262,7 @@ export const PriceListDetailsForm = ({ form }: PriceListDetailsFormProps) => {
|
|||||||
<StackedFocusModal.Trigger asChild>
|
<StackedFocusModal.Trigger asChild>
|
||||||
<button
|
<button
|
||||||
type="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 />
|
<MagnifyingGlass />
|
||||||
{t(
|
{t(
|
||||||
|
|||||||
Reference in New Issue
Block a user