felixge / node-sandboxed-module

A sandboxed node.js module loader that lets you inject dependencies into your modules.
MIT License
342 stars 42 forks source link

Allow configuration of built in source transformers. #58

Open m-orchard opened 8 years ago

m-orchard commented 8 years ago

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 custom coverageVariable 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!

m-orchard commented 8 years ago

I see the failure, I'll try to get that sorted.

m-orchard commented 8 years ago

Tests fixed. If you can offer any guidance on whether/how you want to test config being passed down, that would be great, but either way I will try to find time to write some.

domenic commented 8 years ago

I don't have much time to review these patches these days, and it seems like the other maintainers don't either. In the past @felixge has been willing to add new collaborators for cases like this; would that work for you?

felixge commented 8 years ago

I'd be happy to add @mickylad as a collaborator.

m-orchard commented 8 years ago

Super slow response, sorry! I'm happy to be added as a contributor if you want - anything you need from me?

felixge commented 8 years ago

@mickylad slow reply from me too :). I need your npm user name so I can add you as an owner.

m-orchard commented 8 years ago

@felixge itsmickylad - just signed up! :)

felixge commented 8 years ago

@mickylad added you on GH and NPM.