2017-10-18 9 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:基本」を

私はこのトークンを "cross-env BUILD_AOT = 1"というスクリプトから削除してもうまく動作しますが、アプリケーションをprodutionで実行するときにはこの必要があります。

"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への参照を検索します。

例えば循環依存関係に関するIgorの信用度。どのように樽が使用されるかに注意してください。 fileAは、SimpleAuthServiceまたはそのような他の循環関係をインポートするindex.tsもインポートするSimpleAuthServiceをインポートします。このようなシナリオでは、1つのアプローチでは、バレル経由ではなく特定のアイテムを明示的にインポートすることができます。

注:一般的に、AOT時にはより多くのコンパイルに関する問題が発生しますが、それは良いことです!つまり、開発サイクル中にAOTコンパイルを実行し、PRODビルドの準備が整っていることを確認することをお勧めします。 AOTは正当な問題を抱えています。

+0

私はそれを理解しましたが、このエラーはファイルindexAts.tsからインポートされたファイルSimpleAuthServiceのために表示されます。私はfileAを元のパスからインポートします。なぜバレルファイルが動作しないのですか? –

+0

Cool。 AuthServicesは複数の場所にインポートされる傾向があり、バレルと組み合わせると循環関係に簡単につながります。あなたが循環的な関係を壊したような音。 – sarora

関連する問題