-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile static blocks without the intermediate priv field step (#13297)
* Remove ordering constraints for `static-blocks` plugin * Handle static blocks directly in `helper-create-class-features-plugin`
- Loading branch information
1 parent
b3d35cd
commit 8732dd3
Showing
22 changed files
with
168 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ate-class-features-plugin/test/fixtures/missing-class-static-blocks-plugin/basic/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class A { | ||
#x; | ||
static {} | ||
} |
4 changes: 4 additions & 0 deletions
4
...class-features-plugin/test/fixtures/missing-class-static-blocks-plugin/basic/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": ["proposal-class-properties", "syntax-class-static-block"], | ||
"throws": "Static class blocks are not enabled. Please add `@babel/plugin-proposal-class-static-block` to your configuration." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 5 additions & 8 deletions
13
...lugin-proposal-class-static-block/test/fixtures/integration-loose/class-binding/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
class Foo {} | ||
|
||
Foo.bar = 42; | ||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = Foo.bar; | ||
})() | ||
}); | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
13 changes: 5 additions & 8 deletions
13
...n-proposal-class-static-block/test/fixtures/integration-loose/class-declaration/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
class Foo {} | ||
|
||
Foo.bar = 42; | ||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = Foo.bar; | ||
})() | ||
}); | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
28 changes: 9 additions & 19 deletions
28
...n-proposal-class-static-block/test/fixtures/integration-loose/in-class-heritage/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
var _class, _2, _temp, _class2, _3, _temp2; | ||
var _class, _temp, _class2, _temp2; | ||
|
||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
class Foo extends (_temp = _class = class extends (_temp2 = _class2 = class Base {}, (() => { | ||
_class2.qux = 21; | ||
})(), _temp2) {}, (() => { | ||
_class.bar = 21; | ||
})(), _temp) {} | ||
|
||
class Foo extends (_temp = (_2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"), _class = class extends (_temp2 = (_3 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"), _class2 = class Base {}), Object.defineProperty(_class2, _3, { | ||
writable: true, | ||
value: (() => { | ||
_class2.qux = 21; | ||
})() | ||
}), _temp2) {}), Object.defineProperty(_class, _2, { | ||
writable: true, | ||
value: (() => { | ||
_class.bar = 21; | ||
})() | ||
}), _temp) {} | ||
(() => { | ||
Foo.foo = Foo.bar + Foo.qux; | ||
})(); | ||
|
||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = Foo.bar + Foo.qux; | ||
})() | ||
}); | ||
expect(Foo.foo).toBe(42); |
27 changes: 10 additions & 17 deletions
27
...class-static-block/test/fixtures/integration-loose/multiple-static-initializers/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
var _bar = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("bar"); | ||
|
||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
var _2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_2"); | ||
|
||
class Foo {} | ||
|
||
Object.defineProperty(Foo, _bar, { | ||
writable: true, | ||
value: 21 | ||
}); | ||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = babelHelpers.classPrivateFieldLooseBase(Foo, _bar)[_bar]; | ||
Foo.qux1 = Foo.qux; | ||
})() | ||
}); | ||
|
||
(() => { | ||
Foo.foo = babelHelpers.classPrivateFieldLooseBase(Foo, _bar)[_bar]; | ||
Foo.qux1 = Foo.qux; | ||
})(); | ||
|
||
Foo.qux = 21; | ||
Object.defineProperty(Foo, _2, { | ||
writable: true, | ||
value: (() => { | ||
Foo.qux2 = Foo.qux; | ||
})() | ||
}); | ||
|
||
(() => { | ||
Foo.qux2 = Foo.qux; | ||
})(); |
13 changes: 5 additions & 8 deletions
13
...lugin-proposal-class-static-block/test/fixtures/integration-loose/name-conflict/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
var _2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_2"); | ||
|
||
class Foo {} | ||
|
||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: 42 | ||
}); | ||
Object.defineProperty(Foo, _2, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = babelHelpers.classPrivateFieldLooseBase(Foo, _)[_]; | ||
})() | ||
}); | ||
|
||
(() => { | ||
Foo.foo = babelHelpers.classPrivateFieldLooseBase(Foo, _)[_]; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
33 changes: 12 additions & 21 deletions
33
...-proposal-class-static-block/test/fixtures/integration-loose/super-static-block/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
var _class, _2, _temp; | ||
var _class, _temp; | ||
|
||
var _ = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
class Foo extends (_temp = (_2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"), _class = class {}), Object.defineProperty(_class, _2, { | ||
writable: true, | ||
value: (() => { | ||
_class.bar = 42; | ||
})() | ||
}), _temp) {} | ||
class Foo extends (_temp = _class = class {}, (() => { | ||
_class.bar = 42; | ||
})(), _temp) {} | ||
|
||
Foo.bar = 21; | ||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
var _class2, _3, _temp2; | ||
|
||
Foo.foo = (_temp2 = (_3 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("_"), _class2 = class {}), Object.defineProperty(_class2, _3, { | ||
writable: true, | ||
value: (() => { | ||
_class2.bar = 42; | ||
})() | ||
}), _temp2).bar; | ||
})() | ||
}); | ||
(() => { | ||
var _class2, _temp2; | ||
|
||
Foo.foo = (_temp2 = _class2 = class {}, (() => { | ||
_class2.bar = 42; | ||
})(), _temp2).bar; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
11 changes: 5 additions & 6 deletions
11
...abel-plugin-proposal-class-static-block/test/fixtures/integration/class-binding/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
class Foo {} | ||
|
||
babelHelpers.defineProperty(Foo, "bar", 42); | ||
var _ = { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = Foo.bar; | ||
})() | ||
}; | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
11 changes: 5 additions & 6 deletions
11
...-plugin-proposal-class-static-block/test/fixtures/integration/class-declaration/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
class Foo {} | ||
|
||
babelHelpers.defineProperty(Foo, "bar", 42); | ||
var _ = { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = Foo.bar; | ||
})() | ||
}; | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
expect(Foo.foo).toBe(42); |
Oops, something went wrong.