-
Notifications
You must be signed in to change notification settings - Fork 54
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
Support dynamic import under NodeJS #36
Comments
Hoping that this will be available soon so that we can start consuming ESM code in extensions? |
Any updates on this one? Is there any way to import ESM code in vscode extensions? |
VS Code 1.94 now ships the ESM build in the stable channel: I tested using ESM in extensiom code and that still appears to be unsupported, but hopefully VS Code now shipping ESM means this limitation will be lifted, soon. |
In a non-ESM context normally
import()
can be used to bring in ESM code. Under this loader this will be true for browsers, but not NodeJS which does not include an implementation by default for scripts constructed withvm.Script
.Downstream this complicates extension development in VSCode as it means ESM packages can only be used if first transformed into a compatible syntax (usually by a bundler). Note that the extension development host appears to load extensions without using this loader, so such dynamic import restrictions will not be seen there.
At present, I can see 2 paths towards supporting dynamic import.
importModuleDynamically
option (this API and those which may be needed for the implementation are marked experimental, it may be worth waiting on Roadmap for stabilization of vm modules nodejs/node#37648)Forfeit thenodeInstrumenter
option so the implementation can be simplified to justrequire
(by far easiest and not blocked by experimental API, but will be a breaking change)EDIT 2023-03-13: On closer inspection, it appears I read the codepath wrong. This is not an option.
Downstream issue: microsoft/vscode#130367
The text was updated successfully, but these errors were encountered: