www/apps/resources/app/lint/rules/admin-no-medusa-utils-import/page.mdx
export const metadata = {
title: admin-no-medusa-utils-import - ESLint plugin rules,
}
This rule disallows importing Node-only modules from the Medusa Framework (@medusajs/framework/utils, @medusajs/framework/http, and @medusajs/framework/workflows-sdk) in admin code, since they break the browser bundle.
error. This rule is enabled in the recommended preset.
This rule targets files in your project's src/admin directory. It reports an import or re-export of a Node-only module from the Medusa Framework.
The following code is reported by the rule:
import { MedusaError } from "@medusajs/framework/utils"
Instead, move the logic to the server and call it from the admin via the JS SDK:
import { sdk } from "../lib/sdk"
The admin dashboard is a browser bundle. Importing Node-only modules breaks the admin build or ships server-only code to the client.
Learn more in the Admin Development documentation.
This rule isn't auto-fixable.