A platform for community discussion. Free, open, simple.
DEV: Transpile all plugin js by default (#17175)
Jarek Radosz624c684d51d2
diff --git a/app/assets/javascripts/discourse/tests/plugin-tests.js.erb b/app/assets/javascripts/discourse/tests/plugin-tests.js.erbindex f2b38319a4a..6e5d6bae588 100644--- a/app/assets/javascripts/discourse/tests/plugin-tests.js.erb+++ b/app/assets/javascripts/discourse/tests/plugin-tests.js.erb@@ -3,7 +3,7 @@root_path = "#{File.dirname(p.path)}/test/javascripts"to_glob = [root_path + '/**/**.es6']- to_glob << (root_path + '/**/**.js') if p.transpile_js+ to_glob << (root_path + '/**/**.js')Dir.glob(to_glob) { |f| require_asset(f) }enddiff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rbindex 3ff88170971..b8487a0dbbd 100644--- a/lib/plugin/instance.rb+++ b/lib/plugin/instance.rb@@ -67,13 +67,6 @@ class Plugin::Instance}end- # If plugins provide `transpile_js: true` in their metadata we will- # transpile regular JS files in the assets folders. Going forward,- # all plugins should do this.- def transpile_js- metadata.try(:transpile_js) == "true"- end-def seed_data@seed_data ||= HashWithIndifferentAccess.new({})end@@ -656,24 +649,22 @@ class Plugin::Instance# Automatically include all ES6 JS and hbs filesroot_path = "#{root_dir_name}/assets/javascripts"- DiscoursePluginRegistry.register_glob(root_path, 'js') if transpile_js+ DiscoursePluginRegistry.register_glob(root_path, 'js')DiscoursePluginRegistry.register_glob(root_path, 'js.es6')DiscoursePluginRegistry.register_glob(root_path, 'hbs')DiscoursePluginRegistry.register_glob(root_path, 'hbr')admin_path = "#{root_dir_name}/admin/assets/javascripts"- DiscoursePluginRegistry.register_glob(admin_path, 'js', admin: true) if transpile_js+ DiscoursePluginRegistry.register_glob(admin_path, 'js', admin: true)DiscoursePluginRegistry.register_glob(admin_path, 'js.es6', admin: true)DiscoursePluginRegistry.register_glob(admin_path, 'hbs', admin: true)DiscoursePluginRegistry.register_glob(admin_path, 'hbr', admin: true)- if transpile_js- DiscourseJsProcessor.plugin_transpile_paths << root_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')- DiscourseJsProcessor.plugin_transpile_paths << admin_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')+ DiscourseJsProcessor.plugin_transpile_paths << root_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')+ DiscourseJsProcessor.plugin_transpile_paths << admin_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')- test_path = "#{root_dir_name}/test/javascripts"- DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')- end+ test_path = "#{root_dir_name}/test/javascripts"+ DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')endself.instance_eval File.read(path), path@@ -818,7 +809,7 @@ class Plugin::Instanceyield [f, true]elsif f_str.end_with?(".js.es6") || f_str.end_with?(".hbs") || f_str.end_with?(".hbr")yield [f, false]- elsif transpile_js && f_str.end_with?(".js")+ elsif f_str.end_with?(".js")yield [f, false]endenddiff --git a/plugins/discourse-details/plugin.rb b/plugins/discourse-details/plugin.rbindex 9903bb861db..130bd58a325 100644--- a/plugins/discourse-details/plugin.rb+++ b/plugins/discourse-details/plugin.rb@@ -5,7 +5,6 @@# version: 0.4# authors: Régis Hanol# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-details-# transpile_js: trueenabled_site_setting :details_enabledhide_plugin if self.respond_to?(:hide_plugin)diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rbindex 32961189f71..af28e941f00 100644--- a/plugins/discourse-local-dates/plugin.rb+++ b/plugins/discourse-local-dates/plugin.rb@@ -4,7 +4,6 @@# about: Display a date in your local timezone# version: 0.1# author: Joffrey Jaffeux-# transpile_js: truehide_plugin if self.respond_to?(:hide_plugin)diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rbindex 314e0c7182e..cb6f4f0c268 100644--- a/plugins/discourse-narrative-bot/plugin.rb+++ b/plugins/discourse-narrative-bot/plugin.rb@@ -5,7 +5,6 @@# version: 1.0# authors: Nick Sahler, Alan Tan# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-narrative-bot-# transpile_js: trueenabled_site_setting :discourse_narrative_bot_enabledhide_plugin if self.respond_to?(:hide_plugin)diff --git a/plugins/discourse-presence/plugin.rb b/plugins/discourse-presence/plugin.rbindex b1e356d7471..26d2c335055 100644--- a/plugins/discourse-presence/plugin.rb+++ b/plugins/discourse-presence/plugin.rb@@ -5,7 +5,6 @@# version: 2.0# authors: André Pereira, David Taylor, tgxworld# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-presence-# transpile_js: trueenabled_site_setting :presence_enabledhide_plugin if self.respond_to?(:hide_plugin)diff --git a/plugins/lazy-yt/plugin.rb b/plugins/lazy-yt/plugin.rbindex 494d5d14362..ae2995065ef 100644--- a/plugins/lazy-yt/plugin.rb+++ b/plugins/lazy-yt/plugin.rb@@ -5,7 +5,6 @@# version: 1.0.1# authors: Arpit Jalan# url: https://github.com/discourse/discourse/tree/main/plugins/lazy-yt-# transpile_js: truehide_plugin if self.respond_to?(:hide_plugin)diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rbindex 677852cc059..94a1c5570e7 100644--- a/plugins/poll/plugin.rb+++ b/plugins/poll/plugin.rb@@ -5,7 +5,6 @@# version: 1.0# authors: Vikhyat Korrapati (vikhyat), Régis Hanol (zogstrip)# url: https://github.com/discourse/discourse/tree/main/plugins/poll-# transpile_js: trueregister_asset "stylesheets/common/poll.scss"register_asset "stylesheets/desktop/poll.scss", :desktopdiff --git a/plugins/styleguide/plugin.rb b/plugins/styleguide/plugin.rbindex f90169de17b..4c3244b1f67 100644--- a/plugins/styleguide/plugin.rb+++ b/plugins/styleguide/plugin.rb@@ -4,7 +4,6 @@# about: Preview how Widgets are Styled in Discourse# version: 0.2# author: Robin Ward-# transpile_js: trueregister_asset "stylesheets/styleguide.scss"enabled_site_setting :styleguide_enabled