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

Explore enabling ESM based extensions #135450

Closed
mjbvz opened this issue Oct 20, 2021 · 4 comments
Closed

Explore enabling ESM based extensions #135450

mjbvz opened this issue Oct 20, 2021 · 4 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) extension-host Extension host issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Oct 20, 2021

Bringing up #116056 again

VS Code extensions currently use commonJS modules. However Native ECMAScript modules (ESM) are quickly becoming the standard across various JavaScript environments. We should explore what it would require to enable ESM based extensions for VS Code

As background, Node 12 introduced experimental support for modules and Node 14 moved them to stable. The TypeScript team is also currently working to support compiling to node12 compatible modules with TypeScript 4.5: microsoft/TypeScript#44501

@mjbvz mjbvz added the under-discussion Issue is under discussion for relevance, priority, approach label Oct 20, 2021
@mjbvz
Copy link
Collaborator Author

mjbvz commented Oct 20, 2021

One challenge is that we'd need to intercept calls to import 'vscode'. Currently we can do this for require:

const _require = (request: string) => {

class VSCodeNodeModuleFactory implements INodeModuleFactory {

I don't think our current approach works for import though.

Node does have an experimental loader api that we could potentially use: https://nodejs.org/api/esm.html#loaders However with the current proposal, I don't think we would be able to hand each extension it's own copy of the vscode api object like we currently do

Let's follow along with what node is working on make sure whatever they eventually stabilize supports our use case

@alexdima alexdima added the extension-host Extension host issues label Oct 20, 2021
@jrieken
Copy link
Member

jrieken commented Oct 20, 2021

It's also noteworthy that neither Safari nor Firefox support ESM in web-workers (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility).

@mjbvz
Copy link
Collaborator Author

mjbvz commented Oct 20, 2021

Safari 15 just added support! Just waiting on Firefox now but it looks like there has been some somewhat recent activity on the issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1247687

xsro added a commit to dosasm/masm-tasm that referenced this issue Oct 29, 2021
latest node-fetch is esm only, so we can't load it
node-fetch/node-fetch#1279 (comment)

focusing vscode support of esm
in microsoft/vscode#135450
xsro added a commit to dosasm/masm-tasm that referenced this issue Oct 29, 2021
latest node-fetch is esm only, so we can't load it
node-fetch/node-fetch#1279 (comment)

focusing vscode support of esm
in microsoft/vscode#135450
xsro added a commit to dosasm/masm-tasm that referenced this issue Nov 1, 2021
latest node-fetch is esm only, so we can't load it
node-fetch/node-fetch#1279 (comment)

focusing vscode support of esm
in microsoft/vscode#135450
@jrieken
Copy link
Member

jrieken commented Nov 1, 2021

actually, /duplicate of #130367

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) extension-host Extension host issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants
@jrieken @alexdima @mjbvz and others