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"
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

View File

@ -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,25 +649,23 @@ 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(/^\/*/, '')
test_path = "#{root_dir_name}/test/javascripts"
DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
end
end
self.instance_eval File.read(path), path
if auto_assets = generate_automatic_assets!
@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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