{"action":"created","issue":{"url":"https://api.github.com/repos/parcel-bundler/parcel/issues/1181","repository_url":"https://api.github.com/repos/parcel-bundler/parcel","labels_url":"https://api.github.com/repos/parcel-bundler/parcel/issues/1181/labels{/name}","comments_url":"https://api.github.com/repos/parcel-bundler/parcel/issues/1181/comments","events_url":"https://api.github.com/repos/parcel-bundler/parcel/issues/1181/events","html_url":"https://github.com/parcel-bundler/parcel/issues/1181","id":314007870,"node_id":"MDU6SXNzdWUzMTQwMDc4NzA=","number":1181,"title":"Parcel sometimes doesn't use the browser version of libraries","user":{"login":"download13","id":575088,"node_id":"MDQ6VXNlcjU3NTA4OA==","avatar_url":"https://avatars2.githubusercontent.com/u/575088?v=4","gravatar_id":"","url":"https://api.github.com/users/download13","html_url":"https://github.com/download13","followers_url":"https://api.github.com/users/download13/followers","following_url":"https://api.github.com/users/download13/following{/other_user}","gists_url":"https://api.github.com/users/download13/gists{/gist_id}","starred_url":"https://api.github.com/users/download13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/download13/subscriptions","organizations_url":"https://api.github.com/users/download13/orgs","repos_url":"https://api.github.com/users/download13/repos","events_url":"https://api.github.com/users/download13/events{/privacy}","received_events_url":"https://api.github.com/users/download13/received_events","type":"User","site_admin":false},"labels":[{"id":663703608,"node_id":"MDU6TGFiZWw2NjM3MDM2MDg=","url":"https://api.github.com/repos/parcel-bundler/parcel/labels/:bug:%20Bug","name":":bug: Bug","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-13T08:06:44Z","updated_at":"2018-06-28T18:58:16Z","closed_at":null,"author_association":"NONE","body":"🐛 bug report\r\n\r\nVery simple to reproduce.\r\n\r\nPut `import 'readable-stream';` into a js file.\r\n\r\nRun `parcel build -d outdir file.js --no-minify`. The no-minify flag isn't required, just makes it easier to find out what's going on.\r\n\r\nUse a script tag to load the built file in a browser.\r\n\r\n### 🤔 Expected Behavior\r\n\r\nNothing is shown in the console, since basically nothing happened.\r\n\r\n### 😯 Current Behavior\r\n\r\n```\r\nUncaught TypeError: Object prototype may only be an Object or null: undefined\r\n    at Function.create (<anonymous>)\r\n    at Object.function.Object.create.module.exports [as inherits] (player.js:12)\r\n    at Object.parcelRequire.50.process-nextick-args (player.js:43)\r\n    at u (player.js:1)\r\n    at a (player.js:1)\r\n    at Object.parcelRequire.45../lib/_stream_writable.js (player.js:61)\r\n    at u (player.js:1)\r\n    at a (player.js:1)\r\n    at Object.parcelRequire.42.events (player.js:69)\r\n    at u (player.js:1)\r\n```\r\n\r\nI tracked it back to [a line](https://github.com/nodejs/readable-stream/blob/master/lib/_stream_writable.js#L96) that runs `util.inherits(Writable, Stream);`\r\n\r\nThe error is being thrown when `util.inherits` tries to create an object using the ancestor's prototype. In this case, Stream.prototype turns out to be `undefined`. The reason for this seems to be that parcel is importing the node version of the module instead of the browser version.\r\n\r\nStream is imported by [the line](https://github.com/nodejs/readable-stream/blob/master/lib/_stream_writable.js#L78) `var Stream = require('./internal/streams/stream');` which, according to the [package.json file](https://github.com/nodejs/readable-stream/blob/master/package.json#L44) should redirect to `./lib/internal/streams/stream-browser.js` when compiling for the browser.\r\n\r\nIt doesn't seem to be getting redirected though. If I hunt through the bundle for the module addressed as `./internal/streams/stream`, I find this:\r\n\r\n```\r\n[function(require,module,exports) {\r\nmodule.exports = require('stream');\r\n\r\n},{\"stream\":20}]\r\n```\r\n\r\nThat is the contents of [stream.js](https://github.com/nodejs/readable-stream/blob/master/lib/internal/streams/stream.js), not [stream-browser.js](https://github.com/nodejs/readable-stream/blob/master/lib/internal/streams/stream-browser.js) as it should be.\r\n\r\nI also had this happen with another library (webtorrent) briefly pulling in the `net` node module and crashing because of it. That problem went away without explanation though, while this one seems to be easily reproducible."},"comment":{"url":"https://api.github.com/repos/parcel-bundler/parcel/issues/comments/401138588","html_url":"https://github.com/parcel-bundler/parcel/issues/1181#issuecomment-401138588","issue_url":"https://api.github.com/repos/parcel-bundler/parcel/issues/1181","id":401138588,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTEzODU4OA==","user":{"login":"alidcastano","id":11031952,"node_id":"MDQ6VXNlcjExMDMxOTUy","avatar_url":"https://avatars0.githubusercontent.com/u/11031952?v=4","gravatar_id":"","url":"https://api.github.com/users/alidcastano","html_url":"https://github.com/alidcastano","followers_url":"https://api.github.com/users/alidcastano/followers","following_url":"https://api.github.com/users/alidcastano/following{/other_user}","gists_url":"https://api.github.com/users/alidcastano/gists{/gist_id}","starred_url":"https://api.github.com/users/alidcastano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alidcastano/subscriptions","organizations_url":"https://api.github.com/users/alidcastano/orgs","repos_url":"https://api.github.com/users/alidcastano/repos","events_url":"https://api.github.com/users/alidcastano/events{/privacy}","received_events_url":"https://api.github.com/users/alidcastano/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T18:58:16Z","updated_at":"2018-06-28T18:58:16Z","author_association":"NONE","body":"Not sure if it's related but I'm getting an `Object prototype may only be an Object or null: undefined` error as well and I'm building both browser and node versions of my bundle\r\n\r\nWith the same code, sometimes the error shows up, sometimes it doesn't. I have to delete build file and restart app to get it to work. Having to do this multiple times makes Parcel slower than Webpack haha"}}
{"actor":{"display_login":"alidcastano"}}