-
Notifications
You must be signed in to change notification settings - Fork 755
Copyless setup of react source #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copyless setup of react source #254
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
😹 The same idea hit me while writing up #252 , I love it. It looks like this removes support for the "enviroment drop-in path" and that's fine with me -- seems like a rare use case with a trivial workaround of just dropping a copy of react.js in your You'll probably have to update a couple tests, too. Thanks, this is awesome! |
I'm glad you like it. I'll update the test and PR the related change to |
Oh I missed the changes to So then to add different versions, you'd just add different Your call, I love the copy-free setup either way |
I already started a PR on |
… of react-rails See reactjs/react-rails#254 for context
… of react-rails See reactjs/react-rails#254 for context
… of react-rails See reactjs/react-rails#254 for context
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
👍 I was going to ask in the other PR about compatibility. The other option we have here is to stop using react-source entirely. I don't know how useful it actually is at this point. When I first started this project I modeled it after a couple other things (combo of coffeescript and ember) but didn't know the implications. What we do with pyreact is actually just download the js files from https://github.com/reactjs/react-bower into that repo and then there aren't the constraints of another dependency. If there's no value in react-source, then I'm happy to just kill it, let me know. |
Well, actually I moved react-source as a development dependency only since It's not needed at runtime anymore. So yes using the same strategy than pyreact sounds good. I'll do that then, it will simplify even more. |
1311f96
to
c2106b5
Compare
Ok, so I vendored everything using bower. I also fixed the There is 2 remaining broken test cases, but I don't really understand them. @rmosolgo your help would be appreciated to figure out what wrong with thoses. |
c2106b5
to
390c0db
Compare
Ok, so out of the 2 failures, one already fail on master for me, so it must be a problem with my setup. As for the second one (drop-in files), I think I already cover that in another test. The coverage lost though is the test that assert that the development version is served. Not sure if it's critical. |
5398af6
to
bd8dff7
Compare
How does this work with a new project? If it's a new project, I see that That way, the rake task would be part of
This introduces a hidden dependency on bower, but hey I guess that's the downside of this approach. Worth it IMO. What do you think of that? Have I missed something? |
Not sure what you mean by that.
That's a good point and it also fix one issue I have with the current state of the PR, which is that you can't use it as a git gem because the files are created during the build. I'll update this PR in a minute. Hang on. |
bd8dff7
to
c7c5c63
Compare
@rmosolgo should be good now. The |
c7c5c63
to
7f84c44
Compare
7f84c44
to
07eec91
Compare
For the record as just tested this branch in my app as a git gem, and it dies work as intended. |
That looks nice! Bower is just the means for getting those files into the right directories. Then, the Railtie switches on The only remaining thing is this: is there any test that the directory approach really works? Eg testing production vs. development, testing add-ons vs no add-ons? (I'm not 100% sure how to test it) This removes support for environment-based drop-in react.js files but that's OK with me. I've never heard anyone using that configuration. I'll create a changelog after this PR is merged. |
It's really hard to test since sprockets caches everything. But I can give it a try. On a side note. It seems that the path is appended too late. I tried deploying 07eec91 and assets:precompile is failing in production:
I'll find a way to fix this. |
Not sure if this is related, but it rings a bell: #241 |
I successfully deployed |
Grumble. Of course that change broke the same tests again.... I'm quite busy today, but I'll fix the tests as soon as I have a bit of time. |
…e-copying fix(Railtie) add asset paths another way, add test for precompiling assets
f5e47ed fixes the new precompile test under 3.2. |
And 1c92a45 test that it's the development version that is loaded. I don't know How I could assert that different settings load different version since it would require to reboot rails :/ Would that be good enough for you? |
👍 from me! I'll give it a try locally before I merge it and let it hang here for a bit in case anyone else has suggestions. |
I gave it a try locally:
👍 |
Oh the cache issue is interesting, I totally didn't think about it. It's probably a minor issue, but quite annoying. What we could do is to append the react-rails settings to the sprockets environment version: https://github.com/rails/sprockets-rails/blob/656c9d266a0c5d29d19c566831c8d7daa2f2005d/lib/sprockets/railtie.rb#L91-L97 |
I think byroot@b3ee527 would solve the issue. Let me know if you want it included in this PR. |
would be nice as a separate PR! On Mon, May 4, 2015 at 2:16 PM, Jean Boussier [email protected]
|
…e-copying Copyless setup of react source
what a huge win, thanks @byroot 🎊 🎉 !! |
My pleasure :) |
Copying files on boot is really problematic, especially in capistrano scenario where the application run under a different user than the one compiling assets.
e.g. the
deploy
user compiles the assets and therails
user can only read them.The current copying behaviour requires a lot of capistrano hacks, and is also unsafe because the running application if compromised could corrupt the asset bundles.
My proposal is not to copy files but to append different directories to sprockets search path. To work, this would require to change the paths in the
react-source
gem to:build/JSXTransformer.js
development/react.js
development-with-addons/react.js
production/react.js
production-with-addons/react.js
@rmosolgo thoughts about this?
cc @gmalette