-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Drop jQuery as a dependency #27113
Drop jQuery as a dependency #27113
Conversation
7967631
to
d6262d7
Compare
|
||
module ActionView | ||
# = Action View Engine | ||
class Railtie < Rails::Engine # :nodoc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about leaving this in lib/action_view/railtie.rb
? The fact that its superclass is now Rails::Engine
doesn't mean it needs to move.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!!!
d6262d7
to
5a7bed1
Compare
//= require <%= options[:javascript] %> | ||
//= require <%= options[:javascript] %>_ujs | ||
<% else -%> | ||
//= require rails-ujs | ||
<% end -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should always use rails-ujs and eliminate *_ujs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, I was thinking exactly the same
5a7bed1
to
7184289
Compare
"Use #{options[:javascript]} as the JavaScript library") | ||
if options[:javascript] | ||
gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, | ||
"Use #{options[:javascript]} as the JavaScript library") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line needs another space to indent it fully 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, updated!!
Congrats @liudangyi, nice work! ❤️ |
This needs changelog as well 😃 |
7184289
to
84f8cb5
Compare
CHANGELOG entries added 😊 |
Does the compiled |
@javan the different options were discussed in #25208 (comment), B) was discarded but maybe A) is preferred more than the current approach /cc @dhh @rafaelfranca In my opinion is a better idea to keep the source code out of Rails repo because of maintenance (typically the maintainers of js integration libraries are different than the maintainers of Rails and that's why we have a "Javascript" collaborators group on Github) and distribution (we don't expect to sync releases of this library with the releases of Action View like we do for Action Cable) Personally I'll prefer to keep the current approach or B) making it a gem. |
I think it should be a gem that is explicitly named in the Gemfile. For the relevant helpers to work, actionview needs a UJS implementation to be present -- but that could be this new one as supplied by us, it could be jquery-rails, or it could be managed by another asset manager. We have plenty of precedent for features that only work, or work much better, if an additional optional gem is present -- from database adapters, to bcrypt passwords. And the "U" in "UJS" is supposed to promise that the helpers' HTML output will still get the job done even with no JS available. (After all, even if we ship it, we can't guarantee it's included on a given page.) Mostly, I'm worried that having two UJS assets floating around inside an application risks confusing conflicts, so it seems better that this new one will Properly Go Away if it's not being used. (Particularly given that while we're not yet strongly committed to the idea, and a good way away from requiring it, it seems likely we're going to end up with a 3rd party asset manager as the default happy path in the not-too-distant future.) I agree with @javan that it should at least be part of the build process, not a manually copied file, if we do choose to ship it built-in. And if we're bundling the compiled result into the AV gem, then we do seem to intend to sync releases of the library -- in the most physical way possible. 😕 |
We currently have two "systems" for incorporating JavaScript:
I'd rather not introduce a third, especially if it's copy+paste |
Thinking about the release process I still prefer it to be a gem and for
|
I would suggest to make it a separate gem. An additional line in |
I'm curious as to why we think this package is going to need a higher But, again, if Rafael is doing the release work, and he prefers a separate On Mon, Nov 21, 2016 at 10:07 AM, Dangyi Liu [email protected]
|
dd2e5d8
to
edec43d
Compare
Updated and now jquery-ujs gem is added to Gemfile. |
3750e8d
to
277b5f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we claim to this library to be ubstrusive why even bother to allow people to chose another one? I'm more inclined to just remove support to other javascript drivers in the generators
@@ -328,8 +328,13 @@ def javascript_gemfile_entry | |||
gems = [javascript_runtime_gemfile_entry] | |||
gems << coffee_gemfile_entry unless options[:skip_coffee] | |||
|
|||
gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, | |||
"Use #{options[:javascript]} as the JavaScript library") | |||
if options[:javascript] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doing this here and not using the already existing default option in Thor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind got it
//= require <%= options[:javascript] %> | ||
//= require <%= options[:javascript] %>_ujs | ||
<% end -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not this add both in case people have Jquery-ujs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For users passing the -j jquery
option this file will be like:
//= require jquery
//= require rails-ujs
So we are making rails-ujs the default even for jQuery users and not allowing people to chose another driver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. I miss read it.
@rafaelfranca yup, we are doing exactly that in generators, even the jQuery users will get |
👍 |
@rafaelfranca I think that's a strong argument for just including it in Action View. We don't need an adapter for this. This is UJS support to make the Rails helpers work and they just rely on standard JS. No reason to have a jQuery or whatever version of them imo. |
@dhh agree on that @rafaelfranca wdyt? |
This will make the release process really hard because we will have to clone two repositories build the dist file etc. We can make it simpler though if we move all code to inside action view. That way we can release it in the same way we do release actioncable. But doing this we will lose the separated issue tracker and will complicate our test matrix that is already slow, and complicated. If we are going to move the entire code to action view I'm positive about it, but there are those drawbacks that I pointed. |
Rails dropped jQuery as a dependency back in rails/rails#27113. That commit removed 'jquery-ujs' from the application.js and replaced it with 'rails-ujs'. Since we aren't using 'jquery-ujs', we don't need the 'jquery-rails' gem. As for the test JS, `$.fx.off = true` shouldn't be necessary if we aren't using jQuery, and `$.ajaxSetup({ async: false });` seems to have been for Akephalos, which we no longer use.
Rails dropped jQuery as a dependency back in rails/rails#27113. That commit removed 'jquery-ujs' from the application.js and replaced it with 'rails-ujs'. Since we aren't using 'jquery-ujs', we don't need the 'jquery-rails' gem. As for the test JS, `$.fx.off = true` shouldn't be necessary if we aren't using jQuery, and `$.ajaxSetup({ async: false });` seems to have been for Akephalos, which we no longer use.
Rails dropped jQuery as a dependency back in rails/rails#27113. That commit removed 'jquery-ujs' from the application.js and replaced it with 'rails-ujs'. Since we aren't using 'jquery-ujs', we don't need the 'jquery-rails' gem. As for the test JS, `$.fx.off = true` shouldn't be necessary if we aren't using jQuery, and `$.ajaxSetup({ async: false });` seems to have been for Akephalos, which we no longer use.
As discussed in #25208 we have decided to remove jQuery from default stack and use a vanilla version of the ujs driver named rails-ujs instead.
This Pull Request remove
jquery-rails
from new applications and providesrails-ujs
throughAction View
(to do this I had to convertActionView::Railtie
into anEngine
).The new rails-ujs was developed by @liudangyi as part of Google Summer of Code, all credits for this goes to him and to his mentor @pixeltrix 👏 👏 👏 👏 👏