Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load ES module from VS Code extension #915

Open
hakonhagland opened this issue Apr 22, 2022 · 1 comment
Open

Load ES module from VS Code extension #915

hakonhagland opened this issue Apr 22, 2022 · 1 comment

Comments

@hakonhagland
Copy link

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?

See also: https://stackoverflow.com/questions/70620025/how-do-i-import-an-es6-javascript-module-in-my-vs-code-extension-written-in-type

@Leedehai
Copy link

According to electron/electron#21457 (comment) from an Electron maintainer, it seems it is technically unfeasible to support ESM in Electron directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants