Skip to content

Commit

Permalink
Record the compilation digest even on webpack error (#2117)
Browse files Browse the repository at this point in the history
* Record the compilation digest even on webpack error

Fixes /issues/2113

* fix: failed builds should return as fresh

If it returns stale, the error message will never make it to the `webpack-dev-server` overlay. This also fixes typescript related problems in #2113
  • Loading branch information
Taytay authored and gauravtiwari committed Jun 10, 2019
1 parent 891b50d commit 195396f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit 195396f

Please sign in to comment.