2
votes

I am deploying an Ember CLI app through jenkins and publishing it using nginx. Here is by jenkins build script:

npm install
bower install
node_modules/ember-cli/bin/ember build --environment=production

The nginx configuration simply directs sub.domain.com to jenkins\jobs\lastStable\archive\dist. That works fine, but when I go the page, it is blank and the following output in the console:

TypeError: Ember.Handlebars.compile is not a function   vendor-92ab6507ac60a5bf7c6819aa8fc418d6.js:18
ReferenceError: Swag is not defined   spa-client-9b01c6124f5b2a4cd2e95b62be7f5ba5.js:1

I am guessing that the two errors are related, but I can't figure out what is causing them. I have tried this answer to what appears to be a similar question, but it doesn't work for me. Everything works fine in my dev environment, and I can't see anything suspicious in the Brocfile.js.

3
I had run into similar issue in production. In my case, I had a component with layout defined as "layout : Ember.Handlebars.complie('....')". But then I removed the layout part, then I created a separate hbs file for the component itself and wolla at least the Ember.Handlebars.compile is not a function error was gone.Deewendra Shrestha

3 Answers

1
votes

Production uses handlebars-runtime which does not include Ember.Handlebars.compile. The reason is that it's smaller to use that in production and it's more effective to precompile which ember-cli does for you automatically.

Lots of discussion on the PR found here

3
votes

I have same issue with one of third-party libraries I'm using.

I'm using this solution: https://github.com/rwjblue/_____ember-cli-test/commit/1a26911def6f04a4badee94c8a62d8205258867b

My Brocfile.js diff:

-var app = new EmberApp();
+var app = new EmberApp({
+  vendorFiles: {
+    'handlebars.js': {
+      production: 'bower_components/handlebars/handlebars.js'
+    }
+  }
+});
0
votes

I encountered this same problem with the bootstrap for ember package. The temporary solution (from GH) was to inlcude the entire handlebars.js file in production:

var fileMover   = require('broccoli-file-mover');

var vendorTree = fileMover('vendor', {
    files: {
        'handlebars/handlebars.js': 'handlebars/handlbars.runtime.js'
    }
});

var app = new EmberApp({
    vendorFiles: {
        'handlebars.js': {
            production:  'vendor/handlebars/handlebars.min.js'
    }
   }
});