You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To recap: I will be taking ideas from istanbul's and nyc's require-hook implementations, and trying to make something that:
Super easy require-hook injection, with a super simple API that Just Works(tm), feeding hooks into each other in the order they are added. API concept:
varpirates=require('pirates');// ...pirates.addCompiler('.js',function(filename){returnfilename.indexOf('foo')!==-1;},function(module,filename){returnthis.addFile(module,filename).content;// Just return the new source for the module.});
Using getters/setters, automatic fixing of hooks that don't use pirates, and still passing all requires through the hooks in order. API concept:
require('pirates/register');// For some weird reason, part of my app is in coffee script, and some is in ES6.require('coffee-script/register');require('babel-core/regsister');require('some-bad-module/register');
Ok everyone, I got pirates mostly done! It's now available on npm, and I've opened pull requests for babel (babel/babel#3139) and istanbul (istanbuljs-archived-repos/istanbul-lib-hook#5), and a PR for nyc is in the works. If you have any other modules you like that use require hooks, convince them to adopt pirates! It's super easy and reduces complexity!
After looking into having getters and setters for dealing with naughty require hooks, I ended up dropping that idea (for now), because basically any hook that misbehaves is using Module.prototype._compile instead of module._compile, which I haven't been able to figure out how to fix.
Hi All,
Just continuing istanbuljs/nyc#70 and babel/babel#3062.
To recap: I will be taking ideas from istanbul's and nyc's require-hook implementations, and trying to make something that:
Super easy require-hook injection, with a super simple API that Just Works(tm), feeding hooks into each other in the order they are added. API concept:
Using getters/setters, automatic fixing of hooks that don't use pirates, and still passing all requires through the hooks in order. API concept:
???
Discuss.
cc @bcoe, @gotwarlost, @stefanpenner, @jamestalmage, @sebmck
The text was updated successfully, but these errors were encountered: