-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
React on Rails: last issue is the check for the binstubs crashes if the binstub does not exist #656
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
namespace :webpacker do | ||
desc "Verifies that bin/webpack & bin/webpack-dev-server are present." | ||
task :check_binstubs do | ||
unless File.exist?("bin/webpack") && File.exist?("bin/webpack-dev-server") | ||
unless Webpacker.config.custom_compile? || | ||
(File.exist?("bin/webpack") && File.exist?("bin/webpack-dev-server")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dhh @gauravtiwari How do we work around this part for React on Rails users that will not want to have the bin/webpack file installed? It turns out that if the automatic precompile task runs, this message prints:
as React on Rails first does the compile, so this seems OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @justin808 Yeah probably should test for We discussed to remove logger output - don't think it's needed when assets are fresh. |
||
$stderr.puts "Webpack binstubs not found.\n"\ | ||
"Have you run rails webpacker:install ?\n"\ | ||
"Make sure the bin directory or binstubs are not included in .gitignore\n"\ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,16 @@ require "webpacker/configuration" | |
namespace :webpacker do | ||
desc "Verifies if webpacker is installed" | ||
task verify_install: [:check_node, :check_yarn, :check_binstubs] do | ||
if Webpacker.config.config_path.exist? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The :check_binstubs is the issue, not the part below. |
||
$stdout.puts "Webpacker is installed 🎉 🍰" | ||
$stdout.puts "Using #{Webpacker.config.config_path} file for setting up webpack paths" | ||
else | ||
$stderr.puts "Configuration config/webpacker.yml file not found. \n"\ | ||
unless Webpacker.config.custom_compile? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we've extracted all the logic from the rake tasks into the Webpacker classes, I think the better move here, rather than trying to hack the webpacker tasks, is probably just to have your own reactonrails:* tasks that call these Webpacker classes directly. Then you can tailor output and prerequisites as you please 👍 |
||
if Webpacker.config.config_path.exist? | ||
$stdout.puts "Webpacker is installed 🎉 🍰" | ||
$stdout.puts "Using #{Webpacker.config.config_path} file for setting up webpack paths" | ||
else | ||
$stderr.puts "Configuration config/webpacker.yml file not found. \n"\ | ||
"Make sure webpacker:install is run successfully before " \ | ||
"running dependent tasks" | ||
exit! | ||
exit! | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,21 @@ def find(name) | |
|
||
def handle_missing_entry(name) | ||
raise Webpacker::Manifest::MissingEntryError, | ||
"Can't find #{name} in #{config.public_manifest_path}. Is webpack still compiling?" | ||
"Can't find #{name} in #{config.public_manifest_path}. Manifest contains:\n#{JSON.pretty_generate(@data)}" | ||
end | ||
|
||
def missing_file_from_manifest_error(bundle_name) | ||
msg = <<-MSG | ||
Webpacker can't find #{bundle_name} in #{config.public_manifest_path}. Possible causes: | ||
1. You are hot reloading. | ||
2. You want to set Configuration.compile to true for your environment. | ||
3. Webpack has not re-run to reflect updates. | ||
4. You have misconfigured Webpacker's config/webpacker.yml file. | ||
5. Your Webpack configuration is not creating a manifest. | ||
Your manifest contains: | ||
#{@data.to_json} | ||
MSG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gauravtiwari @dhh Do we want a more detailed error message? or at least what I did on line 45 to output the manifest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is good 👍 |
||
raise(Webpacker::FileLoader::NotFoundError.new(msg)) | ||
end | ||
|
||
def data | ||
|
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.
@dhh @gauravtiwari I need to add something like this so that assets:precompile does not try to use the bin/webpacker command.
We can't just turn compile off, as that's used to determine if compile checking should happen. Maybe instead of true/false, we could have a third value of "custom"? Whatever you prefer is fine with me.
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.
Not sure I understand? Should be possible for React on Rails to overwrite the webpacker:compile task or to even remove it from the assets:precompile preconditions. I think that's probably the better 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.
@dhh Right now, the default precompile from both Webpacker and React on Rails is getting run. Rake is additive. I don't see a good way for React on Rails to disable to the Webpacker task. That's all I want to do.