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

import and export es6 #360

Open
srobledo opened this issue Nov 25, 2016 · 2 comments
Open

import and export es6 #360

srobledo opened this issue Nov 25, 2016 · 2 comments

Comments

@srobledo
Copy link

Cannot export or import clases when using es6.

Exporting class:

export class authRestService
{
  constructor($resource, env) {
    this.$resource = $resource;
    this.env = env;
  }
}

Importing class and extending:

import {authRestService} from './authrest-service';

(function () {
  'use strict';

  class Auth extends authRestService {
    constructor($resource, env) {
      super($resource, env);
    }

    get() {
      return 'Auth';
    }
  }

  /**
   * @ngdoc service
   * @name components.service:Auth
   *
   * @description
   *
   */
  angular
    .module('components')
    .service('Auth', Auth);
}());

i get the following error on the console,

authrest-service.js:3 Uncaught ReferenceError: exports is not defined(…)(anonymous function)
auth-service.js:11 Uncaught ReferenceError: require is not defined(…)(anonymous function)

@dustinspecker
Copy link
Owner

This has been a pretty big issue for a while. ng-poly does not currently have a module bundler setup, so import/export aren't going to work.

There's a part of me that wants to get Webpack implemented (also would help with the huge Gulp files), but I haven't used Angular in ages.

I'm sorry, but this is probably something that won't be fixed anytime soon. A warning for this ought to be added to the readme.

@srobledo
Copy link
Author

@dustinspecker thank you for taking your time to respond, do you suggest any approach (some npm module ect.) so i can resolve this and added to the gulp files? and maybe create a PR for this repo, it would be nice to have it.

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

No branches or pull requests

2 participants