Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Gregorio Setti
    i don't know why, but it keeps telling
    ActionView::Template::Error (Error: Parse Error: Line 2: Illegal import declaration
      (in app/assets/javascripts/components/simple_map.js.jsx)):
    I've tried with es6ify too
    but it didn't work
    any idea/suggestion?
    Gregorio Setti
    Hi guys, is anybody experiencing this? facebook/react#3320
    I'm having hard time trying to make react components work with browserify rails
    the weird thing is that if I include those components with sprockets it works
    as soon as I compile them with browserify, it throws errors
    Harry Moreno
    @desmondhume have you looked into https://github.com/TannerRogalsky/sprockets-es6 ?
    but yeah if you add the babel browserify transform https://github.com/babel/babelify that could work
    Cymen Vig
    @desmondhume are the components using es6 as in import and such? Right now, browserify-rails is not detecting ES6 -- it detects based on the presence of require and module.exports -- you can force it to always browserify your JavaScript though so you could try that too.
    oh, if it is jsx, hrm... are you using reactify?
    Gregorio Setti
    @cymen @morenoh149 thank you guys
    everything's working fine with
    [babelify --stage 0] argument
    in the browserify rails config
    it works also with some es7 featues, super!
    Gregorio Setti
    Hi everybody! I just noticed these two lines in my rails logs
    Browserify: /Users/macbookair/Sites/dude-buddy/node_modules/.bin/browserifyinc -t [babelify --stage 0] --extension=".jsx" --list --cachefile=\"/Users/macbookair/Sites/dude-buddy/tmp/cache/browserify-rails/browserifyinc-cache.json\" -o "/Users/macbookair/Sites/dude-buddy/tmp/cache/browserify-rails/output20150623-8917-3wlawr" -
    Browserify: /Users/macbookair/Sites/dude-buddy/node_modules/.bin/browserifyinc -t [babelify --stage 0] --extension=".jsx" --cachefile=\"/Users/macbookair/Sites/dude-buddy/tmp/cache/browserify-rails/browserifyinc-cache.json\" -o "/Users/macbookair/Sites/dude-buddy/tmp/cache/browserify-rails/output20150623-8917-5nqdxw" -
    it seems like it compiles twice
    is it expected behaviour or am i doing something wrong?
    Cymen Vig
    @desmondhume That is normal — there is a —list call first
    which lists the dependencies of the module
    the second one actuallys compiles it
    Orlando Del Aguila
    Hello guys, I have browserify-rails working correctly, but I don't use it for all my files
    bundles are still being compiled by Sprockets
    I'm looking to add source maps to our production environment, and sprockets doesn't support this feature.
    Is it posible to ignore sprockets completely and only use browserify-rails to compile bundles (like don't use //= require 'bla' anymore and instead use require('bla'))
    Orlando Del Aguila
    I opened an issue, just in case someone from the channel can give me some guidance browserify-rails/browserify-rails#99
    Tyler Davis
    Hey folks, I've been using browserify-rails for some time now with great success, but recently I started receiving a javascript error in one of my applications, "Uncaught ReferenceError: require is not defined". I'm not getting this error on any other application on my dev box. Is there a good starting point for debugging something like this?
    Cymen Vig
    @tylerdavis I recommend using the google chrome debugger and clicking the little button that looks like a pause button to catch uncaught exceptions — then go up the stack to try to find the require
    it can get confusing
    my other recommendation is to put all of the non-CommonJS code into a separate asset file — so say you had regular jQuery, put that in some asset bundle like lib.js or something — all the //= sprocket stuff could go in there and then have one bundle that is just the CommonJS stuff (that uses require)
    re: the chrome debugger — you can google “chrome javascript pause on exception” to get some more details on how to use the debugger
    Mike Levine

    Hey guys, Wondering if you might offer me some advice: I have downloaded 'material-ui' package and added to my package.json file through NPM. It is displaying in my package.json file. However, I'm not able to access components like AppBar as my browser is telling me it's not defined. I've attempted adding a global variable in my application.js file, but this isn actually crashing the app:

    var MaterialUI = require('material-ui');

    I'm using Rails 4 and Ruby 2.1 with Browserify. Definitely frustrating, I just can't figure out what I'm doing wrong. Thank you for any help/pointers in the right direction you can give me!

    Renaud Chaput
    Hi ! I am having a problem with browserify and assets precompilation. When I grep the resulting JS files, I cant find any code related to the JS files I have required. Like if browserify-rails isnt triggered by assets:precompile. Any ideas ?
    Cymen Vig
    Hey, it would be best to file issues on github. Unfortunately, I now have too many different chat options (slack, discord and glitter).
    @renchap have you included browserify-rails in your production gems?
    it needs to be in production for the asset compilation
    it doesn't actually do anything further
    but if it isn't in production, it won't be loaded during asset compile and that will have the result you mention here
    @goldnuggets24 The whole point of using something like browserify is to not use global variables
    Try the basics first -- try to walk before you run :)
    I know that sounds annoying but one hint is to have a file say application.js -- in that file anything that is coming from asset pipeline requires like //= do it there.. then after that, require your CommonJS files
    Look at some examples out there if you can't get it working as you expect. But from what you wrote, I think you're thinking about it wrong and still trying to have global asset pipeline JS run things when really you want to get to CommonJS modules and assemble all your JS with that and then kick off the CommonJS-based code
    Much easier to start w/ working examples and add to it when you're first getting started
    Mike Levine
    Fantastic advise. Seriously appreciate you hitting me up. I've gotten a bit further since posting this. Curious: how long would you say you guys took before getting proficient on React?
    Hey. So there is this npm package called solc and it has a function called 'compile' which uses a function called 'cwrap' from this soljson.js file in the /bin/ folder of the solc node_module folder. When I use the node console to require solc and then call that function, it works beautifully. However if I try to call the compile function in rails with browserify, i get an error that states that the function 'cwrap' is missing from soljson.. i am guessing this is due to browserify not compiling the soljson.js file maybe ?
    hi, if I do //= require jquery and then do require(‘jquery’), how can i make sure jquery is included only 1 time?
    Cymen Vig
    @chhuang you can’t — if you want it outside of browserified code, use the //= require and then configure browserify to have jQuery as an external
    Cymen Vig
    @admazzola I’d take that to StackOverflow, sounds like a require issue not related directly to this project (I know you asked a while ago but just in case)