The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
chore: v2.0.0-canary.74
vholik61d8cfd7d73b
diff --git a/bun.lock b/bun.lockindex 9a8eb5ed7..1c87d67ac 100644--- a/bun.lock+++ b/bun.lock@@ -38,7 +38,7 @@},"packages/admin": {"name": "@mercurjs/admin",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {"@ariakit/react": "^0.4.15","@babel/runtime": "^7.26.10",@@ -98,7 +98,7 @@},"packages/cli": {"name": "@mercurjs/cli",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","bin": {"mercurjs": "./dist/index.js",},@@ -137,7 +137,7 @@},"packages/client": {"name": "@mercurjs/client",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {"@tanstack/react-query": "^5.64.2","qs": "^6.12.1",@@ -154,7 +154,7 @@},"packages/core-plugin": {"name": "@mercurjs/core-plugin",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","devDependencies": {"@medusajs/cli": "^2.13.3","@medusajs/core-flows": "^2.13.3",@@ -195,9 +195,11 @@},"packages/dashboard-sdk": {"name": "@mercurjs/dashboard-sdk",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {- "esbuild-register": "^3.6.0",+ "@babel/parser": "7.25.6",+ "@babel/traverse": "7.25.6",+ "@babel/types": "7.25.6",},"devDependencies": {"@types/node": "^22.0.0",@@ -209,7 +211,7 @@},"packages/dashboard-shared": {"name": "@mercurjs/dashboard-shared",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {"@ariakit/react": "^0.4.15","@babel/runtime": "^7.26.10",@@ -301,7 +303,7 @@},"packages/types": {"name": "@mercurjs/types",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {"@medusajs/types": "2.13.3",},@@ -311,7 +313,7 @@},"packages/vendor": {"name": "@mercurjs/vendor",- "version": "2.0.0-canary.71",+ "version": "2.0.0-canary.73","dependencies": {"@ariakit/react": "^0.4.15","@babel/runtime": "^7.26.10",diff --git a/packages/admin/package.json b/packages/admin/package.jsonindex 8c28ebebb..e73b85853 100644--- a/packages/admin/package.json+++ b/packages/admin/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/admin",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 9c4f1d158..4a071510d 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/cli",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/client/package.json b/packages/client/package.jsonindex a5a7094a6..cece4f735 100644--- a/packages/client/package.json+++ b/packages/client/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/client",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/core-plugin/package.json b/packages/core-plugin/package.jsonindex 455a6dd87..ad6f48c36 100644--- a/packages/core-plugin/package.json+++ b/packages/core-plugin/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/core-plugin",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/dashboard-sdk/package.json b/packages/dashboard-sdk/package.jsonindex 8d06f2b73..6ab02ff6f 100644--- a/packages/dashboard-sdk/package.json+++ b/packages/dashboard-sdk/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/dashboard-sdk",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",@@ -12,8 +12,8 @@"exports": {".": {"types": "./dist/index.d.ts",- "require": "./dist/index.cjs",- "default": "./dist/index.cjs"+ "import": "./dist/index.js",+ "require": "./dist/index.cjs"}},"files": [@@ -25,7 +25,9 @@"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"},"dependencies": {- "esbuild-register": "^3.6.0"+ "@babel/parser": "7.25.6",+ "@babel/traverse": "7.25.6",+ "@babel/types": "7.25.6"},"devDependencies": {"@types/node": "^22.0.0",diff --git a/packages/dashboard-sdk/src/babel.ts b/packages/dashboard-sdk/src/babel.tsnew file mode 100644index 000000000..d6977d020--- /dev/null+++ b/packages/dashboard-sdk/src/babel.ts@@ -0,0 +1,40 @@+import { parse } from "@babel/parser"+import _traverse from "@babel/traverse"+import {+ isBooleanLiteral,+ isCallExpression,+ isFunctionDeclaration,+ isIdentifier,+ isMemberExpression,+ isNumericLiteral,+ isObjectExpression,+ isObjectProperty,+ isStringLiteral,+ isVariableDeclaration,+ isVariableDeclarator,+ isArrayExpression,+} from "@babel/types"++let traverse: typeof _traverse+if (typeof _traverse === "function") {+ traverse = _traverse+} else {+ traverse = (_traverse as any).default+}++export {+ parse,+ traverse,+ isBooleanLiteral,+ isCallExpression,+ isFunctionDeclaration,+ isIdentifier,+ isMemberExpression,+ isNumericLiteral,+ isObjectExpression,+ isObjectProperty,+ isStringLiteral,+ isVariableDeclaration,+ isVariableDeclarator,+ isArrayExpression,+}diff --git a/packages/dashboard-sdk/src/menu-items.ts b/packages/dashboard-sdk/src/menu-items.tsindex 362a74afb..8c60d6dbe 100644--- a/packages/dashboard-sdk/src/menu-items.ts+++ b/packages/dashboard-sdk/src/menu-items.ts@@ -1,7 +1,19 @@import fs from "fs"import path from "path"import { VALID_FILE_EXTENSIONS } from "./constants"-import { normalizePath } from "./utils"+import { normalizePath, getParserOptions } from "./utils"+import {+ parse,+ traverse,+ isIdentifier,+ isNumericLiteral,+ isObjectProperty,+ isStringLiteral,+ isVariableDeclaration,+ isVariableDeclarator,+ isCallExpression,+ isObjectExpression,+} from "./babel"import type { BuiltMercurConfig } from "./types"type MenuItemConfig = {@@ -72,41 +84,120 @@ function getRoute(file: string, pagesDir: string): string {) || "/"}-function hasConfigExport(filePath: string): boolean {- try {- const content = fs.readFileSync(filePath, "utf-8")- return (- /export\s+(const|let|var)\s+config\b/.test(content) ||- /export\s*\{[^}]*\bconfig\b[^}]*\}/.test(content)+function getConfigObjectProperties(+ path: any+): any[] | null {+ if (isVariableDeclarator(path.node)) {+ const decl = isIdentifier(path.node.id, { name: "config" }) ? path.node : null+ if (!decl) return null++ if (+ isCallExpression(decl.init) &&+ decl.init.arguments.length > 0 &&+ isObjectExpression(decl.init.arguments[0])+ ) {+ return decl.init.arguments[0].properties+ }+ if (isObjectExpression(decl.init)) {+ return decl.init.properties+ }+ return null+ }++ const declaration = path.node.declaration+ if (isVariableDeclaration(declaration)) {+ const configDecl = declaration.declarations.find(+ (d: any) => isVariableDeclarator(d) && isIdentifier(d.id, { name: "config" }))- } catch {- return false+ if (+ configDecl &&+ isCallExpression(configDecl.init) &&+ configDecl.init.arguments.length > 0 &&+ isObjectExpression(configDecl.init.arguments[0])+ ) {+ return configDecl.init.arguments[0].properties+ }++ // Also handle direct object expression (no wrapper call)+ const directDecl = declaration.declarations.find(+ (d: any) => isVariableDeclarator(d) && isIdentifier(d.id, { name: "config" })+ )+ if (directDecl && isObjectExpression(directDecl.init)) {+ return directDecl.init.properties+ }}++ return null}-function getConfigProperties(filePath: string): MenuItemConfig | null {- try {- const content = fs.readFileSync(filePath, "utf-8")+function processConfigProperties(+ properties: any[]+): MenuItemConfig | null {+ const hasProperty = (name: string) =>+ properties.some(+ (prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name })+ )- const hasLabel =- /\blabel\s*[:=]/.test(content)+ const hasLabel = hasProperty("label")+ if (!hasLabel) {+ return null+ }- if (!hasLabel) {- return null- }+ const hasIcon = hasProperty("icon")- const hasIcon = /\bicon\s*[:=]/.test(content)+ const nested = properties.find(+ (prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "nested" })+ )+ let nestedValue: string | undefined+ if (nested && isObjectProperty(nested) && isStringLiteral(nested.value)) {+ nestedValue = nested.value.value+ }- const rankMatch = content.match(/\brank\s*:\s*(\d+)/)- const rank = rankMatch ? parseInt(rankMatch[1], 10) : undefined+ const translationNs = properties.find(+ (prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "translationNs" })+ )+ let translationNsValue: string | undefined+ if (translationNs && isObjectProperty(translationNs) && isStringLiteral(translationNs.value)) {+ translationNsValue = translationNs.value.value+ }- const nestedMatch = content.match(/\bnested\s*:\s*["']([^"']+)["']/)- const nested = nestedMatch ? nestedMatch[1] : undefined+ const rank = properties.find(+ (prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "rank" })+ )+ let rankValue: number | undefined+ if (rank && isObjectProperty(rank) && isNumericLiteral(rank.value)) {+ rankValue = rank.value.value+ }- const translationNsMatch = content.match(/\btranslationNs\s*:\s*["']([^"']+)["']/)- const translationNs = translationNsMatch ? translationNsMatch[1] : undefined+ return { label: hasLabel, icon: hasIcon, rank: rankValue, nested: nestedValue, translationNs: translationNsValue }+}- return { label: hasLabel, icon: hasIcon, rank, nested, translationNs }+function getRouteConfig(file: string): MenuItemConfig | null {+ try {+ const code = fs.readFileSync(file, "utf-8")+ const ast = parse(code, getParserOptions(file))++ let config: MenuItemConfig | null = null+ let configFound = false++ traverse(ast, {+ VariableDeclarator(path: any) {+ if (configFound) return+ const properties = getConfigObjectProperties(path)+ if (!properties) return+ config = processConfigProperties(properties)+ if (config) configFound = true+ },+ ExportNamedDeclaration(path: any) {+ if (configFound) return+ const properties = getConfigObjectProperties(path)+ if (!properties) return+ config = processConfigProperties(properties)+ if (config) configFound = true+ },+ })++ return config} catch {return null}@@ -157,11 +248,7 @@ function parseFile(pagesDir: string,index: number): MenuItemResult | null {- if (!hasConfigExport(file)) {- return null- }-- const config = getConfigProperties(file)+ const config = getRouteConfig(file)if (!config) {return null}diff --git a/packages/dashboard-sdk/src/plugin.ts b/packages/dashboard-sdk/src/plugin.tsindex 740f00245..dd983f2b8 100644--- a/packages/dashboard-sdk/src/plugin.ts+++ b/packages/dashboard-sdk/src/plugin.ts@@ -1,7 +1,18 @@import type * as Vite from "vite"import path from "path"import fs from "fs"-import { getFileExports } from "./utils"+import { getParserOptions } from "./utils"+import {+ parse,+ traverse,+ isIdentifier,+ isCallExpression,+ isObjectExpression,+ isObjectProperty,+ isStringLiteral,+ isArrayExpression,+ isMemberExpression,+} from "./babel"import { RESOLVED_ROUTES_MODULE } from "./constants"import { isVirtualModule, resolveVirtualModule, loadVirtualModule } from "./virtual-modules"import type { MercurConfig, BuiltMercurConfig } from "./types"@@ -81,29 +92,150 @@ function resolvePluginExtensions(return extensions}+function extractStringFromNode(node: any, configDir: string): string | null {+ if (isStringLiteral(node)) {+ return node.value+ }++ // Handle path.join(__dirname, 'relative') or path.resolve(__dirname, 'relative')+ if (+ isCallExpression(node) &&+ isMemberExpression(node.callee) &&+ isIdentifier(node.callee.object, { name: "path" }) &&+ isIdentifier(node.callee.property) &&+ (node.callee.property.name === "join" || node.callee.property.name === "resolve")+ ) {+ const args = node.arguments+ if (args.length >= 2 && isIdentifier(args[0], { name: "__dirname" })) {+ const parts = args.slice(1)+ .filter((a: any) => isStringLiteral(a))+ .map((a: any) => a.value)+ if (parts.length > 0) {+ return path.resolve(configDir, ...parts)+ }+ }+ }++ return null+}++function extractObjectProperties(node: any): any[] | null {+ if (isObjectExpression(node)) {+ return node.properties+ }+ return null+}+async function loadMedusaConfig(medusaConfigPath: string, root: string): Promise<{ base?: string; pluginExtensions: string[] }> {try {- const mod = await getFileExports(medusaConfigPath)- const medusaConfig = mod.default ?? mod-- const modules = medusaConfig?.modules ?? {}+ const code = fs.readFileSync(medusaConfigPath, "utf-8")+ const ast = parse(code, getParserOptions(medusaConfigPath))const configDir = path.dirname(medusaConfigPath)+ const result: { properties: any[] | null } = { properties: null }++ traverse(ast, {+ // Handle: export default defineConfig({ ... })+ ExportDefaultDeclaration(nodePath: any) {+ const decl = nodePath.node.declaration+ if (isCallExpression(decl) && decl.arguments.length > 0) {+ result.properties = extractObjectProperties(decl.arguments[0])+ }+ },+ // Handle: module.exports = defineConfig({ ... }) or module.exports = { ... }+ AssignmentExpression(nodePath: any) {+ const left = nodePath.node.left+ if (+ isMemberExpression(left) &&+ isIdentifier(left.object, { name: "module" }) &&+ isIdentifier(left.property, { name: "exports" })+ ) {+ const right = nodePath.node.right+ if (isCallExpression(right) && right.arguments.length > 0) {+ result.properties = extractObjectProperties(right.arguments[0])+ } else if (isObjectExpression(right)) {+ result.properties = right.properties as any[]+ }+ }+ },+ })++ const configObjectProperties = result.properties++ if (!configObjectProperties) {+ return { pluginExtensions: [] }+ }+let base: string | undefined- for (const key of UI_MODULE_KEYS) {- const value = modules[key]- if (!value || typeof value !== "object" || !value.options?.appDir) continue+ // Extract modules+ const modulesProp = configObjectProperties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "modules" })+ )++ if (modulesProp && isObjectProperty(modulesProp) && isObjectExpression(modulesProp.value)) {+ for (const key of UI_MODULE_KEYS) {+ const uiProp = modulesProp.value.properties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: key })+ )++ if (!uiProp || !isObjectProperty(uiProp) || !isObjectExpression(uiProp.value)) continue++ const optionsProp = uiProp.value.properties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "options" })+ )++ if (!optionsProp || !isObjectProperty(optionsProp) || !isObjectExpression(optionsProp.value)) continue++ const appDirProp = optionsProp.value.properties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "appDir" })+ )++ if (!appDirProp || !isObjectProperty(appDirProp)) continue++ const appDir = extractStringFromNode(appDirProp.value, configDir)+ if (!appDir) continue- const appDir = path.resolve(configDir, value.options.appDir)+ const resolvedAppDir = path.isAbsolute(appDir)+ ? appDir+ : path.resolve(configDir, appDir)- if (appDir === root) {- base = value.options.path- break+ if (resolvedAppDir === root) {+ const pathProp = optionsProp.value.properties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "path" })+ )++ if (pathProp && isObjectProperty(pathProp) && isStringLiteral(pathProp.value)) {+ base = pathProp.value.value+ }+ break+ }+ }+ }++ // Extract plugins+ const plugins: any[] = []+ const pluginsProp = configObjectProperties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "plugins" })+ )++ if (pluginsProp && isObjectProperty(pluginsProp) && isArrayExpression(pluginsProp.value)) {+ for (const element of pluginsProp.value.elements) {+ if (!element) continue++ if (isObjectExpression(element)) {+ const resolveProp = element.properties.find(+ (p: any) => isObjectProperty(p) && isIdentifier(p.key, { name: "resolve" })+ )+ if (resolveProp && isObjectProperty(resolveProp) && isStringLiteral(resolveProp.value)) {+ plugins.push({ resolve: resolveProp.value.value })+ }+ } else if (isStringLiteral(element)) {+ plugins.push({ resolve: element.value })+ }}}- const plugins = medusaConfig?.plugins ?? []const pluginExtensions = resolvePluginExtensions(plugins, configDir)return { base, pluginExtensions }diff --git a/packages/dashboard-sdk/src/routes.ts b/packages/dashboard-sdk/src/routes.tsindex e5b0c9a7e..c31119444 100644--- a/packages/dashboard-sdk/src/routes.ts+++ b/packages/dashboard-sdk/src/routes.ts@@ -1,7 +1,16 @@import fs from "fs"import path from "path"import { VALID_FILE_EXTENSIONS } from "./constants"-import { normalizePath } from "./utils"+import { normalizePath, getParserOptions, hasDefaultExport } from "./utils"+import {+ parse,+ traverse,+ isBooleanLiteral,+ isIdentifier,+ isObjectProperty,+ isVariableDeclaration,+ isVariableDeclarator,+} from "./babel"import type { BuiltMercurConfig } from "./types"type Route = {@@ -65,43 +74,67 @@ function crawlPages(dir: string, pattern = "page"): string[] {return files}-function hasDefaultExport(filePath: string): boolean {- try {- const content = fs.readFileSync(filePath, "utf-8")- return (- /export\s+default\s+/.test(content) ||- /export\s*\{\s*[^}]*\s+as\s+default\s*[,}]/.test(content)- )- } catch {- return false- }-}+function hasConfigPublic(ast: any): boolean {+ let found = false++ traverse(ast, {+ ExportNamedDeclaration(path: any) {+ const declaration = path.node.declaration+ if (!isVariableDeclaration(declaration)) return++ for (const decl of declaration.declarations) {+ if (+ isVariableDeclarator(decl) &&+ isIdentifier(decl.id, { name: "config" }) &&+ decl.init?.type === "ObjectExpression"+ ) {+ const publicProp = decl.init.properties.find(+ (prop) =>+ isObjectProperty(prop) &&+ isIdentifier(prop.key, { name: "public" }) &&+ isBooleanLiteral(prop.value, { value: true })+ )+ if (publicProp) {+ found = true+ }+ }+ }+ },+ })-function hasConfigPublic(filePath: string): boolean {- try {- const content = fs.readFileSync(filePath, "utf-8")- return /export\s+const\s+config\s*=\s*\{[^}]*public\s*:\s*true/.test(content)- } catch {- return false- }+ return found}-function getNamedExports(filePath: string): { hasHandle: boolean; hasLoader: boolean } {- try {- const content = fs.readFileSync(filePath, "utf-8")+function getNamedExports(ast: any): { hasHandle: boolean; hasLoader: boolean } {+ let hasHandle = false+ let hasLoader = false++ traverse(ast, {+ ExportNamedDeclaration(path: any) {+ const declaration = path.node.declaration++ if (declaration?.type === "VariableDeclaration") {+ declaration.declarations.forEach((decl: any) => {+ if (decl.id.type === "Identifier" && decl.id.name === "handle") {+ hasHandle = true+ }+ if (decl.id.type === "Identifier" && decl.id.name === "loader") {+ hasLoader = true+ }+ })+ }- const hasHandle =- /export\s+(const|function|async\s+function)\s+handle\b/.test(content) ||- /export\s*\{[^}]*\bhandle\b[^}]*\}/.test(content)+ if (declaration?.type === "FunctionDeclaration" && declaration.id?.name === "loader") {+ hasLoader = true+ }- const hasLoader =- /export\s+(const|function|async\s+function)\s+loader\b/.test(content) ||- /export\s*\{[^}]*\bloader\b[^}]*\}/.test(content)+ if (declaration?.type === "FunctionDeclaration" && declaration.id?.name === "handle") {+ hasHandle = true+ }+ },+ })- return { hasHandle, hasLoader }- } catch {- return { hasHandle: false, hasLoader: false }- }+ return { hasHandle, hasLoader }}function generateRouteComponentName(index: number): string {@@ -187,20 +220,27 @@ function formatRoute(route: Route, indent: string = " "): string {}function parseFile(file: string, pagesDir: string, index: number): RouteResult | null {- if (!hasDefaultExport(file)) {- return null- }+ try {+ const code = fs.readFileSync(file, "utf-8")+ const ast = parse(code, getParserOptions(file))- const { hasHandle, hasLoader } = getNamedExports(file)- const isPublic = hasConfigPublic(file)- const routePath = getRoute(file, pagesDir)+ if (!hasDefaultExport(ast)) {+ return null+ }- const imports = generateImports(file, index, hasHandle, hasLoader)- const route = generateRouteObject(routePath, index, hasHandle, hasLoader, isPublic)+ const { hasHandle, hasLoader } = getNamedExports(ast)+ const isPublic = hasConfigPublic(ast)+ const routePath = getRoute(file, pagesDir)- return {- imports,- route,+ const imports = generateImports(file, index, hasHandle, hasLoader)+ const route = generateRouteObject(routePath, index, hasHandle, hasLoader, isPublic)++ return {+ imports,+ route,+ }+ } catch {+ return null}}@@ -220,7 +260,7 @@ function buildRouteTree(results: RouteResult[]): RouteResult[] {const parent = routeMap.get(parentPath)if (parent) {- parent.route.children = parent.route.children || []+ parent.route.children = parent.route.children ?? []parent.route.children.push({...result.route,path: result.route.path.replace("/@", "/"),diff --git a/packages/dashboard-sdk/src/utils.ts b/packages/dashboard-sdk/src/utils.tsindex bd675f97d..2df9708f7 100644--- a/packages/dashboard-sdk/src/utils.ts+++ b/packages/dashboard-sdk/src/utils.ts@@ -1,39 +1,56 @@-export function resolveExports(moduleExports: any) {- if (- "default" in moduleExports &&- moduleExports.default &&- "default" in moduleExports.default- ) {- return resolveExports(moduleExports.default)- }- return moduleExports-}--export async function getFileExports(path: string): Promise<any> {- const { unregister } = await safeRegister()- const module = require(path)- unregister()+import type { ParserOptions } from "@babel/parser"+import { traverse } from "./babel"- return resolveExports(module)+export function normalizePath(filePath: string): string {+ return filePath.replace(/\\/g, "/")}-export const safeRegister = async () => {- const { register } = await import("esbuild-register/dist/node")- let res: { unregister: () => void }- try {- res = register({- format: "cjs",- loader: "ts",- })- } catch {- res = {- unregister: () => {},- }+export function getParserOptions(file: string): ParserOptions {+ const options: ParserOptions = {+ sourceType: "module",+ plugins: ["jsx"],}- return res+ if (file.endsWith(".ts") || file.endsWith(".tsx")) {+ options.plugins!.push("typescript")+ }++ return options}-export function normalizePath(filePath: string): string {- return filePath.replace(/\\/g, "/")+// eslint-disable-next-line @typescript-eslint/no-explicit-any+export function hasDefaultExport(ast: any): boolean {+ let found = false++ traverse(ast, {+ ExportDefaultDeclaration() {+ found = true+ },+ AssignmentExpression(path: any) {+ if (+ path.node.left.type === "MemberExpression" &&+ path.node.left.object.type === "Identifier" &&+ path.node.left.object.name === "exports" &&+ path.node.left.property.type === "Identifier" &&+ path.node.left.property.name === "default"+ ) {+ found = true+ }+ },+ ExportNamedDeclaration(path: any) {+ const specifiers = path.node.specifiers+ if (+ specifiers?.some(+ (s: any) =>+ s.type === "ExportSpecifier" &&+ s.exported.type === "Identifier" &&+ s.exported.name === "default"+ )+ ) {+ found = true+ }+ },+ })++ return found}diff --git a/packages/dashboard-sdk/tsup.config.ts b/packages/dashboard-sdk/tsup.config.tsindex fe906dca6..acf36670d 100644--- a/packages/dashboard-sdk/tsup.config.ts+++ b/packages/dashboard-sdk/tsup.config.ts@@ -2,7 +2,7 @@ import { defineConfig } from "tsup"export default defineConfig({entry: ["src/index.ts"],- format: ["cjs"],+ format: ["cjs", "esm"],dts: true,clean: true,})diff --git a/packages/dashboard-shared/package.json b/packages/dashboard-shared/package.jsonindex b4d718452..c328ff8a3 100644--- a/packages/dashboard-shared/package.json+++ b/packages/dashboard-shared/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/dashboard-shared",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/types/package.json b/packages/types/package.jsonindex 1c145e956..e2a14da4c 100644--- a/packages/types/package.json+++ b/packages/types/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/types",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/vendor/package.json b/packages/vendor/package.jsonindex 4d5382489..e54cfdca2 100644--- a/packages/vendor/package.json+++ b/packages/vendor/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/vendor",- "version": "2.0.0-canary.73",+ "version": "2.0.0-canary.74","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",