You can’t directly use NPM modules in browser applications. This is true for any browser webapp, not just Figma plugins. You’ll need to use a bundler that combines NPM module source code with your code. See our guide to bundling here:
figma.com
I am already using Webpack
I am easily getting all the selections in Figma into converted image bytearray. I am using webpack based project. But when I try to initialze the jszip object, it gives compile error.
If it is not possible, can I send this Bytearray to a HTTP request? So that if another program is running in c# or java can access it locally? Basically I wish to save this image arrays to png images. Even if I am running Figma desktop, I think I am running the plugin in Figma server… Correct?
@Gleb could you please give a suggestion?
I am also trying to set jszip to a Figma plugin but unsuccessfully. I’m am running out of ideas on how to solve this and currently stuck.
I managed to select all images in the project and set the download (although only one is downloaded) — which is why I believe I need the jszip.
I suspect the problem might be in the tsconfig.json file.
It sounds like you’re trying to include JSZip inside the UI side of the plugin. You’ll want to make sure that you’re using HtmlWebpackPlugin to ensure that the NPM modules are being correctly bundled for the UI. Using a script tag that references node_modules won’t work.
Here’s an example of a Figma plugin that uses webpack and imports NPM dependencies (in this case, React) into the plugin UI code:
github.com
So are you suggesting if I use ui.tsx and try jszip inside that, it may work?
Hi @Nidhin_Kuttikkattu_Rajeevan, did you find a solution for this? I am facing same problem