Allow configuration of built in source transformers. #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey,
We needed the ability to configure the istanbul transformer, specifically so we could tell it to use of ES6 modules when requiring (by passing through
esModules: true
).I thought this might the best and most backwards compatible way of doing it - you can now specify configuration when registering a built-in transformer, and calling register for the same transformer after that will simply override the previous configuration. For the coffee transform, this configuration is passed straight into the
compile
call, and for istanbul this configuration is copied, then used to help detect if coverage is running (in case a customcoverageVariable
is specified), then passed into the instrumentation call.You can see I've not added any unit tests - I'll be honest, I wasn't sure the best way to test this. At least for the istanbul transformer, the instrumentation doesn't appear to be mocked, so there's not a nice way to check whether config is passed on. If you would like tests to be added I'd be happy to, with a little guidance.
Cheers!