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.