2017-10-18 2 views
0

J'ai créé une bibliothèque angulaire contenant les services de mon projet et j'ai importé la bibliothèque dans le projet et je l'ai testée sans problème.Angular AOT erreur de construction - Taille maximum de la pile d'appels dépassée, résolution du symbole XXX dans le chemin

Mais quand je suis en train de faire une construction AOT pour mon projet angulaire cette erreur apparaît

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 

Et c'est le script qui rendent le problème "build: aot: prod: base"

Lorsque je supprime ce jeton "cross-env BUILD_AOT = 1" du script, cela fonctionnera, mais j'en ai besoin lorsque je lance l'application dans la production.

"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

Vous avez probablement une dépendance circulaire dans votre code. Voir ce connexe [GitHub Ticket # 6309] (https://github.com/angular/angular-cli/issues/6309) – Igor

+0

vous pouvez essayer --force tag aussi. – BlackEagle

+0

@BlackEagle, j'ai utilisé --force tag sans succès. –

Répondre

1

Je rechercherais votre code pour des références à SimpleAuthService. Un crédit à Igor concernant le problème de la dépendance circulaire, par ex. faites attention à la façon dont les tonneaux sont utilisés, par ex. fileA importe SimpleAuthService qui importe également un index.ts qui importe SimpleAuthService ou d'autres relations circulaires. Dans un tel scénario, une approche pourrait consister à importer explicitement certains articles au lieu d'utiliser un baril.

Remarque: vous rencontrerez généralement plus de problèmes de compilation pendant AOT et c'est une bonne chose! c'est-à-dire sa bonne pratique à exécuter avec la compilation AOT pendant votre cycle de développement de temps en temps pour s'assurer qu'il est prêt pour PROD build. AOT attrape les problèmes légitimes.

+0

Je l'ai compris, cette erreur apparaît à cause de fileA import SimpleAuthService à partir du fichier index.ts principal, je viens de faire un fichierA importer de son chemin d'origine, je ne sais pas pourquoi le fichier Canon ne fonctionne pas. –

+0

Cool. Les authServices ont tendance à être importés à plusieurs endroits, ce qui facilite les relations circulaires lorsqu'ils sont combinés avec des barils. On dirait que vous avez rompu la relation circulaire. – sarora