Troubleshooting local plugin development for Cloudinary asset source in Sanity

21 replies
Last updated: Jul 1, 2020
Hello good people at Sanity! I am wanting to extend the
sanity-plugin-asset-source-cloudinary
with video and multi asset selection. I’m trying to get it to run as a plugin locally, but I’m getting an error loading the module
'part:@sanity/components/dialogs/fullscreen'
which is the first
part:
module it asks for. I’ve added the plugin as a local yarn link in my monorepo project. Any ideas?
May 5, 2020, 9:07 AM
Hey Mike! Great idea to extend the Cloudinary asset source plugin with those features Just to rule out something: have you tried adding the plugin source simply as a folder to
/plugins
to see if that does run successfully?
May 5, 2020, 9:53 AM
Yes, but without luck. I’m definitely doing something wrong. So I add the plugin to the plugins. And then what?
May 5, 2020, 10:19 AM
Let’s go back to the original idea as you were looking to run it as a local plugin. I just ran a test and although it wasn’t in a monorepo, it worked successfully following the steps on https://github.com/sanity-io/sanity-plugin-asset-source-cloudinary#developing-on-this-module
Is
sanity-plugin-asset-source-cloudinary
running with watch mode after successfully completing both the
npm install
and the
npm link
commands?
After bootstrapping the monorepo, did you add
sanity-plugin-asset-source-cloudinary
to your
package.json
file in the studio root folder, with version
0.1.0
?
Did
npm link sanity-plugin-asset-source-cloudinary
complete successfully in your monorepo root?
Have you added
"asset-source-cloudinary"
to the list of plugins in your
sanity.json
file? And did you restart the test studio?
Perhaps most importantly considering the error, does your studio’s
package.json
file list
@sanity/components
as a dependency?
May 5, 2020, 10:56 AM
Yes, it is running in watchmode, but I get an error because it cant find module
part:@sanity/components/dialogs/fullscreen

Yes, added it to package.json (not in root). Will try that, but I think that might be a yarn workspace thing.

I used yarn link, since the monorepo is running yarn with workspaces (and lerna)

Yes added to
sanity.json
and restarted multiple times.
Yes, I have
@sanity/components
as dep in my cms package.json
May 5, 2020, 11:01 AM
I think I’ll try your approach and ditch the monorepo and figure that one out later.
May 5, 2020, 11:01 AM
Let me know if that gets it to work 🤞
May 5, 2020, 11:06 AM
Ok, so I figured something out. By adding the symlink to the monorepo root. I am able to get things going. But when I make a change in
CloudinaryAssetSource.tsx
I get the error described above. It still seems to work tho 🤷‍♂️
May 5, 2020, 11:12 AM
This is the error I get in from
yarn watch
May 5, 2020, 11:13 AM
Maybe the error is already there in the first place in that case? We could check with the authors - I think someone on the team has been involved in the creation of this plugin, so I can share it internally too.
Happy that you seem to be able to move forward though
🚀
May 5, 2020, 11:16 AM
I think for ‘part’ errors I was seeing that because the script wasn’t executed with ‘sanity exec’ are you doing that?
May 5, 2020, 11:23 AM
No, not currently, but it looks like that is for node scripts like migrations and such?
May 5, 2020, 11:29 AM
Right, but I think you might be running into the same issue - what is the script you're running that is throwing this error? is it
sanity start
?
May 5, 2020, 11:33 AM
No, it’s
yarn watch
in the plugin
May 5, 2020, 11:34 AM
But there is definitely something wrong with the importing – which tbh is a bit magic to me. I see that I get the same error with
config:
imports
May 5, 2020, 11:35 AM
yeah - I believe every time I've seen that error with importing it's because the script was not being executed under the
sanity
binary
May 5, 2020, 11:36 AM
Ok, great thank you for the tip 🙌 I’ll see if I can find an another way of executing this
May 5, 2020, 11:38 AM
Hey
Mike Patterson
, did you ever get this figured out for videos?
Jun 11, 2020, 7:05 PM
user C
Yes I did. Havent gotten around to creating a PR on the original repo yet. But this should work. It’ll import 4 types
cloudinarySingleImage
,
cloudinaryMultipleImage
,
cloudinarySingleVideo
and
cloudinaryMultipleVideo
Jun 12, 2020, 7:36 PM
amazing, thank you, i'll take a look!
Jun 14, 2020, 11:39 PM
How are you importing/configuring the plugin into your project?Also, anything I can do to help out to get it set up for a PR?
Jun 14, 2020, 11:53 PM
Did you figure it out? If not just PM me
Jul 1, 2020, 2:28 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in