2

我有 angular 2 应用程序,它在 JIT 编译时运行良好。现在对于 Prod,我正在使用 AOT 编译和汇总创建单个捆绑文件。当我运行应用程序时,我在 Chrome 开发工具的控制台中收到此错误


Error: Uncaught (in promise): TypeError: Illegal constructor
TypeError: Illegal constructor
at new e (http://localhost:61102/app/build.js:14:6950)
at e.createInternal (http://localhost:61102/app/build.js:47:22406)
at e.t.createHostView (http://localhost:61102/app/build.js:7:10163)
at t.create (http://localhost:61102/app/build.js:6:6211)
at e.bootstrap (http://localhost:61102/app/build.js:6:13675)
at http://localhost:61102/app/build.js:6:11927
at Array.forEach (native)
at e._moduleDoBootstrap (http://localhost:61102/app/build.js:6:11898)
at http://localhost:61102/app/build.js:6:11228
at ZoneDelegate.invoke (http://localhost:61102/js/zone.js:365:26)
at Object.onInvoke (http://localhost:61102/app/build.js:5:13894)
at ZoneDelegate.invoke (http://localhost:61102/js/zone.js:364:32)
at Zone.run (http://localhost:61102/js/zone.js:125:43)
at http://localhost:61102/js/zone.js:760:57
at ZoneDelegate.invokeTask (http://localhost:61102/js/zone.js:398:31)
at Object.onInvokeTask (http://localhost:61102/app/build.js:5:13794) [angular]
____________________Elapsed_3_ms__At__Thu_Mar_16_2017_16_09_17_GMT_0530__India_Standard_Time_@[native code]
at Object.onScheduleTask (http://localhost:61102/js/zone.js:274:29) [angular]
at resolvePromise (http://localhost:61102/js/zone.js:707:21) [angular]
at Object.onInvokeTask (http://localhost:61102/app/build.js:5:13794) [angular]
____________________Elapsed_9_ms__At__Thu_Mar_16_2017_16_09_17_GMT_0530__India_Standard_Time_@[native code]
at Object.onScheduleTask (http://localhost:61102/js/zone.js:274:29) [angular]
at resolvePromise (http://localhost:61102/js/zone.js:707:21) [angular]
at http://localhost:61102/js/zone.js:760:17 [angular]
at Object.onInvokeTask (http://localhost:61102/app/build.js:5:13794) [angular]
____________________Elapsed_17_ms__At__Thu_Mar_16_2017_16_09_17_GMT_0530__India_Standard_Time_@[native code]
at Object.onScheduleTask (http://localhost:61102/js/zone.js:274:29) [angular]
at new t (http://localhost:61102/app/build.js:4:30262) [angular]
at e.createInternal (http://localhost:61102/app/build.js:49:30624) [angular]
at e.create (http://localhost:61102/app/build.js:6:16079) [angular]
at t.create (http://localhost:61102/app/build.js:6:15833) [angular]
t.handleError @ build.js:4
next @ build.js:6
e.object.r @ build.js:5
e.__tryOrUnsub @ build.js:5
e.next @ build.js:5
e._next @ build.js:5
e.next @ build.js:5
e.next @ build.js:5
e.emit @ build.js:5
t.triggerError @ build.js:5
onHandleError @ build.js:5
ZoneDelegate.handleError @ zone.js:369
Zone.runGuarded @ zone.js:141
_loop_1 @ zone.js:604

drainMicroTaskQueue@zone.js:613

TSconfig-aot.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "suppressImplicitAnyIndexErrors": true,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ],
  "files": [
    "Scripts/app/app.module.ts",
    "Scripts/app/main.ts"
  ],
  "angularCompilerOptions": {
    "genDir": "aot",
    "skipMetadataEmit": true
  }
}

Rollup.config.js

//import rollup      from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs    from 'rollup-plugin-commonjs';
import uglify      from 'rollup-plugin-uglify';

//import moment      from 'moment';

export default {
entry: 'Scripts/app/main.js',
    dest: 'wwwroot/app/build.js', // output a single application bundle
    sourceMap: true,
    sourceMapFile: 'wwwroot/js/build.js.map',
format: 'iife',
onwarn: function(warning) {

    // Skip certain warnings

    // should intercept ... but doesn't in some rollup versions
    if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }

    // intercepts in some rollup versions
    //if ( warning.indexOf("The 'this' keyword is equivalent to 'undefined'") > -1 ) { return; }

    // console.warn everything else
    console.warn( warning.message );
},
plugins: [
    nodeResolve({jsnext: true, module: true}),
    commonjs({
        include: ['node_modules/rxjs/**',
            'node_modules/moment/**',
            'node_modules/ng2-bootstrap/**']
    }),
    uglify()
]
}

我已经生成了源地图。我怎样才能弄清楚问题是什么?

4

0 回答 0