-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Support Babel 8 in plugins and presets #15750
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
Conversation
❌ Deploy Preview for jestjs failed.Built without sensitive environment variables
|
d09e5c0 to
e1c717f
Compare
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
501bd08 to
0d9a720
Compare
2e3d659 to
be3b812
Compare
|
I assume we'll release this as a major, and we'll drop Node 18 next so don't worry about those. |
|
Oh I was planning to go with this PR first just allowing users to use Babel 8, and then a separate one (major) upgrading the whole repo to it. I'll do the whole upgrade immediately then. |
In: - babel-plugin-jest-hoist - babel-preset-jest - babel-jest
e821886 to
1813d34
Compare
|
@nicolo-ribaudo sorry I was away for a month. Just to confirm, with this PR Babel 7 or 8 can be used with Jest, and this is not a breaking change, is that correct? |
|
Correct! I can also open a PR with the breaking change next week of you prefer. |
|
Got it! We can discuss the breaking changes in the other PR then and figure out what's the right time to merge that. I see some test failures related to this change on CI: "TypeError: Cannot read properties of null (reading 'transformSync')". |
|
@cpojer I'm struggling a bit with the CI failure. Babel 8 does not support Node.js 18, so I'm using |
|
Ok maybe I found a (ugly) workaround. |
|
@nicolo-ribaudo sorry, I've ignored all OSS for a long time 😅 We have a |
|
jest/packages/test-utils/src/ConditionalTest.ts Lines 33 to 36 in 15e3e7c
This 🙂 |
|
Thanks, updated! Unfortunately I think I still need the workaround for the |
|
Hmm, that helper should fix that as it'll mark the snapshots as skipped rathe than unused 🤔 |
|
Ok, just checking in here to help move this over the line. Is this understanding correct:
If we merge this PR, Jest 30 with Babel 7 will still keep working in Node 18, right? I can figure out the test skipping for Node 18, but I still see tests fail on all versions of Node, so let's fix that and then I'll take over. |
|
Yes, right! Sorry I've had limited time for this, I'll get CI green today :) |
02b60df to
737b82a
Compare
|
Jest really dislikes conditionally skipping tests that contain snapshots (also when using |
This reverts commit 737b82a.
|
Ping? :) |
|
Oh apologies, I thought it was still in progress last time I checked. I'll get to it by Monday. |
cpojer
left a comment
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.
Thank you for doing this 🙇♂️
|
@nicolo-ribaudo this was released in Jest 30.2.0. |
|
Thank you! I'll now open a PR switching all of Jest packages to Babel 8. It will be a breaking change, and also feel free to wait until Babel 8 is stable to release it, but I need to make sure that everything works before the stable release :) |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The only remaining blocker for the Babel 8 stable release is to make sure that it works for major Babel consumers. This PR is the first step towards making Jest ready for it. It updates
babel-plugin-jest-hoist,babel-preset-jestandbabel-jestto support running with Babel 8 in addition to supporting Babel 7.Test plan
Tests updated to run both with Babel 7 and Babel 8.
Unfortunately, while the Babel plugins/presets maintained in this repo work reasonably well with Babel 8, Babel 8 itself cannot be loaded inside Jest-run tests, because it's written in ESM. Or maybe it's possible, but not the way that Jest is configured in this repo.
As a workaround, I'm loading the Babel 8 ESM packages using Node.js' native
require, rather than Jest's sandboxed version.Most of the diff in tests is indentation changes. I suggest disabling whitespace diff when reviewing.
(fyi @JLHwung @liuxingbaoyu)