我的库模块无法识别为NgModule

时间:2017-03-13 12:54:11

标签: angular typescript angular-cli

$input =~ s/\'|\"//g;的第一次编译期间,我的angular 2库中的AccordionModule似乎不是NgModule,但是他在错误之后再次重新加载,然后他可以编译并且模块被识别。< / p>
angular-cli

我尝试将 Time: 7903ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.js.map (main) 11.4 kB {3} [initial] [rendered] chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 9.77 kB {4} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.6 MB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered] ERROR in AccordionModule is not an NgModule webpack: Failed to compile. webpack: Compiling... Hash: 422f957171e71c80b1cf Time: 1999ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] chunk {1} main.bundle.js, main.bundle.js.map (main) 11.4 kB {3} [initial] chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 9.77 kB {4} [initial] chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.6 MB [initial] chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] webpack: Compiled successfully. 升级到版本typescript2.0.10,但这没有任何改变。

这是我的依赖项:

2.0.3

我的tsconfig:

 "peerDependencies": {
        "@angular/common": "^2.4.0",
        "@angular/compiler": "^2.4.0",
        "@angular/core": "^2.4.0",
        "@angular/platform-browser": "^2.4.0",
        "core-js": "2.4.1",
        "typescript": "2.0.10",
        "zone.js": "^0.7.6"
    },
    "devDependencies": {
        "@angular/compiler-cli": "^2.4.0",
        "@angular/platform-server": "^2.4.0",
        "@types/jasmine": "2.5.38",
        "@types/node": "6.0.60",
        "rimraf": "^2.5.4"
    }

1 个答案:

答案 0 :(得分:0)

使用ngc编译器而不是tsc编译器在AOT中编译包。您可以将其指向相同的tsconfig文件。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]

有关本文的更多详情https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#compile

ngc编译器将输出Angular用于识别模块的额外元数据。