-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Use es.*
for stable esnext features
#98
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
434ae62
chore: bump core-js-compat
JLHwung b18a539
add builtin definitions checker
JLHwung 8f1a95a
replace esnext to es for stable features
JLHwung 6a1cb53
update test fixtures
JLHwung ee6723b
es -> esnext fallback logic
JLHwung 1636316
update test cases
JLHwung e4197a7
🤷
JLHwung d3dbc8c
address review comments
JLHwung e9528b0
fix: provider used incorrect base for shipped proposals
JLHwung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
125 changes: 125 additions & 0 deletions
125
packages/babel-plugin-polyfill-corejs3/test/check-builtin-definitions.test.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,125 @@ | ||
import corejs3Entries from "../core-js-compat/entries"; | ||
|
||
import { | ||
BuiltIns, | ||
StaticProperties, | ||
InstanceProperties, | ||
} from "../src/built-in-definitions.js"; | ||
|
||
const supportedCorejs3Modules = new Set(); | ||
|
||
const corejs3Modules = corejs3Entries["core-js"]; | ||
|
||
function addsupportedCorejs3Modules(descriptors) { | ||
for (const { global } of Object.values(descriptors)) { | ||
for (const dep of global) { | ||
supportedCorejs3Modules.add(dep); | ||
} | ||
} | ||
} | ||
addsupportedCorejs3Modules(BuiltIns); | ||
|
||
for (const properties of Object.values(StaticProperties)) { | ||
addsupportedCorejs3Modules(properties); | ||
} | ||
|
||
addsupportedCorejs3Modules(InstanceProperties); | ||
|
||
const allowList = []; | ||
describe("corejs3 builtin definitions", () => { | ||
it("should support most corejs3 features", () => { | ||
let todoListItem = 0; | ||
for (const name of corejs3Modules) { | ||
if (supportedCorejs3Modules.has(name)) continue; | ||
if (name.startsWith("es.")) { | ||
const esNextName = "esnext." + name.slice(3); | ||
if (supportedCorejs3Modules.has(esNextName)) { | ||
todoListItem++; | ||
console.error( | ||
`Please replace "${esNextName}" by "${name}" in | ||
packages/babel-plugin-polyfill-corejs3/src/built-in-definitions.js.`, | ||
); | ||
continue; | ||
} | ||
} | ||
if (name.startsWith("esnext.")) { | ||
const esName = "es." + name.slice(7); | ||
if (supportedCorejs3Modules.has(esName)) continue; | ||
} | ||
allowList.push(name); | ||
} | ||
expect(todoListItem).toBe(0); | ||
// The allowlist should only be added when we decide we don't support | ||
// the feature in `src/builtin-definitions.js` | ||
expect(allowList).toMatchInlineSnapshot(` | ||
Array [ | ||
"es.symbol.match-all", | ||
"es.array.unscopables.flat", | ||
"es.date.get-year", | ||
"es.date.set-year", | ||
"es.date.to-gmt-string", | ||
"es.escape", | ||
"es.json.stringify", | ||
"es.reflect.to-string-tag", | ||
"es.regexp.dot-all", | ||
"es.regexp.sticky", | ||
"es.regexp.test", | ||
"es.string.substr", | ||
"es.unescape", | ||
"esnext.array.filter-out", | ||
"esnext.array.filter-reject", | ||
"esnext.array.group-by", | ||
"esnext.array.is-template-object", | ||
"esnext.array.unique-by", | ||
"esnext.async-iterator.constructor", | ||
"esnext.async-iterator.as-indexed-pairs", | ||
"esnext.async-iterator.drop", | ||
"esnext.async-iterator.every", | ||
"esnext.async-iterator.filter", | ||
"esnext.async-iterator.find", | ||
"esnext.async-iterator.flat-map", | ||
"esnext.async-iterator.for-each", | ||
"esnext.async-iterator.from", | ||
"esnext.async-iterator.map", | ||
"esnext.async-iterator.reduce", | ||
"esnext.async-iterator.some", | ||
"esnext.async-iterator.take", | ||
"esnext.async-iterator.to-array", | ||
"esnext.bigint.range", | ||
"esnext.iterator.constructor", | ||
"esnext.iterator.as-indexed-pairs", | ||
"esnext.iterator.drop", | ||
"esnext.iterator.every", | ||
"esnext.iterator.filter", | ||
"esnext.iterator.find", | ||
"esnext.iterator.flat-map", | ||
"esnext.iterator.for-each", | ||
"esnext.iterator.from", | ||
"esnext.iterator.map", | ||
"esnext.iterator.reduce", | ||
"esnext.iterator.some", | ||
"esnext.iterator.take", | ||
"esnext.iterator.to-array", | ||
"esnext.map.emplace", | ||
"esnext.map.update-or-insert", | ||
"esnext.map.upsert", | ||
"esnext.number.range", | ||
"esnext.object.iterate-entries", | ||
"esnext.object.iterate-keys", | ||
"esnext.object.iterate-values", | ||
"esnext.symbol.async-dispose", | ||
"esnext.symbol.matcher", | ||
"esnext.symbol.metadata", | ||
"esnext.symbol.replace-all", | ||
"esnext.typed-array.filter-out", | ||
"esnext.typed-array.filter-reject", | ||
"esnext.typed-array.find-last", | ||
"esnext.typed-array.find-last-index", | ||
"esnext.typed-array.group-by", | ||
"esnext.typed-array.unique-by", | ||
"esnext.weak-map.emplace", | ||
"esnext.weak-map.upsert", | ||
] | ||
`); | ||
}); | ||
}); |
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
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: 1 addition & 1 deletion
2
packages/babel-plugin-polyfill-corejs3/test/fixtures/entry-global/entries-stable/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,7 +1,7 @@ | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.set.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
import "core-js/modules/web.dom-collections.iterator.js"; | ||
import "core-js/modules/es.array.from.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.from-entries.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
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: 1 addition & 1 deletion
2
packages/babel-plugin-polyfill-corejs3/test/fixtures/entry-global/normalization/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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name.startsWith("esnext.")
is alwaysfalse
when bothproposals
andshippedProposals
are not enabled.