2017-10-18 19 views
0

我創建角度庫包含了服務在我的項目 ,我已經導入項目庫裏面並進行測試,沒有任何問題。角AOT生成錯誤 - 最大調用堆棧大小超出,解析符號XXX在路徑

但是,當我試圖做一個AOT建立我的角度項目 這個錯誤出現

Error: Maximum call stack size exceeded, resolving symbol SimpleAuthService in C:/i.rabeea/workspaces/hero/fulfillment_angular/node_modules/zwp-modules/auth/index.d.ts, resolving symbol SimpleAuthService in C:/i.rabeea/workspaces/hero/fulfillment_angular/node_modules/zwp-modules/auth/index.d.ts, ... 
at syntaxError (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:1699:2) 
at simplifyInContext (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:24949:17) 
at StaticReflector.simplify (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:24961:7) 
at StaticReflector.annotations (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:24388:38) 
at NgModuleResolver.resolve (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:14720:34) 
at CompileMetadataResolver.getNgModuleMetadata (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:15372:58) 
at addNgModule (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\bundles\compiler.umd.js:24268:58) 
at C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\bundles\compiler.umd.js:24279:14 
at Array.forEach (<anonymous>) 
at _createNgModules (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:24248:8) 
at analyzeNgModules (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\bundles\compiler.umd.js:24153:14) 
at analyzeAndValidateNgModules (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\@angular\compiler.es5.js:24133:19) 
at AotCompiler.analyzeModulesAsync (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\compiler\bundles\compiler.umd.js:23797:46) 
at CodeGenerator.codegen (C:\i.rabeea\workspaces\hero\fulfillment_angular\packages\compiler-cli\src\codegen.ts:41:10) 
at C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\src\main.ts:19:84 
at Object.main (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\@angular\tools\@angular\tsc-wrapped\src\main.ts:136:12) 
at Object.runInternal (C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\src\main.ts:24:10) 
at C:\i.rabeea\workspaces\hero\fulfillment_angular\node_modules\src\plugin.ts:64:21 
at <anonymous> 
at process._tickCallback (internal/process/next_tick.js:188:7) 
at Function.Module.runMain (module.js:667:11) 
at startup (bootstrap_node.js:187:16) 
at bootstrap_node.js:607:3 

這是使問題 腳本「編譯:AOT:PROD:基地」

當我刪除此令牌「跨ENV BUILD_AOT = 1」從劇本它的工作將,但我需要這個運行在脾淋巴細胞應用程序時。

"scripts": { 
"build:aot:prod:base": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 npm run webpack -- --config config/webpack.prod.js --progress --profile --bail", 
"build:aot:dev-conf": "cross-env CONF_FILE=./config.dev.json npm run build:aot:prod:base", 
"build:aot:prod-conf": "cross-env CONF_FILE=./config.prod.json npm run build:aot:prod:base", 
"build:aot:prod": "cross-env CONF_FILE=./config.dev.json npm run build:aot:prod:base", 
"build:aot": "npm run build:aot:prod", 
"build:dev": "npm run clean:dist && npm run webpack -- --config config/webpack.dev.js --progress --profile", 
"build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .", 
"build:prod": "npm run clean:dist && npm run webpack -- --config config/webpack.prod.js --progress --profile --bail", 
"build": "npm run build:dev", 
"ci:aot": "npm run lint && npm run test && npm run build:aot && npm run e2e", 
"ci:jit": "npm run lint && npm run test && npm run build:prod && npm run e2e", 
"ci:nobuild": "npm run lint && npm test && npm run e2e", 
"ci:testall": "npm run lint && npm run test && npm run build:prod && npm run e2e && npm run build:aot && npm run e2e", 
"ci:travis": "npm run lint && npm run test && npm run build:aot && npm run e2e:travis", 
"ci": "npm run ci:testall", 
"clean:all": "npm run rimraf -- doc coverage dist compiled dll", 
"clean:dll": "npm run rimraf -- dll", 
"clean:aot": "npm run rimraf -- compiled", 
"clean:dist": "npm run rimraf -- dist", 
"clean:install": "npm set progress=false && npm install", 
"clean": "npm cache clean --force && npm run rimraf -- node_modules doc coverage dist compiled dll", 
"deploy:prod": "npm run clean:all && npm prune --force && npm install && npm version patch", 
"deploy:test": "npm run clean:all && npm prune --force && npm install && npm test && npm run build:aot:prod", 
"docker": "docker", 
"docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/", 
"docs:compodoc": "compodoc -p tsconfig.json", 
"docs:compodoc:serve": "compodoc -p tsconfig.json -s", 
"docs:compodoc:serve:watch": "compodoc -p tsconfig.json -s -w", 
"e2e:live": "npm-run-all -p -r server:prod:ci protractor:live", 
"e2e:travis": "npm-run-all -p -r server:prod:ci protractor:delay", 
"e2e": "npm-run-all -p -r server:prod:ci protractor", 
"github-deploy:dev": "npm run webpack -- --config config/webpack.github-deploy.js --progress --profile --env.githubDev", 
"github-deploy:prod": "npm run webpack -- --config config/webpack.github-deploy.js --progress --profile --env.githubProd", 
"github-deploy": "npm run github-deploy:dev", 
"lint": "npm run tslint \"src/**/*.ts\"", 
"node": "node", 
"postinstall": "npm run webdriver:update", 
"postversion": "git push && git push --tags", 
"preclean:install": "npm run clean", 
"preversion": "npm test", 
"protractor": "protractor", 
"protractor:delay": "sleep 3 && npm run protractor", 
"protractor:live": "protractor --elementExplorer", 
"rimraf": "rimraf", 
"server:dev:hmr": "npm run server:dev -- --hotOnly", 
"server:dev:hmr:browser": "npm run server:dev:browser -- --hotOnly", 
"server:dev": "npm run rimraf -- .awcache && npm run webpack-dev-server -- --config config/webpack.dev.js --progress --profile --watch --content-base src/", 
"server:dev:browser": "npm run server:dev -- --open", 
"server:prod": "http-server dist -c-1 --cors", 
"server:prod:ci": "http-server dist -p 3001 -c-1 --cors", 
"server": "npm run server:dev", 
"start:hmr": "npm run server:dev:hmr", 
"start:hmr:browser": "npm run server:dev:hmr:browser", 
"start": "npm run server:dev", 
"test": "npm run lint && karma start", 
"tslint": "tslint", 
"typedoc": "typedoc", 
"version": "npm run build:aot:prod", 
"watch:dev:hmr": "npm run watch:dev -- --hot", 
"watch:dev": "npm run build:dev -- --watch", 
"watch:prod": "npm run build:prod -- --watch", 
"watch:aot:prod": "npm run build:aot:prod -- --watch", 
"watch:test": "npm run test -- --auto-watch --no-single-run", 
"watch": "npm run watch:dev", 
"webdriver-manager": "webdriver-manager", 
"webdriver:start": "npm run webdriver-manager start", 
"webdriver:update": "webdriver-manager update", 
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js", 
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js" 
} 
+2

你可能在你的代碼循環依賴。看到這個相關的[GitHub Ticket#6309](https://github.com/angular/angular-cli/issues/6309) – Igor

+0

你也可以嘗試--force標籤。 – BlackEagle

+0

@BlackEagle,我用--force標籤沒有成功。 –

回答

1

我會搜索您的代碼以引用SimpleAuthService。

信用伊戈爾關於循環依賴關注如小心如何使用桶fileA導入SimpleAuthService,它還會導入導入SimpleAuthService或其他循環關係的index.ts。在這種情況下,一種方法可能是明確導入某些項目,而不是通過桶。

注意:你會在AOT一般捕到更多的編譯問題,這是一件好事!即它的良好實踐是在您的開發週期中運行AOT編譯,然後確保它已準備好進行PROD構建。 AOT捕捉合法問題。

+0

我已經想通了,出現這種錯誤,因爲從主index.ts文件的fileA進口SimpleAuthService的,我只是做從其原始路徑的fileA進口的話,我不爲什麼每桶文件無法正常工作。 –

+0

很酷。 AuthServices傾向於在多個位置導入,與桶組合時容易導致循環關係。聽起來像你打破了循環關係。 – sarora

相關問題