Ember 3.1 Upgrade Issue (Template Compile)

Hey folks - we’re running into a bit of an odd issue in a test while trying to upgrade our app to Ember 3.1, and it appears glimmer related (though we’ve hit 3 red herrings already, so forgive me if this is another one). We’re getting the following error when calling Ember.Handlebars.compile:

TypeError: (0 , _util.getAttrNamespace) is not a function
    at TemplateCompiler.attribute

After some experimentation, we’ve confirmed we get this error on any simple div with an attribute:<div class="blah">Hello</div>, so our template is not the issue. Any help here is greatly appreciated.

Some general questions:

  • Can you share the full stack trace?
  • Why are you using Ember.Handlebars.compile directly? By using compile I am assuming that you are attempting to compile templates while the app is running (e.g. in the browser runtime), but 99% of the time template compilation should be done during build time (either via hbs helper from ember-htmlbars-inline-precompile or by ember-cli-htmlbars itself compiling your .hbs files).
  • How are you loading the runtime template compiler?
  • What version of Ember are you upgrading from?

My gut feeling is that this error is a result of a mismatch between ember-template-compiler.js and ember.debug.js / ember.prod.js versions, but without more details its hard to tell…

@rwjblue - I’ll try to answer one by one. Sorry if it’s a long reply:

  • Full stack trace:
test-support.js:11387 Uncaught TypeError: (0 , _util.getAttrNamespace) is not a function
    at TemplateCompiler.attribute (test-support.js:11387)
    at TemplateCompiler.openElement (test-support.js:11365)
    at test-support.js:11319
    at Array.forEach (<anonymous>)
    at TemplateCompiler.process (test-support.js:11312)
    at Function.TemplateCompiler.compile (test-support.js:11305)
    at exports.precompile (test-support.js:11852)
    at precompile (vendor.js:52772)
    at Object.compile (vendor.js:52738)
    at Context.<anonymous> (all-tests.js:316135)
    at describe (test-support.js:9794)
    at Module.<anonymous> (all-tests.js:316134)
    at Module.callback (vendor.js:76732)
    at Module.exports (vendor.js:111)
    at requireModule (vendor.js:32)
    at requireDirectory (vendor.js:81524)
    at HTMLDocument.document.addEventListener (test-support.js:233528)
  • we’re using Ember.Handlebars.compile because we’re running a unit test. We have not yet upgraded our tests to new Ember Qunit functionality, so our tests are admittedly a bit behind. We’re just trying to render a template in a unit test, so we have a renderTemplate function that can be passed a String from a unit test, which calls Ember.Handlebars.compile to render correctly. In this case, the before of our unit test is:
  before(async function() {
    await resetApp();
    this.eventstream = sandbox.stub(appContainer().lookup('service:eventstream'), 'track');
    this.view = renderTemplate(`
      <div class="test-modal">{{authorized-users-confirmation-modal-body}}</div>
    `);
  });
  • I’m honestly not sure how to answer your third question about loading the runtime template compiler. Most of my work has been standard development, and not much work with the structure of the app / ember itself. Can you give me some details on how I’d find that? I can also ask around with some other devs at the company to find out.

  • We’re upgrading from 3.0 to 3.1. Specifically:

~/Development/dashboard/frontend/dashboard master ember -v
ember-cli: 3.0.2
node: 8.10.0
os: darwin x64

Please let me know if I can provide any additional information.

In the interim, we are moving our usages away from Ember.Handlebars.compile, and to using the hbs helper from ember-htmlbars-inline-precompile. I’m still curious as to what in the 3.1 upgrade process could have started causing the failures, though.