-
Notifications
You must be signed in to change notification settings - Fork 392
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
fix(jest-transformer): add babel-preset-jest dependency #1112
Conversation
Benchmark resultsBase commit: lwc-engine-benchmark
|
@@ -16,6 +16,7 @@ | |||
"@babel/plugin-transform-modules-commonjs": "7.1.0", | |||
"@babel/template": "~7.1.2", | |||
"@lwc/errors": "0.37.0", | |||
"babel-preset-jest": "^24.0.0", | |||
"deasync": "0.1.14" | |||
}, | |||
"peerDependencies": { |
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.
Shall we add instead jest
as a peer dependency?
How does other jest transformers deal with this?
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.
We can add jest
as a peer dependency, but we still need a dependency here on babel-preset-jest
. This package works with the latest versions of Jest (and I encourage users to stay relatively current), but babel-preset-jest
isn't accessible from this package even if the consuming project has a jest
dependency.
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.
Actually, I don't think we need jest
as a peer dependency here. This package declares it's own dependencies for the what it uses and the input/output of the transformer hasn't changed in recent versions. It takes in the source code and file path and returns the compiled/transformed code. That should work for older and newer versions of Jest.
We can add a peer dependency for Jest 24 because that's what we want consumers to use but it won't break them to be on Jest 23 so I don't think we should burden them with the warning message if it's not a hard requirement.
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.
You are assuming here that jest has not introduced a breaking change in babel-preset-jest
between 23 and 24.
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.
The only breaking change Jest listed between 23 and 24 for this package was for to a change that required Babel 7, but the transformer has been on 7 for a while.
I can add the peer dependency just to be safe. I feel like this is moving in a direction where we want the Jest related packages in here to match the Jest major versions though. Similar to how ts-jest
does it.
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
The Jest transformer imports and uses
babel-preset-jest
directly but does not declare it as a dependency.Although always not fully correct, this did not result in any errors before because the dependency would get hoisted to the project level
node_modules
via other Jest dependencies anyway. In newer versions of Jest, however,babel-preset-jest
is nested injest-config/node_modules
and not accessible by the transformer.Does this PR introduce a breaking change?