generator-ng-poly
generator-ng-poly copied to clipboard
import and export es6
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)
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.
@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.