Comments (18)
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.
@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.
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.
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.
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.
@gabrielecirulli I think you are right. I'm looking into it right now.
from browserify-rails.
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.
When it works, you should see something like this on the console when accessing localhost:3000:
from browserify-rails.
Quite cool! Thanks so much for doing this. I'll see if I can apso try.
from browserify-rails.
What version have you reached so far? I can help search in the remaining space. =
from browserify-rails.
@gabrielecirulli I tried upgrading browserify and after 4.x it stops working. Not sure why yet.
from browserify-rails.
Are you using git bisect
? It could probably help a lot in case you aren't.
from browserify-rails.
@gabrielecirulli I didn't need to use git bisect. I opened an issue for this bug: browserify/browserify#1019
from browserify-rails.
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.
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.
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.
@gabrielecirulli Wow. That is way too long.
from browserify-rails.
@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)
- Problem with transpilation of Javascript inside an Engine HOT 2
- EPERM with browserify on Windows, succeeds with browserify-incremental HOT 1
- Wrong lookup path HOT 6
- Require throwing error in rails HOT 1
- Browserify copies modules multiple times HOT 2
- Browserify not doing anything when precompiling assets HOT 1
- not compiling on production after update to browserify 14.3.0 HOT 9
- What's the advantage of using this gem over rails' new webpacker gem? HOT 5
- Browserify breaks action cable HOT 3
- Production env. randomly not compiling certain .js files HOT 2
- Babel Documentation
- Error requiring .coffee files from a node_module HOT 2
- Encoding::UndefinedConversionError occurs when js file contains Chinese characters HOT 2
- Accessing code outside browserified code HOT 4
- Browserify Rails is skipping a file.
- Browserify-rails is not passing process.env.NODE_ENV to the assets? HOT 1
- Problem when try require module in my html.erb file into script tags HOT 4
- ES6 code with no imports HOT 7
- Rails 5.2 support HOT 6
- Seems to re-browserify everything after restarting dev server HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browserify-rails.