Rails无法使用ember-template-compiler进行预编译

时间:2015-06-30 17:07:24

标签: ember.js handlebars.js ember-rails htmlbars

从1.10.beta4升级到Ember.js 1.13.2后,我们再也无法预编译生产中有弃用警告的Handlebars模板。请查看rake资产的错误和追溯:下面的预编译。奇怪的是,我们在生产环境中没有在Mac上出现任何错误,但在Linux构建服务器(Ubuntu)上失败了。

经过调查,似乎ember-template-compiler.js在预编译期间生成了与编译输出混合的弃用警告。这个JS文件中有一条评论," Ember构建工具将在进行生产构建时删除对Ember.deprecate()的任何调用。"但我不知道Sprockets工具链是如何工作的。我无法覆盖Ember.deprecate,因为在预编译期间没有包含application.js文件。如果有人能说出如何在Rails资产预编译中删除对Ember.deprecate的调用,那将有助于进一步调试。

我们确实需要摆脱弃用,但可能需要一些时间!感谢您对此问题的帮助。

版本信息(我们不使用ember-cli):

  • Rails 4.2.0
  • ember-rails gem 0.16.1
  • barber gem 0.9.0
  • ember-template-compiler.js 1.13.2

错误消息和跟踪:

RAILS_ENV=production bundle exec rake assets:precompile
...
rake aborted!
JSON::ParserError: 757: unexpected token at 'DEPRECATION: The `bind-attr` helper (L1:C7) is deprecated in favor of HTMLBars-style bound attributes.
{anonymous}(/tmp/execjs20150630-36511-b2stmyjs:15523:15)
Walker.visit (/tmp/execjs20150630-36511-b2stmyjs:22029:7)
visitors.Program (/tmp/execjs20150630-36511-b2stmyjs:22039:16)
Walker.children (/tmp/execjs20150630-36511-b2stmyjs:22062:7)
Walker.visit (/tmp/execjs20150630-36511-b2stmyjs:22030:12)
TransformBindAttrToAttributes_transform [as transform] (/tmp/execjs20150630-36511-b2stmyjs:15518:12)
preprocess (/tmp/execjs20150630-36511-b2stmyjs:21637:27)
compileSpec (/tmp/execjs20150630-36511-b2stmyjs:16640:52)
["ok","(function() {\ ... 
... locals: [],\n    templates: []\n  };\n}())"]'
(in     /var/lib/jenkins/jobs/ch_master_package/workspace/app/assets/javascripts/templates/_permanently_remove_post.hbs)
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/json-1.8.2/lib/json/common.rb:155:in `parse'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/json-1.8.2/lib/json/common.rb:155:in `parse'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:68:in `extract_result'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:39:in `exec'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:21:in `eval'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:46:in `call'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/barber-0.9.0/lib/barber/precompiler.rb:23:in `compile'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/barber-0.9.0/lib/barber/precompiler.rb:8:in `compile'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/ember-rails-0.16.1/lib/ember/handlebars/template.rb:75:in `precompile_ember_handlebars'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/ember-rails-0.16.1/lib/ember/handlebars/template.rb:27:in `evaluate'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/context.rb:197:in `block in evaluate'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `each'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `evaluate'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:12:in `initialize'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `new'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:395:in `circular_call_protection'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:373:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:105:in `each'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `new'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:395:in `circular_call_protection'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:373:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:105:in `each'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `new'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:395:in `circular_call_protection'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:373:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `new'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:211:in `block in find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:257:in `benchmark'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:210:in `find_asset'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:119:in `block in compile'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `each'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `compile'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-2.12.3/lib/rake/sprocketstask.rb:146:in `with_logger'
/usr/local/rvm/gems/ruby-2.2.0@ch_master_package/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

1 个答案:

答案 0 :(得分:0)

是的,我对Ember 1.12升级有相同的经验,请参阅https://github.com/emberjs/rfcs/pull/65#issuecomment-114964973弃用打破了构建并阻止了我的项目的发布。我不得不修复阻止的延迟,延迟释放一天