DEV: Transpile all plugin js by default (#17175)

Goodbye `# transpile_js: true`? 🙂
This commit is contained in:
Jarek Radosz 2022-06-21 22:07:10 +02:00 committed by GitHub
parent 9cb9d1105e
commit 624c684d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 8 additions and 24 deletions

View File

@ -3,7 +3,7 @@
root_path = "#{File.dirname(p.path)}/test/javascripts" root_path = "#{File.dirname(p.path)}/test/javascripts"
to_glob = [root_path + '/**/**.es6'] 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) } Dir.glob(to_glob) { |f| require_asset(f) }
end end

View File

@ -67,13 +67,6 @@ class Plugin::Instance
} }
end 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 def seed_data
@seed_data ||= HashWithIndifferentAccess.new({}) @seed_data ||= HashWithIndifferentAccess.new({})
end end
@ -656,24 +649,22 @@ class Plugin::Instance
# Automatically include all ES6 JS and hbs files # Automatically include all ES6 JS and hbs files
root_path = "#{root_dir_name}/assets/javascripts" 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, 'js.es6')
DiscoursePluginRegistry.register_glob(root_path, 'hbs') DiscoursePluginRegistry.register_glob(root_path, 'hbs')
DiscoursePluginRegistry.register_glob(root_path, 'hbr') DiscoursePluginRegistry.register_glob(root_path, 'hbr')
admin_path = "#{root_dir_name}/admin/assets/javascripts" 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, 'js.es6', admin: true)
DiscoursePluginRegistry.register_glob(admin_path, 'hbs', admin: true) DiscoursePluginRegistry.register_glob(admin_path, 'hbs', admin: true)
DiscoursePluginRegistry.register_glob(admin_path, 'hbr', 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 << root_path.sub(Rails.root.to_s, '').sub(/^\/*/, '') DiscourseJsProcessor.plugin_transpile_paths << admin_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" test_path = "#{root_dir_name}/test/javascripts"
DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '') DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
end
end end
self.instance_eval File.read(path), path self.instance_eval File.read(path), path
@ -818,7 +809,7 @@ class Plugin::Instance
yield [f, true] yield [f, true]
elsif f_str.end_with?(".js.es6") || f_str.end_with?(".hbs") || f_str.end_with?(".hbr") elsif f_str.end_with?(".js.es6") || f_str.end_with?(".hbs") || f_str.end_with?(".hbr")
yield [f, false] yield [f, false]
elsif transpile_js && f_str.end_with?(".js") elsif f_str.end_with?(".js")
yield [f, false] yield [f, false]
end end
end end

View File

@ -5,7 +5,6 @@
# version: 0.4 # version: 0.4
# authors: Régis Hanol # authors: Régis Hanol
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-details # url: https://github.com/discourse/discourse/tree/main/plugins/discourse-details
# transpile_js: true
enabled_site_setting :details_enabled enabled_site_setting :details_enabled
hide_plugin if self.respond_to?(:hide_plugin) hide_plugin if self.respond_to?(:hide_plugin)

View File

@ -4,7 +4,6 @@
# about: Display a date in your local timezone # about: Display a date in your local timezone
# version: 0.1 # version: 0.1
# author: Joffrey Jaffeux # author: Joffrey Jaffeux
# transpile_js: true
hide_plugin if self.respond_to?(:hide_plugin) hide_plugin if self.respond_to?(:hide_plugin)

View File

@ -5,7 +5,6 @@
# version: 1.0 # version: 1.0
# authors: Nick Sahler, Alan Tan # authors: Nick Sahler, Alan Tan
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-narrative-bot # url: https://github.com/discourse/discourse/tree/main/plugins/discourse-narrative-bot
# transpile_js: true
enabled_site_setting :discourse_narrative_bot_enabled enabled_site_setting :discourse_narrative_bot_enabled
hide_plugin if self.respond_to?(:hide_plugin) hide_plugin if self.respond_to?(:hide_plugin)

View File

@ -5,7 +5,6 @@
# version: 2.0 # version: 2.0
# authors: André Pereira, David Taylor, tgxworld # authors: André Pereira, David Taylor, tgxworld
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-presence # url: https://github.com/discourse/discourse/tree/main/plugins/discourse-presence
# transpile_js: true
enabled_site_setting :presence_enabled enabled_site_setting :presence_enabled
hide_plugin if self.respond_to?(:hide_plugin) hide_plugin if self.respond_to?(:hide_plugin)

View File

@ -5,7 +5,6 @@
# version: 1.0.1 # version: 1.0.1
# authors: Arpit Jalan # authors: Arpit Jalan
# url: https://github.com/discourse/discourse/tree/main/plugins/lazy-yt # url: https://github.com/discourse/discourse/tree/main/plugins/lazy-yt
# transpile_js: true
hide_plugin if self.respond_to?(:hide_plugin) hide_plugin if self.respond_to?(:hide_plugin)

View File

@ -5,7 +5,6 @@
# version: 1.0 # version: 1.0
# authors: Vikhyat Korrapati (vikhyat), Régis Hanol (zogstrip) # authors: Vikhyat Korrapati (vikhyat), Régis Hanol (zogstrip)
# url: https://github.com/discourse/discourse/tree/main/plugins/poll # url: https://github.com/discourse/discourse/tree/main/plugins/poll
# transpile_js: true
register_asset "stylesheets/common/poll.scss" register_asset "stylesheets/common/poll.scss"
register_asset "stylesheets/desktop/poll.scss", :desktop register_asset "stylesheets/desktop/poll.scss", :desktop

View File

@ -4,7 +4,6 @@
# about: Preview how Widgets are Styled in Discourse # about: Preview how Widgets are Styled in Discourse
# version: 0.2 # version: 0.2
# author: Robin Ward # author: Robin Ward
# transpile_js: true
register_asset "stylesheets/styleguide.scss" register_asset "stylesheets/styleguide.scss"
enabled_site_setting :styleguide_enabled enabled_site_setting :styleguide_enabled