seeden / angular-es6

Angular ES6 utility library. Write directives, controllers and services as ES6 classes.
MIT License
100 stars 18 forks source link

exception angu 1.5.5 + angu-es6 + babel + webpack #4

Closed cybermerlin closed 8 years ago

cybermerlin commented 8 years ago
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module vGate due to:
Error: [$injector:modulerr] Failed to instantiate module function CoreView() due to:
TypeError: Cannot call a class as a function
    at _classCallCheck (http://localhost:8080/vGate.dev.js:57807:100)
    at CoreView (http://localhost:8080/vGate.dev.js:57827:4)
    at Object.invoke (http://localhost:8080/vGate.dev.js:12916:20)
    at http://localhost:8080/vGate.dev.js:12820:46
    at forEach (http://localhost:8080/vGate.dev.js:8573:21)
    at loadModules (http://localhost:8080/vGate.dev.js:12799:6)
    at http://localhost:8080/vGate.dev.js:12816:41
    at forEach (http://localhost:8080/vGate.dev.js:8573:21)
    at loadModules (http://localhost:8080/vGate.dev.js:12799:6)
    at createInjector (http://localhost:8080/vGate.dev.js:12721:20)
http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=function%20CoreView…reateInjector%20(http%3A%2F%2Flocalhost%3A8080%2FvGate.dev.js%3A12721%3A20)
    at http://localhost:8080/vGate.dev.js:8319:13
    at http://localhost:8080/vGate.dev.js:12838:16
    at forEach (http://localhost:8080/vGate.dev.js:8573:21)
    at loadModules (http://localhost:8080/vGate.dev.js:12799:6)
    at http://localhost:8080/vGate.dev.js:12816:41
    at forEach (http://localhost:8080/vGate.dev.js:8573:21)
    at loadModules (http://localhost:8080/vGate.dev.js:12799:6)
    at createInjector (http://localhost:8080/vGate.dev.js:12721:20)
    at doBootstrap (http://localhost:8080/vGate.dev.js:9997:21)
    at bootstrap (http://localhost:8080/vGate.dev.js:10018:13)
http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=vGate&p1=Error%3A%2…t%20bootstrap%20(http%3A%2F%2Flocalhost%3A8080%2FvGate.dev.js%3A10018%3A13)(anonymous function) @ angular.js:68(anonymous function) @ angular.js:4587forEach @ angular.js:322loadModules @ angular.js:4548createInjector @ angular.js:4470doBootstrap @ angular.js:1746bootstrap @ angular.js:1767angularInit @ angular.js:1652(anonymous function) @ angular.js:30863trigger @ angular.js:3166defaultHandlerWrapper @ angular.js:3456eventHandler @ angular.js:3444

package.json

    "angular-es6": "^3.0.5",
    "angular-sanitize": "^1.5.5",
    "angular-winjs": "^4.4.0",
    "babel-core": "^6.5.1",
    "babel-loader": "^6.2.2",
    "babel-preset-es2015": "^6.5.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.9.0",

webpack.config.js

module: {
        noParse: /(d3.js)|((angular\/angular)|(moment\/locale\/))[^!]+$/,
        preLoaders: [
            //{
            //  test: /\.(jsx?|js)$/,
            //  exclude: /(node_modules|bower_components)/,
            //  loader: 'source-map'
            //}
        ],
        loaders: [
            { test: /[\/]angular\.js$/, loader: 'exports?angular' },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('css-loader?sourceMap')
            },
            {
                // JS LOADER
                // Reference: https://github.com/babel/babel-loader
                // Transpile .js files using babel-loader
                // Compiles ES6 and ES7 into ES5 code
                test: /\.js$/,
                loader: 'babel',
                exclude: /(node_modules|.idea|tests|out|docs)/,
                query: {
                    // https://github.com/babel/babel-loader#options
                    cacheDirectory: true,
                    presets: ['es2015', 'stage-0']
                }
            },

Core.js

'use strict';

import CoreView from './View/Core';
import 'angular-winjs';
import {load} from 'angular-es6';

const MODULE_NAME = 'Core';

load.controllers(require.context('./', true, /.*\.js$/), MODULE_NAME);

export default MODULE_NAME;

View\Core.js

'use strict';

import WinJS from 'winjs';
import {Inject} from 'angular-es6';

/**
 * @class Core.View.Core
 * @altClassName CoreView
 * @singleton
 */
class CoreView extends Inject {
    static $inject = [];

    /* @ngInject */
    constructor(...args) {
        super(...args);
        console.log('Start Core.View.Core');
seeden commented 8 years ago

nice but I am not remote debuger

cybermerlin commented 8 years ago

и как я могу помочь? эта библиотека просто передается в angular.module().controller( класс как он есть, по сути и без angular-es6 ошибка возникает та же.

может есть идея как иначе передавать в ангуляр классы из es6?

seeden commented 8 years ago

Please take a look on the https://github.com/seeden/angular-es6/tree/master/example It is working example. You can start there