-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-runtime: move babel-core to peer dependencies #4557
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #4557 +/- ##
=======================================
Coverage 56.16% 56.16%
=======================================
Files 185 185
Lines 6285 6285
Branches 3 3
=======================================
Hits 3530 3530
Misses 2754 2754
Partials 1 1 Continue to review full report at Codecov.
|
This change means that you get a peer dep warning if you do not depend on babel-core somewhere in your tree. Then you have to install it manually, or tests WILL fail to execute.
Not sure how to handle it. It's not really nice that people not using babel at all will have to install babel-core manually just to be able to use Jest. |
@hzoo Your input would be greatly appreciated here. Issue:
Is there some way you know of to achieve the following:
|
Babel packages were moved to npm scope since v7 beta 5, could we add support for future versions of babel by using latest babel if available? Maybe something like this: let transform;
let babelTransform;
try {
({ transform, babelTransform } = require('@babel/core'));
} catch (error) {
({ transform, babelTransform } = require('babel-core'));
}
// ... |
Auch, that actually makes it even worse for us. @cpojer maybe we add babel-core as a dep in jest, and do |
Since
Does that apply to For For
then this
to get all three packages. Otherwise the existing Then we could also do the opposite so once packages change the peerDep to
thoughts? |
@loganfsmyth The problem was that tests failed due to syntax errors (such as ones that point to import declarations) which means that
It kind of did, but Also what about |
Both. Jest uses babel for a couple of things:
(I think that's it) I like the idea of a bridge module. What I really want is to use the user's installed babel-core if it exists. If it does not, I want to provide my own. I guess a bridging module combined with |
Let me break down my thoughts a bit more. The two places:
I think given that, you can just rely on the user to install the correct babel-core that correlates with their |
Was the bridge package created? |
@cpojer thoughts here? |
I think it would be great if we could stop using babel-jest in jest-runtime but instead use babel for code coverage more directly. Could we make that happen? |
@cpojer We could make a bridge package |
I'm not sure what the best solution is but it makes sense to me that:
We can make the change to both right now because the next Jest release will be a major. |
I personaly liked @loganfsmyth's idea of having a bridge package as a way to select which core to load. For now I edited my local jest package to load |
I've just now published
as a generic block to support all of 6.x and 7.x, including the 7.x alphas, betas, and the new bridge package. You'll just need some docs for users on how to install the bridge package, if they want to use
|
This reverts commit 1fcffab.
Awesome guys!, this is exciting!. For the time being, I have it working with |
Do you need the second package? It would be great to have an example in the docs with how to use babel 7 and jest together |
I added it in my PR see https://facebook.github.io/jest/docs/en/getting-started.html#using-babel |
I believe this has been published in |
|
hmm I might be dumb then, because:
|
you are missing |
@danez, I wasn't sure about that one :D, and I installed instead
?? |
That seems to come from your zsh, that tries to do something with the command, maybe need to escape the ^ |
Ohh you are right!, I missed that, thanks!, and sorry for the noise then! |
Should we put the command in quotes in the readme so it's more copy-pasteable? PR welcome! 🙂 |
It's great that we have a workaround. But is there any plan to make |
Not for now as that would stop babel 6 from working. After babel 7 is promoted to stable that might change, but for now we'll keep the current behaviour |
Gidday @SimenB - now that Babel 7 is stable has this progressed at all? |
See #6949 |
What if we could use In other words, how about if we combine the bridge with |
Install Jest 24, released today, and you don't need the bridge module anymore - just use |
@SimenB could you expand on 'just use |
Please see the docs: https://jestjs.io/docs/en/getting-started#using-babel Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions. |
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
It's still not possible to use Jest with Babel 7 due to some kind of a conflict between Babel versions because
jest-runtime
requiresbabel-core@^6
. Movingbabel-core
to peer dependencies such as inbabel-jest
resolves the problem.Test plan
Existing tests should pass.