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

Class constructor FirestoreAdapter cannot be invoked without 'new' #568

Closed
samselikoff opened this issue Mar 23, 2019 · 6 comments
Closed

Comments

@samselikoff
Copy link

I'm trying out v3 on a new 3.8 app and running into this error when trying to access this.store in a controller:

Class constructor FirestoreAdapter cannot be invoked without 'new'

I believe this is the same error @zoltan-nz pointed out on #553.

e.g.
DEBUG: -------------------------------
DEBUG: Ember      : 3.8.0
DEBUG: Ember Data : 3.8.0
DEBUG: jQuery     : 3.3.1
DEBUG: EmberFire  : 3.0.0-rc.1-4
DEBUG: Firebase   : 5.9.1
DEBUG: -------------------------------

Test case

I can provide a repo if needed

Expected behavior

I can use the store! :)

Actual behavior

I see this error message:

Uncaught TypeError: Class constructor FirestoreAdapter cannot be invoked without 'new'

@zoltan-nz
Copy link

zoltan-nz commented Mar 23, 2019 via email

@bhernez
Copy link

bhernez commented Mar 24, 2019

Kind of weird that my application was working fine a couple of hours ago with EmberFire 3.0.0-rc.1-4 and Firebase 5.8.6, and suddenly it started throwing this error

@bhernez
Copy link

bhernez commented Mar 25, 2019

I've read that this is more a Babel issue, I haven't tested but here they say that configuring Babel presets could help: https://stackoverflow.com/a/51860850 and babel/babel#4269 (comment) and koajs/koa#568 (comment)

@bnetter
Copy link
Contributor

bnetter commented Apr 21, 2019

I'm having the same issue. @samselikoff did you find a solution?

DEBUG: -------------------------------
DEBUG: Ember      : 3.9.1
DEBUG: Ember Data : 3.9.1
DEBUG: jQuery     : 3.4.0
DEBUG: EmberFire  : 3.0.0-rc.1-4
DEBUG: Firebase   : 5.10.0
DEBUG: -------------------------------

@bhernez
Copy link

bhernez commented Apr 21, 2019

@bnetter I found a workaround, but not sure how other things it'll break, I'm actually right now testing for a project.

The problem seems related to babel and the way it handles native classes, when searching in Google I found a lot of "solutions" that pointed to exclude 'transform-es2015-classes' and 'transform-classes' from babel, also using target: 'node'; but again, I'm not very sure how to set/configure that.

Well, the workaround I've just see that allows me to build the project is to add ie 11 in the build targets. The easiest way is to change the config/targets.js file like this:

// config/targets.js 

'use strict';
  
const browsers = [
  'last 1 Chrome versions',
  'last 1 Firefox versions',
  'last 1 Safari versions'
];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';

//if (isCI || isProduction) {
  browsers.push('ie 11');
//}

module.exports = {
  browsers
};

Well, it can be done properly just removing the if or adding the ie 11 to the array of browsers, but well that's basically the point.

The first problem I've found it's that when using Fastboot emberfire wants to import XMLHttpRequest, and it breaks the build; but that is more a general Fastboot issue, that I vaguely remember I solved before

@oskarrough
Copy link
Contributor

I also had this and it went away after upgrading ember-source. Maybe version +3.5? Didn't need to touch targets.js.

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

No branches or pull requests

6 participants