mattma / ember-rocks

An Em(ber) command line utility to help you build an ambitious web application via `em` command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled rejection TypeError

surpmillet opened this issue · comments

[22:51:04] [-log:] em-cli is doing REALLY hard to initialize your repo ...
Unhandled rejection TypeError: undefined is not a function
at C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\src\commands\create.js:166:7
at tryCatcher (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js\main\util.js:2
4:31)
at Promise._settlePromiseFromHandler (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\blu
ebird\js\main\promise.js:466:31)
at Promise._settlePromiseAt (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js
main\promise.js:545:18)
at Promise._settlePromises (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js\m
ain\promise.js:661:14)
at Async._drainQueue (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js\main\as
ync.js:79:16)
at Async._drainQueues (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js\main\a
sync.js:89:10)
at Async.drainQueues (C:\Users\she\AppData\Roaming\npm\node_modules\ember-rocks\node_modules\bluebird\js\main\as
ync.js:14:14)
at process._tickCallback (node.js:419:13)

I will look into it. Thanks

Indeed! it is a problem. I will roll in a fix soon.

@mattma thanks,and how can I compile my handlebars templates and concat into a templates.js without wrapping amd by using gulp-htmlbars?

In your generated ember-rocks project root folder, open gulpfile.js

Search for task buildhbs

gulp.task('buildhbs', function () {
  return gulp.src(clientFolder + '/app/templates/**/*.hbs')
    .pipe($.htmlbars({
      isHTMLBars:       true,
      templateCompiler: require('./client/assets/vendors/ember/ember-template-compiler')
    }))
    .pipe($.wrapAmd({
      deps:         ['exports'],          // dependency array
      params:       ['__exports__'],        // params for callback
      moduleRoot:   'client/app/',
      modulePrefix: 'rocks/'
    }))
    .pipe($.replace(
      /return export default/, 'return __exports__["default"] ='
    ))
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest(clientFolder + '/assets/build/'));
});

So in here gulp-wrap-amd module is actually wrapped output code into the amd format. Feel free to replace or remove to whatever you like.

@mattma thanks.
In the past,I compiled by using gulp-ember-template-compiler and it works well with ember<1.9and handlebars<2.0.Now,I compile by using gulp-htmlbars,but it doesn't work with ember#1.11.0.why?

//templates.js by using gulp-ember-template-compiler
Ember.TEMPLATES['application'] = Ember.Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
  var stack1, buffer = '';//...
Ember.TEMPLATES['main'] = Ember.Handlebars.template//...
Ember.TEMPLATES['main/index'] = Ember.Handlebars.template//...
//templates.js by using gulp-htmlbars
define("application",["exports"],function(__exports__){
return __exports__["default"] = Ember.HTMLBars.template((function() {
  return {
    isHTMLBars: true,
    blockParams: 0,
    cachedFragment: null,
    hasRendered: false,//...
define("main",["exports"],function(__exports__)//...
define("main/index",["exports"],function(__exports__)//...

Have you read this post? I think it should answer your question.

If you look at the code that you have attached in your questions, you should see the output of Ember.Handlebars.template, now with Ember@1.10.0, you could drop the handlebars.js, and use htmlbars via the new syntax Ember.HTMLBars.template

I have been busy but I will take care of this issue soon.

@mattma thanks.I have resolved the problem.and published a plugin named gulp-ember-template which could compile the handlebars for ember.js>1.11.0.

@surpmillet Finally get some time today to resolve this issue. Going to submit the patch soon.

I did not go in-depth on your plugin. First, it is a great initiative to issue a new plugin. Here is a few things that you need to consider,

  1. gulp eco system, one plugin does one thing, does really good. Not used to solve your own particular problem.
  2. gulp eco system, if someone else already have a solution to solve something, use that one.

gulp-htmlbars is what I wrote which used in ember-rocks has 100% code coverage and full unit tests. Currently, by default it works for handlebars file out of box. I am sure that we could tweak it to suite your specific use case without authoring another plugin.

@surpmillet Could you take the latest 0.9.3 version of Ember Rocks, verify the bug has been fixed? If it does, close it.

Thanks.

@surpmillet Just gonna close it since I had not heard anything from you. Well, if it is still an issue, please, reopen it. Thanks.

@mattma OK,thanks for your help