GithubHelp home page GithubHelp logo

Comments (18)

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

Actually, after encountering an error where browserify couldn't find "lodash" (happening in the browser as opposed to during compilation) I'm wondering if it could be due to me not clearing my assets in /tmp. I currently cannot verify because I stashed the changes in favour of another part of work I need to do, so I'll likely go back to it tomorrow.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli I'd definitely recommend clearing the asset cache. I've had some odd behavior with it and making these kinds of changes. My usual way to clear it is with rake assets:clobber and a rm -rf tmp (from the Rails root) just in case. Plus of course stopping and starting Rails. This seems like overkill but odd caching issues are the worst.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

I forgot to say your browserify.yml configuration looks good to me. If it doesn't work, maybe try a local module (not an npm module) to test it and see if that works correctly. If so, it may be a bug with npm modules.

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

Thanks for your answer. I tried deleting tmp/ and rake assets:clobber and the dependencies.js file seems correct (it contains the requested libraries and exposes require=), but I still can't get application.js to stop including the files for the life of me.

I also cannot get it to work with local files. When I specify a local file in browserify.yml, like ./my_file, it will be interpreted as /my_file and thus all requires will fail because they'll still be looking for ./my_file and that won't pass string comparison.

If I try to "hack" it by specifying /my_file in browserify.yml, it'll simply fail since it probably looks for the file at the root of my filesystem.

Having no prefixes in front of the file name leads to no results whatsoever either.

I'm quite lost at this point, since I can't even get a local file to work and I would have no idea how to do it with a node module.

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

I can see the following commands being run:

Browserify: /my_app/./node_modules/.bin/browserify -d -t 6to5-browserify --extension=.jsx --fast --list -
Browserify: /my_app/./node_modules/.bin/browserify -d -t 6to5-browserify --extension=.jsx --fast --require lodash --require react -
Browserify: /my_app/./node_modules/.bin/browserify -d -t 6to5-browserify --extension=.jsx --fast --list -
Browserify: /my_app/./node_modules/.bin/browserify -d -t 6to5-browserify --extension=.jsx --fast --external lodash --external react -

Could the problem be that when you run --list you don't pass the external or require arguments and thus get a different result than what it should be?

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli I think you are right. I'm looking into it right now.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

So we definitely need a test for this -- along the line, it broke. I'm still figuring out where exactly. Check this out:

https://github.com/cymen/browserify-rails-example

It works with browserify-rails 0.4.2 and browserify 4.2.3. I'm going to slowly upgrade things until they break.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

When it works, you should see something like this on the console when accessing localhost:3000:

screen shot 2014-12-09 at 9 43 36 pm

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

Quite cool! Thanks so much for doing this. I'll see if I can apso try.

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

What version have you reached so far? I can help search in the remaining space. =

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli I tried upgrading browserify and after 4.x it stops working. Not sure why yet.

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

Are you using git bisect? It could probably help a lot in case you aren't.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli I didn't need to use git bisect. I opened an issue for this bug: browserify/browserify#1019

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

That's perfect! I couldn't thank you enough for putting so much effort in this. Can't wait for the time they fix it and I'll be able to speed up my build :)=

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

No problem -- it might be worth reconsidering if you want your dependencies out in another bundle. It makes sense if you have two bundles say application1.js and application2.js that both need common.js (aka dependencies.js) but if you don't have that case, it might make more sense to put them all in one bundle.

In terms of compilation speed, in normal development locally with Rails up, I can modify a .js file that is going to be browserified and refresh the page and it loads quickly -- it looks like a lot of the asset compilation is cached. Is this the scenario where you are seeing 20 seconds? Or are you seeing 20 seconds when you compile the assets for production with say bundle exec rake assets:precompile?

I'm just curious -- it would still be good to solve this problem.

from browserify-rails.

gabrielecirulli avatar gabrielecirulli commented on May 13, 2024

In my case I'm seeing upwards of 30 seconds every request. It's close to unbearable. I don't have a myriad of dependencies, but apparently there's just enough code to make it a problem. I'm also running with --fast, but it barely makes any difference. =

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli Wow. That is way too long.

from browserify-rails.

cymen avatar cymen commented on May 13, 2024

@gabrielecirulli I think we are good on this now that browserify-incremental is in. I'll leave the other general performance issue open. Please reopen this if you disagree.

from browserify-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.