mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:23:25 +08:00
DEV: Patch Ruby Ember template compiler to work with recent ember
This commit is contained in:
parent
20fd81c2dc
commit
a4c4d3cb50
|
@ -6,7 +6,7 @@ require 'json_schemer'
|
|||
class Theme < ActiveRecord::Base
|
||||
include GlobalPath
|
||||
|
||||
BASE_COMPILER_VERSION = 57
|
||||
BASE_COMPILER_VERSION = 58
|
||||
|
||||
attr_accessor :child_components
|
||||
|
||||
|
|
36
lib/freedom_patches/barber_ember_precompiler.rb
Normal file
36
lib/freedom_patches/barber_ember_precompiler.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Eventually we aim to move away from using Barber to precompile assets.
|
||||
# These overrides unblock us moving to more recent ember versions in the meantime
|
||||
|
||||
module BarberEmberPrecompilerFreedomPatch
|
||||
# Use the template compiler JS from node_modules
|
||||
def ember_template_precompiler
|
||||
@ember ||= File.new("app/assets/javascripts/node_modules/ember-source/dist/ember-template-compiler.js")
|
||||
end
|
||||
|
||||
# Apply a couple of extra shims for more recent ember-template-compilers
|
||||
def source_fixes
|
||||
shims = super
|
||||
|
||||
shims << <<~JS
|
||||
module = {exports:{}}
|
||||
|
||||
console = {
|
||||
log: function(){},
|
||||
warn: function(){},
|
||||
error: function(){}
|
||||
};
|
||||
JS
|
||||
|
||||
shims
|
||||
end
|
||||
|
||||
# Recent ember-template-compilers fail if `option` is null
|
||||
def compile(template, options = nil)
|
||||
options = {} if options.nil?
|
||||
super(template, options)
|
||||
end
|
||||
end
|
||||
|
||||
Barber::Ember::Precompiler.prepend(BarberEmberPrecompilerFreedomPatch)
|
|
@ -17,7 +17,8 @@ class ThemeJavascriptCompiler
|
|||
node.params.unshift({
|
||||
type: "NumberLiteral",
|
||||
value: #{@theme_id},
|
||||
original: #{@theme_id}
|
||||
original: #{@theme_id},
|
||||
loc: { start: {}, end: {} }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +59,7 @@ class ThemeJavascriptCompiler
|
|||
|
||||
def discourse_extension
|
||||
<<~JS
|
||||
Ember.HTMLBars.registerPlugin('ast', function() {
|
||||
module.exports.registerPlugin('ast', function() {
|
||||
return {
|
||||
name: 'theme-template-manipulator',
|
||||
visitor: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user