sanity-io / sanity-plugin-mux-input

An input component that integrates Sanity Studio with MUX.com video encoding/hosting service.
https://mux.com
MIT License
45 stars 55 forks source link

Graphql deploy `matchMedia is not a function` #361

Closed homerjam closed 2 months ago

homerjam commented 2 months ago

Describe the bug

Cannot deploy graphql when using mux input

To Reproduce

Steps to reproduce the behavior:

  1. Add mux input to plugins in sanity config
    
    ...
    import {muxInput} from 'sanity-plugin-mux-input'

export default defineConfig({ ... plugins: [structureTool(), visionTool(), muxInput()], ... })

2. Run `sanity graphql deploy`

**Expected behavior**

The graphql api should be deployed

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Which versions of Sanity are you using?**

@sanity/cli (global) 3.39.1 (up to date) @sanity/eslint-config-studio 4.0.0 (up to date) @sanity/vision 3.39.1 (up to date) sanity 3.39.1 (up to date)


**What operating system are you using?**

Mac OS 14.4.1

**Which versions of Node.js / npm are you running?**

10.2.3 v18.19.0


**Additional context**

TypeError: Failed to load configuration file "/Users/jameshomer/Projects/abc/src/lib/sanity/sanity.config.ts": l.matchMedia is not a function at el (~/Projects/abc/node_modules/.pnpm/@mux+mux-player@2.5.0/node_modules/@mux/mux-player/dist/index.cjs.js:145:8374) at Object. (~/Projects/abc/node_modules/.pnpm/@mux+mux-player@2.5.0/node_modules/@mux/mux-player/dist/index.cjs.js:145:8586) at Object.newLoader [as .js] (~/Projects/abc/src/lib/sanity/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js:2262:9) at extensions..js (~/Projects/abc/src/lib/sanity/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js:4838:24)  ELIFECYCLE  Command failed with exit code 1.



**Security issue?**

Any security issues should be submitted directly to [security@sanity.io](mailto:security@sanity.io). In order to determine whether you are dealing with a security issue, ask yourself these two questions:

- Can I access something that's not mine, or something I shouldn't have access to?
- Can I disable something for other people? If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just email us at [security@sanity.io](mailto:security@sanity.io.
sgulseth commented 2 months ago

Hi! Can you test with the latest release? https://github.com/sanity-io/sanity/releases/tag/v3.40.0

homerjam commented 2 months ago

Works, thanks!

Could you tell me what was the fix - just curious : )

sgulseth commented 2 months ago

We had to mock matchMedia when loading the schema since it's a browser land method not available in the cli 🙂

https://github.com/sanity-io/sanity/pull/6472