Files
medusa-store/packages/medusa/package.json
Shahed Nasser 1ca3516a5c feat(deps,framework): add zod as framework dependency (#14441)
## Summary

**What** — What changes are introduced in this PR?

Export Zod as a dependency of `@medusajs/framework`.

Closes DX-2414

**Why** — Why are these changes relevant or necessary?  

Zod is an essential part of Medusa development. We use it in the core and developers use it in their customizations.

Developers using pnpm won't have access to Zod, as it's not a top-level dependency. While they can install any version, since Zod is an essential aspect of our framework, it's more convenient that we export it and make it accessible to developers.

**How** — How have these changes been implemented?

1. Add Zod as a dependency in `@medusajs/deps` and export it in `@medusajs/framework`
2. Change imports of Zod across projects to import from `@medusajs/framework` and remove the Zod dependency.

> Note: this change doesn't cover admin extensions (and our related packages), as they're not related to the Medusa framework and using Zod in them isn't part of the conventions we document.

Developers can import Zod like this now:

```ts
import { z } from "@medusajs/framework/zod"
```

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

Use the following import in a Medusa project to create an validate zod schemas:

```bash
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
import { z } from "@medusajs/framework/zod"

export const PostCustomSchema = z.object({
  name: z.string(),
})

type PostCustomSchema = z.infer<typeof PostCustomSchema>

export async function POST(
  req: MedusaRequest<PostCustomSchema>,
  res: MedusaResponse
) {
  res.json({
    message: `Hello, ${req.validatedBody.name}`
  })
}

// in middleware
import { defineMiddlewares, validateAndTransformBody } from "@medusajs/framework/http"
import { PostCustomSchema } from "./admin/custom/route"

export default defineMiddlewares({
  routes: [
    {
      matcher: "/custom",
      middlewares: [validateAndTransformBody(PostCustomSchema)],
    },
  ],
})
```

---

## Examples

-

---

## Checklist

Please ensure the following before requesting a review:

- [x] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [ ] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [x] I have linked the related issue(s) if applicable

---

## Additional Context

-
2026-01-09 13:20:01 +00:00

145 lines
4.5 KiB
JSON

{
"name": "@medusajs/medusa",
"version": "2.12.5",
"description": "Building blocks for digital commerce",
"main": "dist/index.js",
"exports": {
"./package.json": "./package.json",
".": "./dist/index.js",
"./types": "./dist/types/index.js",
"./utils": "./dist/utils/index.js",
"./api/*": "./dist/api/*.js",
"./subscribers/*": "./dist/subscribers/*.js",
"./jobs/*": "./dist/jobs/*.js",
"./core-flows": "./dist/core-flows/index.js",
"./loaders/*": "./dist/loaders/*.js",
"./commands/*": "./dist/commands/*.js",
"./feature-flags/*": "./dist/feature-flags/*.js",
"./*": "./dist/modules/*.js"
},
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa"
},
"publishConfig": {
"access": "public"
},
"files": [
"dist",
"oas",
"!dist/**/__tests__",
"!dist/**/__mocks__",
"!dist/**/__fixtures__"
],
"engines": {
"node": ">=20"
},
"author": "Sebastian Rindom",
"license": "MIT",
"homepage": "https://medusajs.com",
"llms": "https://docs.medusajs.com/llms.txt",
"llmsFull": "https://docs.medusajs.com/llms-full.txt",
"mcpServer": "https://docs.medusajs.com/mcp",
"scripts": {
"watch": "yarn run -T tsc --build --watch",
"build": "yarn run -T rimraf dist && yarn run -T tsc --build",
"serve": "node dist/app.js",
"test": "../../node_modules/.bin/jest --bail --forceExit --testPathIgnorePatterns='/integration-tests/' --testPathPattern=src",
"test:integration": "../../node_modules/.bin/jest --passWithNoTests --forceExit --testPathPattern=\"src/.*/integration-tests/__tests__/.*\\.ts\""
},
"devDependencies": {
"@medusajs/framework": "2.12.5"
},
"dependencies": {
"@inquirer/checkbox": "^2.3.11",
"@inquirer/input": "^2.2.9",
"@medusajs/admin-bundler": "2.12.5",
"@medusajs/analytics": "2.12.5",
"@medusajs/analytics-local": "2.12.5",
"@medusajs/analytics-posthog": "2.12.5",
"@medusajs/api-key": "2.12.5",
"@medusajs/auth": "2.12.5",
"@medusajs/auth-emailpass": "2.12.5",
"@medusajs/auth-github": "2.12.5",
"@medusajs/auth-google": "2.12.5",
"@medusajs/cache-inmemory": "2.12.5",
"@medusajs/cache-redis": "2.12.5",
"@medusajs/caching": "2.12.5",
"@medusajs/caching-redis": "2.12.5",
"@medusajs/cart": "2.12.5",
"@medusajs/core-flows": "2.12.5",
"@medusajs/currency": "2.12.5",
"@medusajs/customer": "2.12.5",
"@medusajs/draft-order": "2.12.5",
"@medusajs/event-bus-local": "2.12.5",
"@medusajs/event-bus-redis": "2.12.5",
"@medusajs/file": "2.12.5",
"@medusajs/file-local": "2.12.5",
"@medusajs/file-s3": "2.12.5",
"@medusajs/fulfillment": "2.12.5",
"@medusajs/fulfillment-manual": "2.12.5",
"@medusajs/index": "2.12.5",
"@medusajs/inventory": "2.12.5",
"@medusajs/link-modules": "2.12.5",
"@medusajs/locking": "2.12.5",
"@medusajs/locking-postgres": "2.12.5",
"@medusajs/locking-redis": "2.12.5",
"@medusajs/notification": "2.12.5",
"@medusajs/notification-local": "2.12.5",
"@medusajs/notification-sendgrid": "2.12.5",
"@medusajs/order": "2.12.5",
"@medusajs/payment": "2.12.5",
"@medusajs/payment-stripe": "2.12.5",
"@medusajs/pricing": "2.12.5",
"@medusajs/product": "2.12.5",
"@medusajs/promotion": "2.12.5",
"@medusajs/region": "2.12.5",
"@medusajs/sales-channel": "2.12.5",
"@medusajs/settings": "2.12.5",
"@medusajs/stock-location": "2.12.5",
"@medusajs/store": "2.12.5",
"@medusajs/tax": "2.12.5",
"@medusajs/telemetry": "2.12.5",
"@medusajs/translation": "2.12.5",
"@medusajs/user": "2.12.5",
"@medusajs/workflow-engine-inmemory": "2.12.5",
"@medusajs/workflow-engine-redis": "2.12.5",
"boxen": "^5.0.1",
"chalk": "^4.1.2",
"chokidar": "^4.0.3",
"compression": "^1.8.0",
"express": "^4.21.0",
"fs-exists-cached": "^1.0.0",
"jsonwebtoken": "^9.0.2",
"multer": "^2.0.2",
"node-schedule": "^2.1.1",
"qs": "^6.12.1",
"request-ip": "^3.3.0",
"slugify": "^1.6.6",
"uuid": "^9.0.0"
},
"peerDependencies": {
"@medusajs/framework": "2.12.5",
"@swc/core": "^1.7.28",
"posthog-node": "^5.11.0",
"react-dom": "^18.3.1",
"yalc": "^1.0.0-pre.53"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"posthog-node": {
"optional": true
},
"react-dom": {
"optional": true
},
"yalc": {
"optional": true
}
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e"
}