{"action":"opened","issue":{"url":"https://api.github.com/repos/broccolijs/broccoli-plugin/issues/10","labels_url":"https://api.github.com/repos/broccolijs/broccoli-plugin/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/broccolijs/broccoli-plugin/issues/10/comments","events_url":"https://api.github.com/repos/broccolijs/broccoli-plugin/issues/10/events","html_url":"https://github.com/broccolijs/broccoli-plugin/issues/10","id":127262031,"number":10,"title":"Example code fails with TypeError: Missing `new` operator","user":{"login":"gcharnock","id":164683,"avatar_url":"https://avatars.githubusercontent.com/u/164683?v=3","gravatar_id":"","url":"https://api.github.com/users/gcharnock","html_url":"https://github.com/gcharnock","followers_url":"https://api.github.com/users/gcharnock/followers","following_url":"https://api.github.com/users/gcharnock/following{/other_user}","gists_url":"https://api.github.com/users/gcharnock/gists{/gist_id}","starred_url":"https://api.github.com/users/gcharnock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcharnock/subscriptions","organizations_url":"https://api.github.com/users/gcharnock/orgs","repos_url":"https://api.github.com/users/gcharnock/repos","events_url":"https://api.github.com/users/gcharnock/events{/privacy}","received_events_url":"https://api.github.com/users/gcharnock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-18T16:29:16Z","updated_at":"2016-01-18T16:29:16Z","closed_at":null,"body":"Trying to run the sample plugin against `broccoli-plugin-1.2.1` fails with the following error:\r\n\r\n```\r\n/home/gareth2/dev/react-redux-tutorial/node_modules/broccoli-plugin/index.js:5\r\n  if (!(this instanceof Plugin)) throw new TypeError('Missing `new` operator')\r\n                                 ^\r\n\r\nTypeError: Missing `new` operator\r\n    at Plugin (/home/gareth2/dev/react-redux-tutorial/node_modules/broccoli-plugin/index.js:5:40)\r\n    at MyPlugin (/home/gareth2/dev/react-redux-tutorial/broccoli-plugins/babel.js:10:10)\r\n    at Object.<anonymous> (/home/gareth2/dev/react-redux-tutorial/Brocfile.js:10:10)\r\n    at Module._compile (module.js:434:26)\r\n    at Object.Module._extensions..js (module.js:452:10)\r\n    at Module.load (module.js:355:32)\r\n    at Function.Module._load (module.js:310:12)\r\n    at Module.require (module.js:365:17)\r\n    at require (module.js:384:17)\r\n    at Object.loadBrocfile (/home/gareth2/dev/react-redux-tutorial/node_modules/broccoli/lib/builder.js:245:14)\r\n```\r\n\r\nMy guess is that the `if (!(this instanceof Plugin)) throw new TypeError('Missing `new` operator')` broke the example when it was added?\r\n\r\n```\r\nvar Plugin = require('broccoli-plugin');\r\nvar path = require('path');\r\n\r\n// Create a subclass MyPlugin derived from Plugin\r\nMyPlugin.prototype = Object.create(Plugin.prototype);\r\nMyPlugin.prototype.constructor = MyPlugin;\r\nfunction MyPlugin(inputNodes, options) {\r\n  options = options || {};\r\n  Plugin.call(this, inputNodes, {\r\n    annotation: options.annotation\r\n  });\r\n  this.options = options;\r\n}\r\n\r\nMyPlugin.prototype.build = function() {\r\n  // Read files from this.inputPaths, and write files to this.outputPath.\r\n  // Silly example:\r\n\r\n  // Read 'foo.txt' from the third input node\r\n  var inputBuffer = fs.readFileSync(path.join(this.inputPaths[2], 'foo.txt'));\r\n  var outputBuffer = someCompiler(inputBuffer);\r\n  // Write to 'bar.txt' in this node's output\r\n  fs.writeFileSync(path.join(this.outputPath, 'bar.txt'), outputBuffer);\r\n};\r\n```"}}