plugin-kit
plugin-kit copied to clipboard
Fresh install doesn't work
I have tried multiple times using npx @sanity/plugin-kit init pluginname
, following the wizard, and then when running yarn build
it instantly fails (see screenshot below)
All your plugin docs suggest using this but it doesn't work out of the box, so its not a great starting point! Please could someone take a look?
@EmilyYond I believe I ran into the same issue as you here. I was able to resolve this quickly by rolling back @sanity/pkg-utils
to version 5.1.0.
More context
I generated fresh plugin files from the command:
npx @sanity/plugin-kit init sanity-plugin-name
Output:
dependencies:
+ @sanity/incompatible-plugin 1.0.4
devDependencies:
+ @sanity/pkg-utils 5.1.4
+ @sanity/plugin-kit 3.1.10
+ @types/react 18.2.70
+ @typescript-eslint/eslint-plugin 7.3.1
+ @typescript-eslint/parser 7.3.1
+ eslint 8.57.0
+ eslint-config-prettier 9.1.0
+ eslint-config-sanity 7.1.2
+ eslint-plugin-prettier 5.1.3
+ eslint-plugin-react 7.34.1
+ eslint-plugin-react-hooks 4.6.0
+ npm-run-all 4.1.5
+ prettier 3.2.5
+ prettier-plugin-packagejson 2.4.12
+ react 18.2.0
+ react-dom 18.2.0
+ react-is 18.2.0
+ rimraf 5.0.5
+ sanity 3.35.2
+ styled-components 5.3.11 (6.1.8 is available)
+ typescript 5.4.3
WARN Issues with peer dependencies found
.
└─┬ @sanity/pkg-utils 5.1.4
└── ✕ unmet peer [email protected]: found 5.4.3
Done in 20.2s
[info] Done!
First steps
I first checked the @sanity/plugin-kit
change log for any releases that seemed related to the errors I was seeing. Nothing jumped out at me so I returned to the initial output of the plugin generation and noticed:
WARN Issues with peer dependencies found
.
└─┬ @sanity/pkg-utils 5.1.4
└── ✕ unmet peer [email protected]: found 5.4.3
This being a warning I didn't think was the cause of the issue but it did encourage me to check @sanity/pkg-utils
for related releases.
I came across this in the change log:
v5.1.1 5.1.1 (2024-03-20) Bug Fixes ensure no "Masquerading as ESM|CJS" dts errors (https://github.com/sanity-io/pkg-utils/issues/627) (e54dc10)
Resolution
Testing to see if this would resolve the build error I pinned @sanity/pkg-utils
to the version immediately before 5.1.1
e.g. 5.1.0
. I did this by adding the following to my package.json
...
"resolutions": {
"@sanity/pkg-utils": "5.1.0",
},
...
Once this change was made I reinstalled my packages and attempted to build the plugin again and it worked!
Clarification
This is definitely not a long-term solution as you'll have to pin @sanity/pkg-utils
every time you generate a plugin from @sanity/plugin-kit
and further the side effects of rolling this package back to 5.1.0 are unknown but for now this should help you get over the immediate hurdle of not being able to build your plugin.
Hope this is helpful for anyone who comes across this issue as well 🙂