{"action":"created","issue":{"url":"https://api.github.com/repos/ariporad/pirates/issues/1","labels_url":"https://api.github.com/repos/ariporad/pirates/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ariporad/pirates/issues/1/comments","events_url":"https://api.github.com/repos/ariporad/pirates/issues/1/events","html_url":"https://github.com/ariporad/pirates/issues/1","id":120310573,"number":1,"title":"Initial Discussion","user":{"login":"ariporad","id":1817508,"avatar_url":"https://avatars.githubusercontent.com/u/1817508?v=3","gravatar_id":"","url":"https://api.github.com/users/ariporad","html_url":"https://github.com/ariporad","followers_url":"https://api.github.com/users/ariporad/followers","following_url":"https://api.github.com/users/ariporad/following{/other_user}","gists_url":"https://api.github.com/users/ariporad/gists{/gist_id}","starred_url":"https://api.github.com/users/ariporad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariporad/subscriptions","organizations_url":"https://api.github.com/users/ariporad/orgs","repos_url":"https://api.github.com/users/ariporad/repos","events_url":"https://api.github.com/users/ariporad/events{/privacy}","received_events_url":"https://api.github.com/users/ariporad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ariporad/pirates/labels/discussion","name":"discussion","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ariporad/pirates/milestones/1","html_url":"https://github.com/ariporad/pirates/milestones/Inital%20Release","labels_url":"https://api.github.com/repos/ariporad/pirates/milestones/1/labels","id":1443269,"number":1,"title":"Inital Release","description":null,"creator":{"login":"ariporad","id":1817508,"avatar_url":"https://avatars.githubusercontent.com/u/1817508?v=3","gravatar_id":"","url":"https://api.github.com/users/ariporad","html_url":"https://github.com/ariporad","followers_url":"https://api.github.com/users/ariporad/followers","following_url":"https://api.github.com/users/ariporad/following{/other_user}","gists_url":"https://api.github.com/users/ariporad/gists{/gist_id}","starred_url":"https://api.github.com/users/ariporad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariporad/subscriptions","organizations_url":"https://api.github.com/users/ariporad/orgs","repos_url":"https://api.github.com/users/ariporad/repos","events_url":"https://api.github.com/users/ariporad/events{/privacy}","received_events_url":"https://api.github.com/users/ariporad/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"closed","created_at":"2015-12-04T01:15:29Z","updated_at":"2015-12-06T03:57:59Z","due_on":null,"closed_at":"2015-12-05T21:55:00Z"},"comments":1,"created_at":"2015-12-04T01:16:24Z","updated_at":"2015-12-06T03:57:59Z","closed_at":"2015-12-06T03:57:59Z","body":"Hi All,\r\nJust continuing bcoe/nyc#70 and babel/babel#3062.\r\n\r\nTo recap: I will be taking ideas from istanbul's and nyc's require-hook implementations, and trying to make something that:\r\n\r\n1. 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:\r\n    ```javascript\r\n    var pirates = require('pirates');\r\n    \r\n    // ...\r\n\r\n    pirates.addCompiler('.js', function (filename) {\r\n       return filename.indexOf('foo') !== -1;\r\n    }, function (module, filename) {\r\n        return this.addFile(module, filename).content; // Just return the new source for the module.\r\n    });\r\n    ```\r\n2. Using getters/setters, automatic fixing of hooks that don't use pirates, and still passing all requires through the hooks in order. API concept:\r\n\r\n    ```javascript\r\n    require('pirates/register');\r\n    // For some weird reason, part of my app is in coffee script, and some is in ES6.\r\n    require('coffee-script/register');\r\n    require('babel-core/regsister');\r\n    require('some-bad-module/register');\r\n    ```\r\n3. ???\r\n\r\nDiscuss.\r\n\r\ncc @bcoe, @gotwarlost, @stefanpenner, @jamestalmage, @sebmck"},"comment":{"url":"https://api.github.com/repos/ariporad/pirates/issues/comments/162268954","html_url":"https://github.com/ariporad/pirates/issues/1#issuecomment-162268954","issue_url":"https://api.github.com/repos/ariporad/pirates/issues/1","id":162268954,"user":{"login":"ariporad","id":1817508,"avatar_url":"https://avatars.githubusercontent.com/u/1817508?v=3","gravatar_id":"","url":"https://api.github.com/users/ariporad","html_url":"https://github.com/ariporad","followers_url":"https://api.github.com/users/ariporad/followers","following_url":"https://api.github.com/users/ariporad/following{/other_user}","gists_url":"https://api.github.com/users/ariporad/gists{/gist_id}","starred_url":"https://api.github.com/users/ariporad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariporad/subscriptions","organizations_url":"https://api.github.com/users/ariporad/orgs","repos_url":"https://api.github.com/users/ariporad/repos","events_url":"https://api.github.com/users/ariporad/events{/privacy}","received_events_url":"https://api.github.com/users/ariporad/received_events","type":"User","site_admin":false},"created_at":"2015-12-06T03:57:59Z","updated_at":"2015-12-06T03:57:59Z","body":"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/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!\r\n\r\nAfter 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.\r\n\r\nSince Pirates@1.0.0 has been released, I'm going to close this.\r\n\r\nEnjoy!"}}