Files
medusa-store/packages/admin/admin-vite-plugin/src/babel.ts
Kasper Fabricius Kristensen 1ba2fadf22 feat(admin-bundler,admin-vite-plugin,medusa): Add support for loading Admin Extensions from plugins (#10869)
Should not be merged before https://github.com/medusajs/medusa/pull/10895

**What**
- Introduces a new `plugin` command to `admin-bundler`, currently not used anywhere but will be called from `medusa build:plugin`
- Discovers plugins with extensions and add passes the to `admin-vite-plugin`.
- Updates `admin-vite-plugin` so its able to read built admin extensions.

Resolves CMRC-830, CMRC-839
2025-01-13 10:45:33 +00:00

74 lines
1.4 KiB
TypeScript

import { parse, type ParseResult, type ParserOptions } from "@babel/parser"
import _traverse, { type NodePath } from "@babel/traverse"
import {
ExportDefaultDeclaration,
ExportNamedDeclaration,
File,
isArrayExpression,
isCallExpression,
isFunctionDeclaration,
isIdentifier,
isJSXElement,
isJSXFragment,
isMemberExpression,
isObjectExpression,
isObjectProperty,
isStringLiteral,
isTemplateLiteral,
isVariableDeclaration,
isVariableDeclarator,
Node,
ObjectExpression,
ObjectMethod,
ObjectProperty,
SpreadElement,
StringLiteral,
VariableDeclarator,
} from "@babel/types"
/**
* Depending on whether we are running the CJS or ESM build of the plugin, we
* need to import the default export of the `@babel/traverse` package in
* different ways.
*/
let traverse: typeof _traverse
if (typeof _traverse === "function") {
traverse = _traverse
} else {
traverse = (_traverse as any).default
}
export {
isArrayExpression,
isCallExpression,
isFunctionDeclaration,
isIdentifier,
isJSXElement,
isJSXFragment,
isMemberExpression,
isObjectExpression,
isObjectProperty,
isStringLiteral,
isTemplateLiteral,
isVariableDeclaration,
isVariableDeclarator,
parse,
traverse,
}
export type {
ExportDefaultDeclaration,
ExportNamedDeclaration,
File,
Node,
NodePath,
ObjectExpression,
ObjectMethod,
ObjectProperty,
ParseResult,
ParserOptions,
SpreadElement,
StringLiteral,
VariableDeclarator,
}