-
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
Add extension esm support #57
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let's get this shipped.
Creating VS Code Extension without native esm
support is such a pain
@v4lentin1879 Could you please help me understand how this PR helps with loading VS Code extensions? AFAIK extension code loading happens via nodejs' require here and does not involve the AMD loader. |
@alexdima This repo is referenced in VSCode’s
Does that mean this repo is supposed to be updated before VSCode’s |
@alexdima I am referring to the discussion in this thread: #36. The issue is that esm modules cannot be imported in a static way in commonjs. Since vscode is still based on commonjs, we have to make use of dynamic imports in extensions in order to use esm modules. This works perfectly fine in the development environment as there the vscode-loader is not used, yes. However, when packaging the extension, dynamic imports will stop to work because that's where the vscode-loader comes into play. My PR simply implements the importModuleDynamically option to enable dynamic imports. |
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. |
Currently, it is impossible to import ESM modules in a vscode extension as those require dynamic imports. This PR introduces the possibility of using dynamic imports in vscode. I'm looking forward to your feedback!
https://nodejs.org/api/vm.html#when-importmoduledynamically-is-a-function
#36