-
Notifications
You must be signed in to change notification settings - Fork 22k
Fail hard if incompatible options are supplied with --webpack #28929
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
Conversation
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.
Where webpacker uses action view? One of the uses cases for webpacker is exacly API applications that want to use client side frameworks.
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.
@rafaelfranca Webpacker has view helpers like javascript_pack_tag
etc. which won't work without views. I guess --api
skips that right?
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.
We can add support to make it work independently without Rails views though 👍
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.
The only way of using webpacker is with javascript_pack_tag
? Is it not possible to user webpacker and don't use those helpers?
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.
It is possible to use, but there is no out of the box support like helpers to link those webpack bundles. If someone wants to add this they have to install HTML plugin and add some changes to make this work
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.
The gem does two things - one is using Webpack to compile modern javascript code and two involves helpers to fetch and link them within Rails views. Perhaps with api option supplied together with webpack we can re-structure bits of webpacker gem so that it serve files directly from public
directory.
Sorry for such |
This seems like a duplication of the |
@maclover7 That's correct. I think with |
Webpacker check is useful for independent gem install. Obviously, one downside is with |
Hmm, spent some time digging around the docs for generators, and may have found a solution. Can you wrap the entire webpacker installer template and the JS dependency checks in an |
@maclover7 It says in the doc that after_bundle callback gets executed even if --skip-bundle and/or --skip-spring has been passed. Don't you think that will lead to the same issue we are having now? i.e. it will try to run |
@gauravtiwari Sorry, I didn't fully say what I was thinking 😞 How about we keep the webpacker + skip bundle stuff in the app generator (this is more a concern of rails than webpacker), and then move the dependency stuff and the install task to the |
@maclover7 No worries :) |
@rafaelfranca @maclover7 Removed the yarn and node check part. Good enough for merge? |
@gauravtiwari Since we aren't doing raising for bad versions, where is that happening now? Within webpacker? Is that out of scope now for this PR? |
@maclover7 Yepp that will happen inside webpacker - seems like best thing to do at this point. |
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.
Can you squash down to one commit?
@maclover7 Done! Looks like |
# --webpack requires webpacker gem to be pre-bundled | ||
# --skip-bundle skips bundle install | ||
if options[:webpack] && options[:skip_bundle] | ||
raise Error, "Incompatible options --webpack and --skip-bundle supplied. Please use either --skip-bundle or --webpack" |
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.
Should we fail in this case or just skip the wepacker:install
call that we do later? I always generate my applications with --skip-bundler
(it is in my ~/.railsrc) and I'm fine with adding webpacker in my gemfile when using --webpack
and running webpacker:install
manually. But the fact that I can't do that when we merge this code annoys me.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Summary
--webpack
and--api
option together, they simple aren't made for each other 😄 . Addresses this - Ditching the Rails view layer webpacker#276--webpack
and--skip-bundle
option together, chicken and egg situation apparently 😄 . Addresses this - rails new does not work with --webpack and --skip-bundle on Rails 5.1 #28916// cc @rafaelfranca @dhh