Fix super usage in lowered private methods (#2039)
Previously esbuild failed to transform super property accesses inside private methods in the case when private methods have to be lowered because the target environment doesn't support them. The generated code still contained the super keyword even though the method was moved outside of the class body, which is a syntax error in JavaScript. This release fixes this transformation issue and now produces valid code:
// Original code
class Derived extends Base {
#foo() { super.foo() }
bar() { this.#foo() }
}
// Old output (with --target=es6)
var _foo, foo_fn;
class Derived extends Base {
constructor() {
super(...arguments);
__privateAdd(this, _foo);
}
bar() {
__privateMethod(this, _foo, foo_fn).call(this);
}
}
_foo = new WeakSet();
foo_fn = function() {
super.foo();
};
// New output (with --target=es6)
var _foo, foo_fn;
const _Derived = class extends Base {
constructor() {
super(...arguments);
__privateAdd(this, _foo);
}
bar() {
__privateMethod(this, _foo, foo_fn).call(this);
}
};
let Derived = _Derived;
_foo = new WeakSet();
foo_fn = function() {
__superGet(_Derived.prototype, this, "foo").call(this);
};
Because of this change, lowered super property accesses on instances were rewritten so that they can exist outside of the class body. This rewrite affects code generation for all super property accesses on instances including those inside lowered async functions. The new approach is different but should be equivalent to the old approach:
Fix super usage in lowered private methods (#2039)
Previously esbuild failed to transform super property accesses inside private methods in the case when private methods have to be lowered because the target environment doesn't support them. The generated code still contained the super keyword even though the method was moved outside of the class body, which is a syntax error in JavaScript. This release fixes this transformation issue and now produces valid code:
// Original code
class Derived extends Base {
#foo() { super.foo() }
bar() { this.#foo() }
}
// Old output (with --target=es6)
var _foo, foo_fn;
class Derived extends Base {
constructor() {
super(...arguments);
__privateAdd(this, _foo);
}
bar() {
__privateMethod(this, _foo, foo_fn).call(this);
}
}
_foo = new WeakSet();
foo_fn = function() {
super.foo();
};
// New output (with --target=es6)
var _foo, foo_fn;
const _Derived = class extends Base {
constructor() {
super(...arguments);
__privateAdd(this, _foo);
}
bar() {
__privateMethod(this, _foo, foo_fn).call(this);
}
};
let Derived = _Derived;
_foo = new WeakSet();
foo_fn = function() {
__superGet(_Derived.prototype, this, "foo").call(this);
};
Because of this change, lowered super property accesses on instances were rewritten so that they can exist outside of the class body. This rewrite affects code generation for all super property accesses on instances including those inside lowered async functions. The new approach is different but should be equivalent to the old approach:
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps esbuild from 0.8.54 to 0.14.32.
Release notes
Sourced from esbuild's releases.
... (truncated)
Changelog
Sourced from esbuild's changelog.
... (truncated)
Commits
5829301
publish 0.14.32 to npm44d70d3
addwasmModule
option toinitialize
JS API (#2155)e86abce
mark symbol static properties as side-effect free516796f
fix tree-shaking regarding property side effects457cf22
Update CHANGELOG.md0a7ac6f
fix #2039: lowersuper
in private methods7f87558
super property shim: change to work outside classe24dfc7
better errors in end-to-end keep name testsc02c99f
publish 0.14.31 to npm4a6f64c
feat: add more CSS-wide keywords in font-family (#2135)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)