{"action":"created","issue":{"url":"https://api.github.com/repos/reactjs/react-rails/issues/181","labels_url":"https://api.github.com/repos/reactjs/react-rails/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/react-rails/issues/181/comments","events_url":"https://api.github.com/repos/reactjs/react-rails/issues/181/events","html_url":"https://github.com/reactjs/react-rails/issues/181","id":58519908,"number":181,"title":"Can't render browserified JS on server side","user":{"login":"elvanja","id":674883,"avatar_url":"https://avatars.githubusercontent.com/u/674883?v=3","gravatar_id":"","url":"https://api.github.com/users/elvanja","html_url":"https://github.com/elvanja","followers_url":"https://api.github.com/users/elvanja/followers","following_url":"https://api.github.com/users/elvanja/following{/other_user}","gists_url":"https://api.github.com/users/elvanja/gists{/gist_id}","starred_url":"https://api.github.com/users/elvanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elvanja/subscriptions","organizations_url":"https://api.github.com/users/elvanja/orgs","repos_url":"https://api.github.com/users/elvanja/repos","events_url":"https://api.github.com/users/elvanja/events{/privacy}","received_events_url":"https://api.github.com/users/elvanja/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-02-22T21:24:38Z","updated_at":"2015-02-25T07:54:01Z","closed_at":null,"body":"Hi!\r\n\r\nI am trying to use this gem with CommonJS style written components. Followed https://medium.com/@olance/rails-react-browserify-e315001d5974 and got things to work client side, but the ```prerender: true``` gives me:\r\n\r\n```ruby\r\nEncountered error \"Error: Cannot find module 'function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}'\" when prerendering ThingsTable with {\"initialThings\":[{\"id\":1,\"name\":\"Test\"}]}\r\n```\r\n\r\nThe ```function e(t,n,r)``` comes from browserify output, e.g. ```browserify -t [ coffeeify --extension .coffee ] -t [ reactify --extension .jsx.coffee ] --extension .js.jsx.coffee app/assets/javascripts/components/things_table.js.jsx.coffee``` will result in JS that is wrapped just like the error says. Can't understand exactly why it woks on client side and not on the server.\r\n\r\nThe environment is pretty much the same as in the given article, but with a few changes:\r\n\r\npackage.json:\r\n```json\r\n{\r\n  \"name\": \"thingy\",\r\n  \"devDependencies\" : {\r\n    \"browserify\": \"~> 9.0.3\",\r\n    \"browserify-incremental\": \"^1.5\",\r\n    \"reactify\": \"~> 1.0.0\",\r\n    \"coffeeify\": \"~> 1.0.0\",\r\n    \"flux\": \"~> 2.0\"\r\n  },\r\n  \"license\": \"MIT\",\r\n  \"engines\": {\r\n    \"node\": \">= 0.10\"\r\n  }\r\n}\r\n```\r\n\r\nGemfile:\r\n```ruby\r\ngem 'browserify-rails', '~> 0.7' # https://github.com/browserify-rails/browserify-rails\r\ngem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails' # https://github.com/reactjs/react-rails\r\n```\r\n\r\nconfig/application.rb (browserify configuration):\r\n```ruby\r\n    config.browserify_rails.commandline_options = [\r\n        '-t [ coffeeify --extension .coffee ]', # coffeescript support\r\n        '-t [ reactify --extension .jsx.coffee ]', # react/jsx support\r\n        '--extension .js.jsx.coffee' # to be able to remove extension from require\r\n    ]\r\n```\r\n\r\nAnd an example of the component:\r\n```coffeescript\r\nThingsTableHeader = require(\"./things_table_header.js.jsx.coffee\")\r\nThingsTableRow = require(\"./things_table_row.js.jsx.coffee\")\r\n\r\nThingsTable = React.createClass\r\n  getInitialState: ->\r\n    { things: @props.initialThings }\r\n\r\n  render: ->\r\n    row = (thing) -> `(<ThingsTableRow key={thing.id} thing={thing} />)`\r\n\r\n    `(\r\n    <div className=\"panel panel-default\">\r\n      <div className=\"panel-heading\">\r\n        <h2 className=\"panel-title\">Things</h2>\r\n      </div>\r\n\r\n      <div className=\"panel-body\">\r\n        <div className=\"table-responsive\">\r\n          <table className=\"table table-hover tablesorter\">\r\n            <ThingsTableHeader />\r\n            <tbody>\r\n              {this.state.things.map(row)}\r\n            </tbody>\r\n          </table>\r\n        </div>\r\n      </div>\r\n    </div>\r\n  )`\r\n\r\nmodule.exports = window.ThingsTable\r\nwindow.ThingsTable = ThingsTable # required by react_component view helper\r\n```\r\nSo basically everything is required, only the main component is still on ```window``` because of the view helper.\r\n\r\nI read issues #55, #120 & #90 which might be related, but I am not sure, hence the new issue."},"comment":{"url":"https://api.github.com/repos/reactjs/react-rails/issues/comments/75919415","html_url":"https://github.com/reactjs/react-rails/issues/181#issuecomment-75919415","issue_url":"https://api.github.com/repos/reactjs/react-rails/issues/181","id":75919415,"user":{"login":"elvanja","id":674883,"avatar_url":"https://avatars.githubusercontent.com/u/674883?v=3","gravatar_id":"","url":"https://api.github.com/users/elvanja","html_url":"https://github.com/elvanja","followers_url":"https://api.github.com/users/elvanja/followers","following_url":"https://api.github.com/users/elvanja/following{/other_user}","gists_url":"https://api.github.com/users/elvanja/gists{/gist_id}","starred_url":"https://api.github.com/users/elvanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elvanja/subscriptions","organizations_url":"https://api.github.com/users/elvanja/orgs","repos_url":"https://api.github.com/users/elvanja/repos","events_url":"https://api.github.com/users/elvanja/events{/privacy}","received_events_url":"https://api.github.com/users/elvanja/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T07:54:01Z","updated_at":"2015-02-25T07:54:01Z","body":"@bogdan-dumitru yep, you're right. Thanks for the tip! Doesn't change the result though..."}}