Do anybody try to use core modules of Node js

Does any try to use core modules like
fs or child-process or something like that if yes how did you achieve that in your plugins

I have not, however AdobeXD provides a Storage api that I assume is abstracting the fs api. https://adobexdplatform.com/plugin-docs/reference/uxp/storage-index.html

I would hope that AdobeXD does not enable node apis without safeguarding them and ideally requiring manifests to request permission. Otherwise, this could enable malicious plugins to be developed and distributed (e.g. execute a keylogger background process that executes even when adobe xd is closed)

Hi all —

We do not directly support the use of Node-specific modules in XD plugins for many reasons, not the least of which is security (incredibly important, obviously), but also because we don’t want to ship Node as a dependency in XD. So there’s no Node whatsoever inside XD.

That said, depending on the platform, we do utilize some dependencies that Node also uses. For example, on macOS, we utilize the libuv libraries which gets us the same capabilities as Node’s fs library. On UWP, however, the file system is heavily sandboxed, and so we have to use a different library to get access to files. As such, we abstract all this away into a provider model that enables you to interact with the file system on macOS and UWP in XD using the same exact code.

So, long story short, there are no Node libraries to expose. This is why require('fs') won’t get you anything useful.

Now, that’s not to say that there aren’t npm packages that won’t work within XD – there are quite a few that will work. But those that depend upon core node modules like fs, path, etc., those are apt to fail inside XD. (Never mind that XD’s require does not resolve files like node does.)

Of course, there are features that we don’t expose because we don’t have core node modules – for example, launching child processes. There’s huge security issues here by the way, but what we want to understand is the use cases behind why one would want to launch a child process (because maybe there’s a better way) – same goes for specific file system needs, etc… For those, though, we’d request a specific API feature request to be created on the forum. :slight_smile:

2 Likes

@kerrishotts
You are right thats why i created feature request
Feature Request to allow VBScript on windows and similar on Mac

Because vbscript runs on sandboxed safe zone

I think at some point we talked about creating a list of JS libraries and npm modules that are known to work with XD plugins.

@kerrishotts what do you think about having a section for this in XD Awesome?

1 Like