From 624c684d51d215a7b0969598d94c6c04f7224e22 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 21 Jun 2022 22:07:10 +0200 Subject: [PATCH] DEV: Transpile all plugin js by default (#17175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Goodbye `# transpile_js: true`? đŸ™‚ --- .../discourse/tests/plugin-tests.js.erb | 2 +- lib/plugin/instance.rb | 23 ++++++------------- plugins/discourse-details/plugin.rb | 1 - plugins/discourse-local-dates/plugin.rb | 1 - plugins/discourse-narrative-bot/plugin.rb | 1 - plugins/discourse-presence/plugin.rb | 1 - plugins/lazy-yt/plugin.rb | 1 - plugins/poll/plugin.rb | 1 - plugins/styleguide/plugin.rb | 1 - 9 files changed, 8 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/plugin-tests.js.erb b/app/assets/javascripts/discourse/tests/plugin-tests.js.erb index 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) } end diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 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 files root_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(/^\/*/, '') end self.instance_eval File.read(path), path @@ -818,7 +809,7 @@ class Plugin::Instance yield [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] end end diff --git a/plugins/discourse-details/plugin.rb b/plugins/discourse-details/plugin.rb index 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: true enabled_site_setting :details_enabled hide_plugin if self.respond_to?(:hide_plugin) diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rb index 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: true hide_plugin if self.respond_to?(:hide_plugin) diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb index 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: true enabled_site_setting :discourse_narrative_bot_enabled hide_plugin if self.respond_to?(:hide_plugin) diff --git a/plugins/discourse-presence/plugin.rb b/plugins/discourse-presence/plugin.rb index 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: true enabled_site_setting :presence_enabled hide_plugin if self.respond_to?(:hide_plugin) diff --git a/plugins/lazy-yt/plugin.rb b/plugins/lazy-yt/plugin.rb index 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: true hide_plugin if self.respond_to?(:hide_plugin) diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb index 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: true register_asset "stylesheets/common/poll.scss" register_asset "stylesheets/desktop/poll.scss", :desktop diff --git a/plugins/styleguide/plugin.rb b/plugins/styleguide/plugin.rb index 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: true register_asset "stylesheets/styleguide.scss" enabled_site_setting :styleguide_enabled