mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Cleanup legacy asset compilation gems and code (#19177)
We now use Ember CLI (core/plugins) and DiscourseJSProcessor (themes) for all Ember and template compilation. This commit removes the remnants of the legacy Sprockets-based Ember compilation system. Sprockets, and its DiscourseJSProcess-based Babel transformations, is still in use for a few assets. Ideally that will be removed/replaced in the near future.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
||||
ctx.eval("module = {}; exports = {};")
|
||||
ctx.attach("rails.logger.info", proc { |err| puts(">> #{err.to_s}") })
|
||||
ctx.attach("rails.logger.error", proc { |err| puts(">> #{err.to_s}") })
|
||||
ctx.eval <<JS
|
||||
console = {
|
||||
prefix: "",
|
||||
log: function(msg){ rails.logger.info(console.prefix + msg); },
|
||||
error: function(msg){ rails.logger.error(console.prefix + msg); }
|
||||
}
|
||||
|
||||
JS
|
||||
source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js")
|
||||
js_source = ::JSON.generate(source, quirks_mode: true)
|
||||
js = ctx.eval("Babel.transform(#{js_source}, { ast: false, plugins: ['check-es2015-constants', 'transform-es2015-arrow-functions', 'transform-es2015-block-scoped-functions', 'transform-es2015-block-scoping', 'transform-es2015-classes', 'transform-es2015-computed-properties', 'transform-es2015-destructuring', 'transform-es2015-duplicate-keys', 'transform-es2015-for-of', 'transform-es2015-function-name', 'transform-es2015-literals', 'transform-es2015-object-super', 'transform-es2015-parameters', 'transform-es2015-shorthand-properties', 'transform-es2015-spread', 'transform-es2015-sticky-regex', 'transform-es2015-template-literals', 'transform-es2015-typeof-symbol', 'transform-es2015-unicode-regex'] }).code")
|
||||
ctx.eval(js)
|
||||
|
||||
if ARGV[0].present?
|
||||
source = File.read(ARGV[0])
|
||||
js_source = ::JSON.generate(source, quirks_mode: true)
|
||||
puts ctx.eval("exports.compile(#{js_source})")
|
||||
end
|
||||
@@ -1,31 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
template = <<~HBS
|
||||
{{attach widget="wat" attrs=(hash test="abc" text=(i18n "hello" count=attrs.wat))}}
|
||||
{{action-link action="undo" className="undo" text=(i18n (concat "post.actions.undo." attrs.action))}}
|
||||
{{actions-summary-item attrs=as}}
|
||||
{{attach widget="actions-summary-item" attrs=as}}
|
||||
{{testing value="hello"}}
|
||||
{{date "today"}}
|
||||
HBS
|
||||
|
||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
||||
ctx.eval("module = {}; exports = {};")
|
||||
ctx.attach("rails.logger.info", proc { |err| puts(err.to_s) })
|
||||
ctx.attach("rails.logger.error", proc { |err| puts(err.to_s) })
|
||||
ctx.eval <<JS
|
||||
console = {
|
||||
prefix: "",
|
||||
log: function(msg){ rails.logger.info(console.prefix + msg); },
|
||||
error: function(msg){ rails.logger.error(console.prefix + msg); }
|
||||
}
|
||||
|
||||
JS
|
||||
source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js")
|
||||
ctx.eval(source)
|
||||
|
||||
js_source = ::JSON.generate(template, quirks_mode: true)
|
||||
|
||||
puts ctx.eval("exports.compile(#{js_source})")
|
||||
Reference in New Issue
Block a user