Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: this.import is not a function #35

Closed
chaitanyya opened this issue Aug 4, 2016 · 4 comments · Fixed by #38
Closed

TypeError: this.import is not a function #35

chaitanyya opened this issue Aug 4, 2016 · 4 comments · Fixed by #38
Assignees
Labels
Milestone

Comments

@chaitanyya
Copy link

I tried using the master branch but I'm getting the following error.

this.import is not a function
TypeError: this.import is not a function
    at CoreObject.module.exports.included (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/emberx-file-input/index.js:9:16)
    at CoreObject.superWrapper [as included] (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/node_modules/core-object/lib/assign-properties.js:32:18)
    at EmberApp.<anonymous> (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/broccoli/ember-app.js:435:15)
    at Array.filter (native)
    at EmberApp._notifyAddonIncluded (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/broccoli/ember-app.js:430:45)
    at new EmberApp (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/broccoli/ember-app.js:109:8)
    at module.exports (/Users/Chaitanya/Developer/Harvard/dotplot/ember-cli-build.js:6:15)
    at CoreObject.module.exports.Task.extend.setupBroccoliBuilder (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/models/builder.js:54:19)
    at CoreObject.module.exports.Task.extend.init (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/models/builder.js:89:10)
    at CoreObject.superWrapper [as init] (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/node_modules/core-object/lib/assign-properties.js:32:18)

The one on npm is still giving me deprication warning:

DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`
    at Function.Addon.lookup (/Users/Chaitanya/Developer/Harvard/dotplot/node_modules/ember-cli/lib/models/addon.js:896:27)
@Robdel12
Copy link
Collaborator

Robdel12 commented Aug 4, 2016

Hmm, I'm going to guess it's because the addon that's doing the import polyfill needs to be moved into dependencies rather than devDependencies: https://github.com/thefrontside/emberx-file-input/blob/master/package.json#L27

Tomorrow is my open source day so I'll get things patched up :)

Thanks for opening an issue!

@Robdel12 Robdel12 added the bug label Aug 4, 2016
@Robdel12 Robdel12 added this to the V1.1.0 milestone Aug 4, 2016
@Robdel12 Robdel12 self-assigned this Aug 4, 2016
@Robdel12
Copy link
Collaborator

Robdel12 commented Aug 5, 2016

Hmm I'd like to get @xcambar's feedback on this. According to this discussion we shouldn't need change anything within our addon. The consuming app, if not on the latest ember-cli, would use this addon.

This means we should remove ember-cli-import-polyfill.

@xcambar
Copy link
Contributor

xcambar commented Aug 6, 2016

There's been a lot of noise/misunderstanding around the polyfill for which I'm accountable for. But please don't forget because of that that this.import is definitively the way to go. This is how asset imports should be done in addons from now on. To sum it up:

  • The polyfill is for the host app, it's not useful anywhere else (my bad)
  • Checking whether the host app uses the new import API is the responsibility of the addon developer, unfortunately it does not come at no cost (though the total cost is 3 lines of code so...).

For the addons that want to support the whole range of ember-cli versions, here's a snippet for the included hook:

included: function(parent) {
  var import;
  if (this && typeof this.import === 'function') {
    import = this.import.bind(this);
  } else {
    import = parent.import.bind(app);
  }

  // Do your imports here
  import('path/to/my/assets/foo.js');
  import('path/to/my/assets/bar.js');
}

@xcambar
Copy link
Contributor

xcambar commented Aug 6, 2016

There's a (more general) discussion going on here: ember-cli/rfcs#63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants