Skip to content
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

Record the compilation digest even on webpack error #2117

Merged
merged 2 commits into from Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/webpacker/compiler.rb
Expand Up @@ -19,7 +19,12 @@ def initialize(webpacker)
def compile
if stale?
run_webpack.tap do |success|
record_compilation_digest if success
# We used to only record the digest on success
# However, the output file is still written on error, (at least with ts-loader), meaning that the
# digest should still be updated. If it's not, you can end up in a situation where a recompile doesn't
# take place when it should.
# See https://github.com/rails/webpacker/issues/2113
record_compilation_digest
end
else
true
Expand Down
5 changes: 2 additions & 3 deletions test/compiler_test.rb
Expand Up @@ -49,14 +49,13 @@ def test_freshness_on_compile_success
end
end

def test_staleness_on_compile_fail
def test_freshness_on_compile_fail
status = OpenStruct.new(success?: false)

assert Webpacker.compiler.stale?
Open3.stub :capture3, [:sterr, :stdout, status] do

Webpacker.compiler.compile
assert Webpacker.compiler.stale?
assert Webpacker.compiler.fresh?
end
end

Expand Down