Packaging for VSCode Extension

Hi,

I’m working on a VSCode extension that I’m spawning external electron apps for some features

Everything works well on the dev environment, so there is no any problem.

However, when I package this extension into a VSIX package for shipment, the problem begins on macOS

I realized that, vsce (packaging tool for VSCode) corrupts the Electron when packaging.

There are also some issues for this, for example: https://github.com/Microsoft/vscode-vsce/issues/168

Therefore I can’t run the Electron app with node_modules/electron/dist/Electron.app/Contents/MacOS/Electron

So,

  1. how can I package my electron apps so that they don’t get corrupted when packaging the extension with vsce? (this problem is the priority)

  2. How can I package these apps (or extension) for cross-platform? Since the npm install gets modules platform dependent, it gets Electron.app if you package the extension on macOS, or gets electron.exe if you package on Windows. The package created on macOS, doesn’t work on Windows (because it doesn’t have electron.exe)

The first question is the priority, for the second, it would be good if there is a way.

Thanks in advance

Like the linked issue mentions, it’s not a good idea to do this.

It sounds like a vsce problem, so it’s difficult to give any information without knowing much about either what vsce is doing or even what your extension is trying to do and in what way it’s “corrupted”.

Packaging for multiple platforms (in regards to 2.) is possible, something like electron-packager can help you build for multiple platforms, but bundling 2 electron apps with every install of your extension sounds like a terrible idea. There’s no way to build a single “cross-platform” electron app.

But really, IMO, you should be using whatever VSCode gives you access to as much as possible

Thanks for your reply. vsce packager deletes some files/links in the Electron.app file, so Electron.app/Contents/MacOS/Electron executable cannot find a library and crashes.

Probably I’ll call npm install electron after the extension is installed. This should replace the corrupted file but increases the installation time (due to the download)

If someone has a better idea pls let me know

Thanks for your reply. vsce packager deletes some files/links in the Electron.app file, so Electron.app/Contents/MacOS/Electron executable cannot find a library and gets crashed.

Probably I’ll call npm install electron after the extension is installed. This should replace the corrupted file but increases the installation time (due to the download)

If someone has a better idea pls let me know