Add compile() method to complement process() for transformers
See original GitHub issue🚀 Feature Proposal
Add support for a compile()
like method to complement process()
for transformers.
Motivation / Pitch
I’m writing an esm
loader and trying to make it work as the ESM support layer for Jest (without using Babel). I found I could make esm
provide a process()
method and be used as a "transform": "esm"
which is great! However, esm
anchors its runtime to the module
object created and ran through the wrapper()
. Normally this isn’t a problem, since esm
owns the implementation it handles this in Module#compile
or Module#_extensions
. However, Jest constructs modules from scratch so there is no place for esm
to hook into and decorate the module
object. A hook like compile
or init
or beforeCompile
would be one way of enabling this.
Related to https://github.com/facebook/jest/issues/4842#issuecomment-377134208.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:29 (14 by maintainers)
Top GitHub Comments
Ok, cool! I’m just not sure if we squeeze this in for v24. But since this is non breaking, I guess we can give it some more time.
Ah, that’s pretty neat!
@cpojer @aaronabramov do you have any thoughts on the API here? I would still like for this to be possible to use together with e.g. Babel, but if this is an OK first go we should do it.
We could also go crazy and have an
--esm
flag so it’s provided out of the box (like--coverage
is). Would be coupled to this implementation, but I think that’s fine?