Skip to content

A platform for community discussion. Free, open, simple.

DEV: Do not manipulate theme module paths at build-time (#23148)

David Taylor82b16f4f476f
diff --git a/app/models/theme.rb b/app/models/theme.rb
index 25fd95c2544..ca78a433d77 100644
--- a/app/models/theme.rb
+++ b/app/models/theme.rb
@@ -6,7 +6,7 @@ require "json_schemer"
class Theme < ActiveRecord::Base
include GlobalPath
- BASE_COMPILER_VERSION = 72
+ BASE_COMPILER_VERSION = 73
attr_accessor :child_components
diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rb
index c4d15e67558..e9581c2c443 100644
--- a/lib/theme_javascript_compiler.rb
+++ b/lib/theme_javascript_compiler.rb
@@ -234,7 +234,7 @@ class ThemeJavascriptCompiler
def append_module(script, name, include_variables: true)
original_filename = name
- name = "discourse/theme-#{@theme_id}/#{name.gsub(%r{\Adiscourse/}, "")}"
+ name = "discourse/theme-#{@theme_id}/#{name}"
script = "#{theme_settings}#{script}" if include_variables
transpiler = DiscourseJsProcessor::Transpiler.new
diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rb
index 4468e670c82..abfa0c0e899 100644
--- a/spec/lib/theme_javascript_compiler_spec.rb
+++ b/spec/lib/theme_javascript_compiler_spec.rb
@@ -119,7 +119,9 @@ RSpec.describe ThemeJavascriptCompiler do
"discourse/templates/components/mycomponent.hbs" => "{{my-component-template}}",
},
)
- expect(compiler.raw_content).to include('define("discourse/theme-1/components/mycomponent"')
+ expect(compiler.raw_content).to include(
+ 'define("discourse/theme-1/discourse/components/mycomponent"',
+ )
expect(compiler.raw_content).to include(
'define("discourse/theme-1/discourse/templates/components/mycomponent"',
)
diff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rb
index ba2479d0517..a34ea1600f1 100644
--- a/spec/models/theme_field_spec.rb
+++ b/spec/models/theme_field_spec.rb
@@ -259,10 +259,10 @@ HTML
)
expect(theme.javascript_cache.content).to include('addRawTemplate("discovery"')
expect(theme.javascript_cache.content).to include(
- "define(\"discourse/theme-#{theme.id}/controllers/discovery\"",
+ "define(\"discourse/theme-#{theme.id}/discourse/controllers/discovery\"",
)
expect(theme.javascript_cache.content).to include(
- "define(\"discourse/theme-#{theme.id}/controllers/discovery-2\"",
+ "define(\"discourse/theme-#{theme.id}/discourse/controllers/discovery-2\"",
)
expect(theme.javascript_cache.content).to include("const settings =")
expect(theme.javascript_cache.content).to include(
diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb
index 8cae8b35391..f34d7ac0d9a 100644
--- a/spec/models/theme_spec.rb
+++ b/spec/models/theme_spec.rb
@@ -254,7 +254,7 @@ HTML
expect(javascript_cache.content).to include("if ('define' in window) {")
expect(javascript_cache.content).to include(
- "define(\"discourse/theme-#{field.theme_id}/initializers/theme-field-#{field.id}-mobile-html-script-1\"",
+ "define(\"discourse/theme-#{field.theme_id}/discourse/initializers/theme-field-#{field.id}-mobile-html-script-1\"",
)
expect(javascript_cache.content).to include(
"settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(#{field.theme_id});",
@@ -406,7 +406,7 @@ HTML
)
expect(theme_field.javascript_cache.content).to include("if ('define' in window) {")
expect(theme_field.javascript_cache.content).to include(
- "define(\"discourse/theme-#{theme_field.theme.id}/initializers/theme-field-#{theme_field.id}-common-html-script-1\",",
+ "define(\"discourse/theme-#{theme_field.theme.id}/discourse/initializers/theme-field-#{theme_field.id}-common-html-script-1\",",
)
expect(theme_field.javascript_cache.content).to include(
"name: \"theme-field-#{theme_field.id}-common-html-script-1\",",