-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Cannot polyfilled on optional chains (#221)
Co-authored-by: Nicolò Ribaudo <[email protected]>
- Loading branch information
1 parent
2fa4e97
commit bacb1df
Showing
10 changed files
with
243 additions
and
22 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
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
2 changes: 2 additions & 0 deletions
2
...ages/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/optional-chaining/input.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Array?.from(); | ||
c?.toSorted(); |
10 changes: 10 additions & 0 deletions
10
...s/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/optional-chaining/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,10 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"@@/polyfill-corejs3", | ||
{ | ||
"method": "usage-global" | ||
} | ||
] | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/optional-chaining/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import "core-js/modules/es.array.from.js"; | ||
import "core-js/modules/es.array.sort.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
Array?.from(); | ||
c?.toSorted(); |
35 changes: 35 additions & 0 deletions
35
packages/babel-plugin-polyfill-corejs3/test/fixtures/usage-pure/optional-chaining/input.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
a.toSorted(x); | ||
a.toSorted?.(x); | ||
a.b.toSorted?.(x); | ||
a.b.toSorted?.(x).c; | ||
a.b.toSorted?.(x)?.c; | ||
|
||
a?.toSorted(x); | ||
a?.b.toSorted(x).c; | ||
a.b?.toSorted(x).c; | ||
a?.b.toSorted(x)?.c; | ||
a.b?.toSorted(x)?.c; | ||
a?.b.toSorted?.(x).c; | ||
|
||
a.b.c.toSorted?.d.e; | ||
a.b?.c.toSorted.d.e; | ||
a.b?.c.toSorted?.d.e; | ||
|
||
Array.from(x); | ||
Array.from?.(x); | ||
Array.from?.(x).c; | ||
Array.from?.(x)?.c; | ||
|
||
Array?.from(x); | ||
Array?.from(x).c; | ||
Array?.from(x)?.c; | ||
Array?.from?.(x); | ||
Array?.from?.(x).c; | ||
Array?.from?.(x)?.c; | ||
|
||
Array?.from; | ||
Array?.from.x.y; | ||
Array.from?.x.y; | ||
Array?.from?.x.y; | ||
Array.from.x?.y; | ||
Array?.from.x().y?.(); |
14 changes: 14 additions & 0 deletions
14
...ges/babel-plugin-polyfill-corejs3/test/fixtures/usage-pure/optional-chaining/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,14 @@ | ||
{ | ||
"targets": { | ||
"chrome": "30" | ||
}, | ||
"plugins": [ | ||
[ | ||
"@@/polyfill-corejs3", | ||
{ | ||
"method": "usage-pure", | ||
"version": "3.38" | ||
} | ||
] | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/babel-plugin-polyfill-corejs3/test/fixtures/usage-pure/optional-chaining/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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14; | ||
import _toSortedInstanceProperty from "core-js-pure/stable/instance/to-sorted.js"; | ||
import _Array$from from "core-js-pure/stable/array/from.js"; | ||
_toSortedInstanceProperty(a).call(a, x); | ||
_toSortedInstanceProperty(a)?.call(a, x); | ||
_toSortedInstanceProperty(_context = a.b)?.call(_context, x); | ||
_toSortedInstanceProperty(_context2 = a.b)?.call(_context2, x).c; | ||
_toSortedInstanceProperty(_context3 = a.b)?.call(_context3, x)?.c; | ||
((_context4 = a) == null ? void 0 : Function.call.bind(_toSortedInstanceProperty(_context4), _context4))?.(x); | ||
((_context5 = a) == null ? void 0 : Function.call.bind(_toSortedInstanceProperty(_context6 = _context5.b), _context6))?.(x).c; | ||
((_context7 = a.b) == null ? void 0 : Function.call.bind(_toSortedInstanceProperty(_context7), _context7))?.(x).c; | ||
((_context8 = a) == null ? void 0 : Function.call.bind(_toSortedInstanceProperty(_context9 = _context8.b), _context9))?.(x)?.c; | ||
((_context10 = a.b) == null ? void 0 : Function.call.bind(_toSortedInstanceProperty(_context10), _context10))?.(x)?.c; | ||
((_context11 = a) == null ? void 0 : _toSortedInstanceProperty(_context12 = _context11.b))?.call(_context12, x).c; | ||
_toSortedInstanceProperty(a.b.c)?.d.e; | ||
((_context13 = a.b) == null ? void 0 : _toSortedInstanceProperty(_context13.c))?.d.e; | ||
((_context14 = a.b) == null ? void 0 : _toSortedInstanceProperty(_context14.c))?.d.e; | ||
_Array$from(x); | ||
_Array$from(x); | ||
_Array$from(x).c; | ||
_Array$from(x)?.c; | ||
_Array$from(x); | ||
_Array$from(x).c; | ||
_Array$from(x)?.c; | ||
_Array$from(x); | ||
_Array$from(x).c; | ||
_Array$from(x)?.c; | ||
_Array$from; | ||
_Array$from.x.y; | ||
_Array$from.x.y; | ||
_Array$from.x.y; | ||
_Array$from.x?.y; | ||
_Array$from.x().y?.(); |