When running the README.md quick run steps, the package.json doesn't seem to be properly configured.
# Initialize a new plugin (outside of your Sanity studio folder)
npx @sanity/plugin-kit init sanity-plugin-testing-it-out
# Make your plugin linkable, and compile an initial version
cd sanity-plugin-testing-it-out
npm run link-watch
npm run link-watch produces
[error] `type` in `./package.json` must be of type 'commonjs' | 'module' (received undefined)
To fix this
- The plugin template package.json needs
"type": "module" added
-
"exports": {
".": {
"types": "./lib/src/index.d.ts",
"source": "./src/index.ts",
"import": "./lib/index.esm.js",
"require": "./lib/index.js", // Update to .cjs
"default": "./lib/index.esm.js"
},
"main": "./lib/index.js", //update to .cjs