Skip to content
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

Remove babel polyfill from fixture test runner #12130

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Oct 1, 2020

Q                       A
Fixed Issues? Improve fixture-runner execution speed
Any Dependency Changes? transform-fixture-runner now depends on regenerator-runtime instead of deprecated @babel/polyfill
License MIT

This PR includes commits from #12127. For the real diff, see https://github.com/babel/babel/pull/12130/files/ed39a04b65315164d884744e31791f0984cdfdb6..ed8665b7100dcf6b3f0d8f113aee723ef1fbf568.

Before this PR the fixture runner can access various builtin polyfills provided by core-js, after this PR the fixture runner can only access regenerator-runtime and babel-helpers. The test execution time is thus improved. What's more, we are now testing against builtins provided by test engines (Node.js), so it the test result does not rely on the behaviour of builtin-polyfill provider. (regenerator-runtime is not builtin polyfill since it provides only regeneratorRuntime namespace).

In ed8665b we introduce an integration example with core-js 3: The symbol-async-iterator polyfill is injected before each test suites is run. To achieve this we add support of suite plugins in @babel/helper-test-fixtures.

@JLHwung JLHwung added area: tests PR: Internal 🏠 A type of pull request used for our changelog categories labels Oct 1, 2020
@babel-bot
Copy link
Collaborator

babel-bot commented Oct 1, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/36192/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 1, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 381f099:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung force-pushed the remove-babel-polyfill-from-fixture-test-runner branch from cca600c to ed8665b Compare October 2, 2020 21:24
@nicolo-ribaudo nicolo-ribaudo added this to To review in Nicolò's ideal PR review order list via automation Dec 8, 2020
Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing native node built-ins sounds great, makes sense - not sure how to review build changes other than testing it?

"plugins": [
"transform-async-to-generator",
"proposal-async-generator-functions",
"./inject-corejs-async-iterator-polyfill.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a preloadScripts option to the test runner instead?

{
  "parserOpts": {
    "allowReturnOutsideFunction": true
  },
  "plugins": [
    "transform-async-to-generator",
    "proposal-async-generator-functions"
  ],
  "preloadScripts": [
    "core-js/es/symbol/async-iterator.js"
  ]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't want to do the plugin hack yeah that could be ok - we should probably document all the config changes somewhere (for ourselves)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan at that time was to use babel-plugin-polyfill-corejs3 but I forgot the error messages I came across.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it's that it wasn't supported by Node.js 6-8.
We can revisit this after Babel 8: maybe add a // TODO(Babel 8) comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Babel 8 this polyfill won't be needed anyway, since Symbol.asyncIterator will be natively supported.

@JLHwung JLHwung force-pushed the remove-babel-polyfill-from-fixture-test-runner branch from ed8665b to 12a761e Compare December 18, 2020 23:15
@@ -167,32 +170,6 @@ export function runCodeInTestContext(
}
}

function wrapPackagesArray(type, names, optionsDir) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are moved to @babel/helper-fixtures.

checksum: 6ef567c662088b1b292214920cbd72443059298d477f72e1a37e0a113bafbfac9057cbfe35ae617284effc4b423493326a78561bbff7b04162c7949bdb9624e8
languageName: node
linkType: hard

Copy link
Contributor Author

@JLHwung JLHwung Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babel/polyfills still uses ^0.13.4. We can explore bumping it to 0.14 later.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:
(I'm overly excited about the idea of finally removing @babel/polyfill, since we deprecated it long time ago 😂)

@JLHwung JLHwung force-pushed the remove-babel-polyfill-from-fixture-test-runner branch from 44545e5 to 810f3db Compare December 21, 2020 17:46
@nicolo-ribaudo
Copy link
Member

I released a new version of the babel-polyfills packages which should fix the CI failure.

@nicolo-ribaudo nicolo-ribaudo merged commit 814212f into babel:main Dec 22, 2020
Nicolò's ideal PR review order list automation moved this from To review to Done Dec 22, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the remove-babel-polyfill-from-fixture-test-runner branch December 22, 2020 01:42
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 23, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: tests outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Development

Successfully merging this pull request may close these issues.

None yet

4 participants