-
-
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
feat(jest-transform): support transformers written in ESM #11163
Conversation
@@ -46,9 +49,6 @@ const setupTransform = (config, rootDir) => { | |||
}; | |||
|
|||
module.exports = async function createRuntime(filename, config) { | |||
const {default: NodeEnvironment} = await import('jest-environment-node'); |
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.
import
in tests doesn't work anymore since I removed the babel plugin
let transformer: Transformer; | ||
|
||
try { | ||
transformer = require(transformPath); |
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 might consider adding a Map
to the module scope for the require
and import
calls. However, they should be by reference when called multiple times in the same context, so I don't think the overhead is necessarily worth it?
Codecov Report
@@ Coverage Diff @@
## master #11163 +/- ##
==========================================
- Coverage 64.20% 64.14% -0.06%
==========================================
Files 307 307
Lines 13364 13373 +9
Branches 3257 3259 +2
==========================================
- Hits 8580 8578 -2
- Misses 4080 4089 +9
- Partials 704 706 +2
Continue to review full report at Codecov.
|
yeyyyyyyyyyyyy |
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
This allows people to write their transformers in ESM. This is mostly a refactor since
import()
is async, I've changedScriptTransformer
to load all transformers when it's created rather than on demand.To not force all consumers to call
load
, I now expose more of a factory method which does the extra function call for the user.This solves the use case behind #11081, but I think that issue might be useful for other async work.
I'll need to update docs here, but I'll do that after landing docusaurus 2Just added a line, I think since we don't mess with versioned docs it should be fineTest plan
E2E test added