Load ES module from VS Code extension
hakonhagland opened this issue · 1 comments
hakonhagland commented
I am trying to load an ES module from a VS Code extension, see this question on stackoverflow. I believe I have run into this issue.
In another issue someone suggested to use the esm
package. I tried it, see the esm branch, but I still get the following error:
[2022-04-21 15:27:47.180] [exthost] [error] Activating extension undefined_publisher.vscode-test-getport failed due to an error:
[2022-04-21 15:27:47.180] [exthost] [error] /home/hakon/test/vscode/vscode-test-getport/out/main.js:1
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/hakon/test/vscode/vscode-test-getport/node_modules/get-port/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/hakon/test/vscode/vscode-test-getport/out/main.js:4:20)
at Generator.next (<anonymous>)
at Object.<anonymous> (/home/hakon/test/vscode/vscode-test-getport/out/extension.js:4:18)
at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
Any suggestions?
Leedehai commented
According to electron/electron#21457 (comment) from an Electron maintainer, it seems it is technically unfeasible to support ESM in Electron directly.