Plugin API access to plugin ID (from the manifest.json)


I saw this code here and I am wondering if the XD team would allow the plugin ID to be received via the API instead of manually writing it a variable as below:

const PLUGIN_ID = "<your manifest's plugin ID here>";

let richObject = {
    list: [2, 4, 6],
    name: "Hello world"
node.sharedPluginData.setItem(PLUGIN_ID, "richData", JSON.stringify(richObject));

I agree that this would be good. Currently, I always use


to get the plugin id (this, at least, doesn’t require me to set the id at different places).

I’m generally curious, however (I direct this question to Adobe): Why do we need to pass the plugin id to setItem when (quoting the docs) “(it) Must be equal to your plugin’s ID.”?


I wouldn’t ever thought about this in a million years :smiley:

And yeah, this:

node.sharedPluginData.setItem(PLUGIN_ID, "richData", JSON.stringify(richObject));

whould have been much better as this (less confusing):

node.sharedPluginData.setItem("richData", JSON.stringify(richObject));
1 Like

Yep, if you’re using webpack, you can

import { id } from '../manifest.json'

and Bob’s your uncle.

1 Like

@cpryland :+1:.

Ideally, with webpack (as webpack enables one to do so), one creates an alias for the manifest.json :wink:. Importing


gets slightly out of hand a few levels deep :stuck_out_tongue_winking_eye:.

but this doesn’t happen when you only have the main.js in the same folder with the manifest.json, right ?

Correct. Only when your plugins get more and more complex and subfolders of subfolders begin to emerge :wink:.

Yeah, that’s why we need it to get it from the scenegraph API :slight_smile:

@cpryland please vote this feature :wink:

I think it’s much simpler to just include whatever you need from manifest in your sources, as I and other suggest above. Generally, it’d be in your main module, so I think the “levels deep” argument doesn’t hold.

No need for Adobe to burden the API with something this simple and easily accessible at build time.

1 Like