A platform for community discussion. Free, open, simple.
FIX: Rebuild theme javascript when the compiler version changes on save (#43391)
David Taylor8d7ba6b9d34b
diff --git a/app/models/theme.rb b/app/models/theme.rbindex 1d69e98df7d..75e8aa7aada 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -171,9 +171,12 @@ class Theme < ActiveRecord::Basereloadsettings_field&.ensure_baked! # Other fields require setting to be **baked**++ stale_extra_js =+ theme_fields.any? { |f| f.extra_js_field? && f.compiler_version != Theme.compiler_version }theme_fields.each(&:ensure_baked!)- update_javascript_cache! if any_extra_js_fields_changed+ update_javascript_cache! if any_extra_js_fields_changed || stale_extra_jsremove_from_cache!ColorScheme.hex_cache.cleardiff --git a/lib/asset_processor.rb b/lib/asset_processor.rbindex 065495e3a35..640de813a2f 100644--- a/lib/asset_processor.rb+++ b/lib/asset_processor.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueclass AssetProcessor- BASE_COMPILER_VERSION = 119+ BASE_COMPILER_VERSION = 120BUNDLE =PrecompiledBundle.new(diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex 052e6437b57..890c7b20123 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -794,6 +794,19 @@ RSpec.describe Theme doendend+ it "rebuilds the javascript cache when saved with a stale compiler version" do+ theme.set_field(target: :extra_js, name: "test.js.es6", value: "const hello = 'world';")+ theme.save!+ theme.reload.javascript_cache.update_columns(content: "stale")++ theme.save!+ expect(theme.reload.javascript_cache.content).to eq("stale")++ ThemeField.where(theme_id: theme.id).update_all(compiler_version: "OLD_HASH")+ theme.save!+ expect(theme.reload.javascript_cache.content).to include("compatModules")+ end+it "recompiles when the hostname changes" dotheme.set_field(target: :settings, name: :yaml, value: "name: bob")theme.set_field(