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

Track extension es6 output migration #68698

Closed
8 of 13 tasks
jrieken opened this issue Feb 14, 2019 · 4 comments
Closed
8 of 13 tasks

Track extension es6 output migration #68698

jrieken opened this issue Feb 14, 2019 · 4 comments
Assignees
Labels
debt Code quality issues engineering VS Code - Build / issue tracking / etc.

Comments

@jrieken
Copy link
Member

jrieken commented Feb 14, 2019

We have changed our compile to emit ES6 JavaScript, instead of ES5. That means let or const don't become var etc, it also means that classes are emitted as classes, not as functions.

There are extensions that emit ES5 JavaScript and that extend from our API types. The code usually looks like this:

var PathCompletionItem = (function (_super) {
    __extends(PathCompletionItem, _super);
    function PathCompletionItem(filename, isfile) {
        _super.call(this, filename);
        this.foo = 1;
    }
    PathCompletionItem.prototype.bar = function () {
        this.foo += 1;
    };
    return PathCompletionItem;
}(vscode.CompletionItem));

The challenge is that calling a class-constructor from a function extending it, isn't possible and requires a workaround. We have the es5ClassCompat-util for that. However, there are only eight extensions that use this pattern and this issue track the migration to emitting ES6 code.

Calling static functions using the new keyword (see #69533)

@jrieken jrieken self-assigned this Feb 14, 2019
@jrieken jrieken added the engineering VS Code - Build / issue tracking / etc. label Feb 14, 2019
@jrieken
Copy link
Member Author

jrieken commented Feb 14, 2019

Types that are being extended by functions (this includes only extension code, not code that is in node_modules programmed against vscode-API)

CompletionItem
Disposable
TreeItem
CodeLens

@jrieken jrieken added this to the February 2019 milestone Feb 14, 2019
@iann0036
Copy link

Done. Good luck!

@Gama11
Copy link
Contributor

Gama11 commented Feb 14, 2019

However, there are only eight extensions that use this pattern and this issue track the migration to emitting ES6 code.

I think your detection method might be flawed and there might actually be more extensions affected. The Haxe extension (naturally) uses Haxe-generated JS, which uses this pattern:

vshaxe.view.dependencies.Node = function(parent,label,path,type) {
	vscode.TreeItem.call(this,label);
	...
}
vshaxe.view.dependencies.Node.prototype = $extend(vscode.TreeItem.prototype,{
	...
}

Where Haxe defines $extend as:

function $extend(from, fields) {
	var proto = Object.create(from);
	for (var name in fields) proto[name] = fields[name];
	if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
	return proto;
}

The challenge is that calling a class-constructor from a function extending it, isn't possible and requires a workaround. We have the es5ClassCompat-util for that.

I'm a bit confused by this - does that mean that with that workaround in place, extensions using ES5 style JS should continue to work fine (but you're looking to remove the compatibility layer soon)? That already seems to not be the case, there's an error when expanding a node in the Haxe Dependencies View with current Insider's Builds (a509265).

@jrieken
Copy link
Member Author

jrieken commented Feb 14, 2019

Good catch @Gama11. I obviously don't know all patterns how functions extend classes/function. I have created a tracking item for the haxe extension.

does that mean that with that workaround in place, extensions using ES5 style JS should continue to work fine (but you're looking to remove the compatibility layer soon)?

Yes, everything should still work (your code won't load if not) but we are keen on removing the workaround because so few extensions rely on it.

@jrieken jrieken modified the milestones: February 2019, March 2019 Feb 25, 2019
@jrieken jrieken removed this from the March 2019 milestone Mar 25, 2019
@jrieken jrieken added the debt Code quality issues label Mar 25, 2019
@jrieken jrieken closed this as completed Oct 7, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues engineering VS Code - Build / issue tracking / etc.
Projects
None yet
Development

No branches or pull requests

3 participants