Skip to content

feat(media): move sanity-plugin-media to the plugins monorepo#978

Draft
stipsan wants to merge 536 commits into
mainfrom
cursor/migrate-sanity-plugin-media-7523
Draft

feat(media): move sanity-plugin-media to the plugins monorepo#978
stipsan wants to merge 536 commits into
mainfrom
cursor/migrate-sanity-plugin-media-7523

Conversation

@stipsan

@stipsan stipsan commented Jun 12, 2026

Copy link
Copy Markdown
Member

Moves sanity-plugin-media (v4.3.1) into the monorepo via git subtree add (full history preserved). Move-only, non-breaking: the goal of this PR is to relocate the plugin and ship a patch release (4.3.2) to verify it publishes from this repo. Bringing the code up to monorepo standards happens in follow-up PRs.

Demo

Manually verified in the test studio (kitchen-sink workspace): Media tool, asset metadata dialog, and the mediaField image picker with mediaTags pre-filtering, asset selection and auto-tagging.

media_plugin_demo_tool_and_asset_source.mp4

Image field picker pre-filtered by the product tag

What changed

  • Imported the full repo history via git subtree add (no generator, per maintainer direction)
  • Deleted standalone-repo tooling (.github/, eslint/prettier/husky/commitlint/semantic-release configs, LICENSE, package-lock.json); kept src/, README.md, CHANGELOG.md, the original tsconfigs/vitest configs, sanity.json + v2-incompatible.js (published files), scripts/migrate-to-localized-fields.ts (referenced by the README), and sanity.config.ts (reference for the test-studio setup)
  • Extended the root .gitignore with the entries only the plugin's gitignore covered (.vscode, .idea/*.iml, .yalc) before removing the plugin-level file
  • package.json: kept the original build toolchain (@sanity/pkg-utils@^7 + @sanity/plugin-kit, dual CJS/ESM output) and left dependencies, peerDependencies, engines, and files unchanged; only repository/homepage/bugs metadata, scripts (build, watch, prepack), and devDependencies changed (catalog: where available)
  • Verified package parity against the published 4.3.1 tarball: file lists are identical; manifest diffs are limited to metadata/scripts/devDependencies
  • Minimal dev-environment fixes (no behavior change):
    • phantom is-hotkey import switched to the declared is-hotkey-esm dependency (previously worked only via npm hoisting)
    • removed a @ts-expect-error that is unused against current Sanity types
    • disabled exactOptionalPropertyTypes (fresh dependency resolution surfaces violations the old standalone lockfile masked; type-check only)
    • root packageExtensions for @hookform/resolvers so its types resolve the dependent's zod v3 instead of the hidden-hoisted zod v4
    • vitest config: replaced the removed Vite esbuild option with its Vite 8 oxc equivalent (all 37 test files / 149 tests pass under the root vitest)
  • Excluded the plugin from oxlint and knip (oxfmt-only for now); formatted with oxfmt
  • Added a mediaExample (kitchen-sink workspace) modeled on the plugin's standalone dev studio config, exercising media() and mediaField with image + file fields
  • Added the plugin to the root README.md table and a patch changeset

Transfer verification

  • Trusted publishing configured: npm trust github sanity-plugin-media --file=release.yml --repository=sanity-io/plugins
  • package.json dependencies/peerDependencies/exports/engines/files verified unchanged against the published 4.3.1 package
  • Test studio example wired and manually verified (pnpm dev, see demo video)
  • pnpm format, pnpm knip, pnpm lint, pnpm build, pnpm test run all pass
  • Patch changeset added (move-only release to verify publishing from this repo)

Follow-up PRs (intentionally out of scope here)

  • Re-enable oxlint/knip for plugins/sanity-plugin-media and fix legacy lint/type issues (React Compiler rules, type-aware rules, re-enable exactOptionalPropertyTypes)
  • Align build toolchain with monorepo standards (@repo/package.config, @sanity/pkg-utils v10, React Compiler, ESM-only) as a major release
  • Move @sanity/plugin-kit into the repo (then drop the plugin-local devDependency)
  • Remove the reference sanity.config.ts from the plugin workspace once no longer needed

Maintainer follow-up

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

robinpyon and others added 30 commits February 24, 2021 12:04
Hey Robin 👋

`@sanity/base` is using `@sanity/ui: ^0.33.6`, which forces package managers to download two versions of the library when this plugin is installed. This is making studios throw an error `Cannot read property 'sanity' of undefined`. For more context, see sanity-io/sanity#2190

I'd suggest moving `@sanity/ui` and `styled-components` into `peerDependencies` as those are shipped with Sanity studio. This will make your plugin more resilient in the long run :)
Shastel and others added 21 commits December 4, 2025 15:54
…#267)

Co-authored-by: Cody Olsen <81981+stipsan@users.noreply.github.com>
* fix: allow sanity v5 as peer dependency

* fix(types): match client version, allow only image/file types - not video
…utils (#290)

* chore: setup vitest and test the main plugin actions, components and utils

* fix: lint issues

* fix: copilot pr comments

* fix: add generic error payload for notifications
* feat: add localization support to media plugin configuration and components

You can now enable localization support by passing a `locales` array to the plugin config
Adds the ability to automatically tag assets when they are uploaded through image field. This helps keep the media library organized without relying on users to manually tag assets.

When opening the Media Browser from a field with mediaTags configured, the browser now automatically filters to show only assets that have those tags, making it easier to find relevant assets.

---------

Co-authored-by: pedrobonamin <pedrobonamin@gmail.com>
…ddeb42718af90f382b8'

git-subtree-dir: plugins/sanity-plugin-media
git-subtree-mainline: 4226408
git-subtree-split: 5dc844b
- point repository/homepage/bugs metadata at sanity-io/plugins
- trim standalone-repo scripts and devDependencies; use catalog: where available
- keep pkg-utils v7 + plugin-kit build toolchain, dual CJS/ESM output,
  dependencies, peerDependencies, engines and files unchanged
- disable plugin-kit eslint/scripts checks that no longer apply in the monorepo
- disable exactOptionalPropertyTypes (fresh dep resolution surfaces violations
  the old standalone lockfile masked; type-check only)
- fix phantom 'is-hotkey' import to use the declared is-hotkey-esm dependency
- remove @ts-expect-error that is unused against current sanity types
- add zod packageExtension so @hookform/resolvers types resolve the
  dependent's zod v3 instead of the hidden-hoisted zod v4
…est 4 config

- oxlint and knip exclusion is temporary until the legacy code is brought up
  to monorepo standards in a follow-up PR
- replace the removed Vite 'esbuild' option with its Vite 8 'oxc' equivalent
  so JSX in component tests transforms again (all 149 tests pass)
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a2e7ee4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sanity-plugin-media Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Jun 12, 2026 3:12pm

Request Review

@stipsan stipsan added the 🤖 bot label Jun 12, 2026 — with Cursor
@socket-security

socket-security Bot commented Jun 12, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm get-it is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: pnpm-lock.yamlnpm/@sanity/plugin-kit@4.0.20npm/get-it@8.6.3

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/get-it@8.6.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm immer is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: pnpm-lock.yamlnpm/@reduxjs/toolkit@2.12.0npm/sanity@6.0.0npm/immer@11.1.8

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/immer@11.1.8. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm rrweb-cssom is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: pnpm-lock.yamlnpm/jsdom@25.0.1npm/rrweb-cssom@0.7.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/rrweb-cssom@0.7.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
License policy violation: npm typescript

License: LicenseRef-W3C-Community-Final-Specification-Agreement - The applicable license policy does not permit this license (5) (package/ThirdPartyNoticeText.txt)

From: plugins/sanity-plugin-media/package.jsonnpm/typescript@5.8.2

ℹ Read more on: This package | This alert | What is a license policy violation?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Find a package that does not violate your license policy or adjust your policy to allow this package's license.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/typescript@5.8.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

…-plugin-media-7523

# Conflicts:
#	pnpm-lock.yaml
…-plugin-media-7523

# Conflicts:
#	pnpm-lock.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.