Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize computed properties output (byte-wise)
- Loading branch information
1 parent
b804bb0
commit 18c83f2
Showing
9 changed files
with
121 additions
and
33 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
3 changes: 1 addition & 2 deletions
3
packages/babel-plugin-transform-computed-properties/test/fixtures/regression/7144/output.mjs
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,2 +1 @@ | ||
var _a$c; | ||
export default (_a$c = {}, babelHelpers.defineProperty(_a$c, a, b), babelHelpers.defineProperty(_a$c, c, d), _a$c); | ||
export default babelHelpers.defineProperty(babelHelpers.defineProperty({}, a, b), c, d); |
7 changes: 3 additions & 4 deletions
7
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/method/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,6 +1,5 @@ | ||
var _obj; | ||
var obj = (_obj = {}, babelHelpers.defineProperty(_obj, foobar, function () { | ||
var obj = babelHelpers.defineProperty(babelHelpers.defineProperty({}, foobar, function () { | ||
return "foobar"; | ||
}), babelHelpers.defineProperty(_obj, "test", function () { | ||
}), "test", function () { | ||
return "regular method after computed property"; | ||
}), _obj); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/mixed/exec.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,18 @@ | ||
var heh = "heh"; | ||
var noo = "noo"; | ||
var foo = "foo"; | ||
|
||
var obj = { | ||
["x" + heh]: "heh", | ||
["y" + noo]: "noo", | ||
[foo]: "foo1", | ||
foo: "foo2", | ||
bar: "bar", | ||
}; | ||
|
||
expect(obj).toEqual({ | ||
xheh: "heh", | ||
ynoo: "noo", | ||
foo: "foo2", | ||
bar: "bar", | ||
}); |
13 changes: 9 additions & 4 deletions
13
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/mixed/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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
var heh = "heh"; | ||
var noo = "noo"; | ||
var foo = "foo"; | ||
|
||
var obj = { | ||
["x" + foo]: "heh", | ||
["y" + bar]: "noo", | ||
foo: "foo", | ||
bar: "bar" | ||
["x" + heh]: "heh", | ||
["y" + noo]: "noo", | ||
[foo]: "foo1", | ||
foo: "foo2", | ||
bar: "bar", | ||
}; |
6 changes: 4 additions & 2 deletions
6
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/mixed/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,2 +1,4 @@ | ||
var _obj; | ||
var obj = (_obj = {}, babelHelpers.defineProperty(_obj, "x" + foo, "heh"), babelHelpers.defineProperty(_obj, "y" + bar, "noo"), babelHelpers.defineProperty(_obj, "foo", "foo"), babelHelpers.defineProperty(_obj, "bar", "bar"), _obj); | ||
var heh = "heh"; | ||
var noo = "noo"; | ||
var foo = "foo"; | ||
var obj = babelHelpers.defineProperty(babelHelpers.defineProperty(babelHelpers.defineProperty(babelHelpers.defineProperty(babelHelpers.defineProperty({}, "x" + heh, "heh"), "y" + noo, "noo"), foo, "foo1"), "foo", "foo2"), "bar", "bar"); |
31 changes: 31 additions & 0 deletions
31
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/multiple/exec.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,31 @@ | ||
var manyProps = { | ||
[0 + 1]: 1, | ||
[0 + 2]: 2, | ||
[0 + 3]: 3, | ||
[0 + 4]: 4, | ||
[0 + 5]: 5, | ||
[0 + 6]: 6, | ||
[0 + 7]: 7, | ||
[0 + 8]: 8, | ||
[0 + 9]: 9, | ||
[0 + 10]: 10, | ||
[0 + 11]: 11, | ||
[0 + 12]: 12, | ||
[0 + 13]: 13, | ||
}; | ||
|
||
expect(manyProps).toEqual({ | ||
1: 1, | ||
2: 2, | ||
3: 3, | ||
4: 4, | ||
5: 5, | ||
6: 6, | ||
7: 7, | ||
8: 8, | ||
9: 9, | ||
10: 10, | ||
11: 11, | ||
12: 12, | ||
13: 13, | ||
}); |
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
5 changes: 3 additions & 2 deletions
5
packages/babel-plugin-transform-computed-properties/test/fixtures/spec/multiple/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.