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

Extending service class fails when transpiling to ES5 #237

Closed
RickEyre opened this issue Sep 15, 2018 · 2 comments
Closed

Extending service class fails when transpiling to ES5 #237

RickEyre opened this issue Sep 15, 2018 · 2 comments

Comments

@RickEyre
Copy link

Steps to reproduce

I'm attempting to extend the Service class in the library like so:

import { Service } from 'feathers-sequelize';

export class SequelizeService extends Service {
  constructor(Model, options = {}) {
    super({ Model, ...options });
  }
}

const service = new Service(MyModel);

I'm also transpiling my code to ES5 using babel.

Expected behavior

The service should be created.

Actual behavior

Breaks at runtime with the following error:

TypeError: Class constructor Service cannot be invoked without 'new'

I believe this is because my transpiled code isn't trying to call the ES6 as a function without the new keyword.

If there was an ES5 version of the package published I'd be able to extend.

Or is there a better way on my end to solve this?

@daffl
Copy link
Member

daffl commented Sep 15, 2018

This is a known Babel issue (see babel/babel#6299).

Since feathers-sequelize is a server side module and is not intended to be used with Node 4 or older there should be no reason to transpile to ES5 though. I recommend using Node 6 (or ES2015) as the transpilation target.

@RickEyre
Copy link
Author

Worked perfectly. Thank you!

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

2 participants