{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/mobx-react/issues/43","repository_url":"https://api.github.com/repos/mobxjs/mobx-react","labels_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/43/comments","events_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/43/events","html_url":"https://github.com/mobxjs/mobx-react/issues/43","id":151929197,"number":43,"title":"Rollup error: Module does not export observer","user":{"login":"Nedlinin","id":298264,"avatar_url":"https://avatars.githubusercontent.com/u/298264?v=3","gravatar_id":"","url":"https://api.github.com/users/Nedlinin","html_url":"https://github.com/Nedlinin","followers_url":"https://api.github.com/users/Nedlinin/followers","following_url":"https://api.github.com/users/Nedlinin/following{/other_user}","gists_url":"https://api.github.com/users/Nedlinin/gists{/gist_id}","starred_url":"https://api.github.com/users/Nedlinin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nedlinin/subscriptions","organizations_url":"https://api.github.com/users/Nedlinin/orgs","repos_url":"https://api.github.com/users/Nedlinin/repos","events_url":"https://api.github.com/users/Nedlinin/events{/privacy}","received_events_url":"https://api.github.com/users/Nedlinin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-04-29T17:34:37Z","updated_at":"2016-09-06T01:01:41Z","closed_at":"2016-06-02T15:09:56Z","body":"Trying to work mobx-react into one of my projects but I'm having issues getting it to play nicely with Rollup.\r\n\r\n     Error: Module c:\\Users\\cheath\\Desktop\\front-end\\node_modules\\mobx-react\\index.js does not export observer\r\n\r\nTrying to import the lib and decorate a class:\r\n\r\n    ....\r\n    import {observer} from \"mobx-react\";\r\n\r\n    @observer\r\n    class Header extends React.Component {\r\n    ....\r\n\r\n\r\nI can seemingly make it work by making the following mods:\r\n\r\n    //mobx-react/index.js\r\n    // Move the export order around.  This project uses Dojo and if the AMD define is before the common we get some issues..\r\n    // UMD\r\n     if (typeof exports === 'object') {\r\n        module.exports = mrFactory(require('mobx'), require('react'), require('react-dom'));\r\n     } else if (typeof define === 'function' && define.amd) {\r\n\t\tdefine('mobx-react', ['mobx', 'react', 'react-dom'], mrFactory);\r\n     } else {\r\n        this.mobxReact = mrFactory(this['mobx'], this['React'], this['ReactDOM']);\r\n     }\r\n\r\nAnd changing my usage in my component to:\r\n\r\n     ....\r\n    import * as MobX from \"mobx-react\";\r\n\r\n    @MobX.default.observer\r\n    class Header extends React.Component {\r\n    ....\r\n\r\n\r\nObviously this is a bit of a clunky fix and I am hoping for a better solution.\r\n\r\n\r\nMy Rollup config:\r\n\r\n    gulp.task(\"bundle\", function () {\r\n\treturn rollup.rollup({\r\n\t\tentry: \"./src/main.js\",\r\n\t\tplugins: [\r\n\t\t\tnodeResolve({\r\n\t\t\t\tmain: true,\r\n\t\t\t\tskip: [ \"esri\" ] // Let Dojo handle Esri\r\n\t\t\t}),\r\n\t\t\tcommonjs(),\r\n\t\t\trollupPostcss({\r\n\t\t\t\tplugins: [\r\n\t\t\t\t\trequire(\"autoprefixer\"),\r\n\t\t\t\t\trequire(\"precss\")\r\n\t\t\t\t]\r\n\t\t\t}),\r\n\t\t\treplace({\r\n\t\t\t\t\"process.env.NODE_ENV\": '\"development\"'\r\n\t\t\t}),\r\n\t\t\tbabel({\r\n\t\t\t\texclude: \"node_modules/**\"\r\n\t\t\t})\r\n\t\t]\r\n\t}).then(function(bundle) {\r\n\t\tbundle.write({\r\n\t\t\tformat: \"amd\", // AMD is Dojo compatible\r\n\t\t\tdest: \"build/app/main.js\",\r\n\t\t\tsourceMap: true\r\n\t\t});\r\n\t})\r\n    });\r\n"},"comment":{"url":"https://api.github.com/repos/mobxjs/mobx-react/issues/comments/244827255","html_url":"https://github.com/mobxjs/mobx-react/issues/43#issuecomment-244827255","issue_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/43","id":244827255,"user":{"login":"zwhitchcox","id":4328800,"avatar_url":"https://avatars.githubusercontent.com/u/4328800?v=3","gravatar_id":"","url":"https://api.github.com/users/zwhitchcox","html_url":"https://github.com/zwhitchcox","followers_url":"https://api.github.com/users/zwhitchcox/followers","following_url":"https://api.github.com/users/zwhitchcox/following{/other_user}","gists_url":"https://api.github.com/users/zwhitchcox/gists{/gist_id}","starred_url":"https://api.github.com/users/zwhitchcox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zwhitchcox/subscriptions","organizations_url":"https://api.github.com/users/zwhitchcox/orgs","repos_url":"https://api.github.com/users/zwhitchcox/repos","events_url":"https://api.github.com/users/zwhitchcox/events{/privacy}","received_events_url":"https://api.github.com/users/zwhitchcox/received_events","type":"User","site_admin":false},"created_at":"2016-09-06T01:01:40Z","updated_at":"2016-09-06T01:01:40Z","body":"I'm getting this error: \r\n```\r\nCould not resolve 'react-dom' from /home/zane/src/ashworth-firm/node_modules/mobx-react/index.js\r\nError: Could not resolve 'react-dom' from /home/zane/src/ashworth-firm/node_modules/mobx-react/index.js\r\n    at Error (native)\r\n    at /home/zane/src/ashworth-firm/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:78:21\r\n    at /home/zane/src/ashworth-firm/node_modules/browser-resolve/index.js:265:24\r\n    at /home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:46:14\r\n    at process (/home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:173:43)\r\n    at ondir (/home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:188:17)\r\n    at load (/home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:69:43)\r\n    at onex (/home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:92:31)\r\n    at /home/zane/src/ashworth-firm/node_modules/resolve/lib/async.js:22:47\r\n    at FSReqWrap.oncomplete (fs.js:123:15)\r\nType rollup --help for help, or visit https://github.com/rollup/rollup/wiki\r\n```\r\n\r\nThis is my config:\r\n\r\n```js\r\n  1 import babel from 'rollup-plugin-babel'                                                                                                 \r\n  2 import commonjs from 'rollup-plugin-commonjs'                                                                                           \r\n  3 import nodeResolve from 'rollup-plugin-node-resolve'                                                                                    \r\n  4                                                                                                                                         \r\n  5 const babelOpts = {                                                                                                                     \r\n  6   presets: [                                                                                                                            \r\n  7     [                                                                                                                                   \r\n  8       'es2015',                                                                                                                         \r\n  9       {                                                                                                                                 \r\n 10         modules: false                                                                                                                  \r\n 11       }                                                                                                                                 \r\n 12     ],                                                                                                                                  \r\n 13     'stage-0',                                                                                                                          \r\n 14     'react',                                                                                                                            \r\n 15   ],                                                                                                                                    \r\n 16   exclude: 'node_modules/**',                                                                                                           \r\n 17   plugins: [                                                                                                                            \r\n 18     'external-helpers',                                                                                                                 \r\n 19     'transform-decorators-legacy',                                                                                                      \r\n 20   ],                                                                                                                                    \r\n 21   babelrc: false,                                                                                                                       \r\n 22 }                                                                                                                                       \r\n 23                                                                                                                                         \r\n 24 export default {                                                                                                                        \r\n 25   entry: 'src/app.js',                                                                                                                  \r\n 26   dest: 'build/assets/bundle.js',                                                                                                       \r\n 27   sourceMap: 'true',                                                                                                                    \r\n 28   plugins: [                                                                                                                            \r\n 29     babel(babelOpts),                                                                                                                   \r\n 30     nodeResolve({                                                                                                                       \r\n 31       jsnext: true,                                                                                                                     \r\n 32       main: true,                                                                                                                       \r\n 33       browser: true,                                                                                                                    \r\n 34       extensions: [ '.js', '.jsx' ],                                                                                                    \r\n 35     }),                                                                                                                                 \r\n 36     commonjs({                                                                                                                          \r\n 37       include: 'node_modules/**'                                                                                                        \r\n 38     }),                                                                                                                                 \r\n 39   ],                                                                                                                                    \r\n 40 };  \r\n```"}}
{"actor":{"display_login":"zwhitchcox"}}