Nondescript compilation error message when Ivy enabled
See original GitHub issue🐞 bug report
When compiling an upgraded Angular 8.0.0 project with Ivy enabled, the compiler generates an ERROR in Value [object Object] is not literal and cannot be used in this context.
error with no further information to help identify the cause.
Is this a regression?
No. I have not tried to compile with Ivy enabled before. The project does compile fine with AoT without Ivy enabled though.
Description
I have a reasonably large application that was recently upgraded from Angular 7 to Angular 8.0.0. The application compiles without issue however when Ivy is enabled the compiler produces the following error:
Date: 2019-06-06T04:11:25.373Z
Hash: 087b7b5fb4b324ff6aca
Time: 49369ms
chunk {0} runtime-es5.b13fe75f2187557b33a6.js, runtime-es5.b13fe75f2187557b33a6.js.map (runtime) 1.49 kB [entry] [rendered]
chunk {1} main-es5.4af9b61479361f268d39.js, main-es5.4af9b61479361f268d39.js.map (main) 186 bytes [initial] [rendered]
chunk {2} polyfills-es5.cc41145fc3ff39238270.js, polyfills-es5.cc41145fc3ff39238270.js.map (polyfills) 68.1 kB [initial] [rendered]
chunk {3} styles.1a689b634a36680c47f4.css, styles.1a689b634a36680c47f4.css.map (styles) 3.66 kB [initial] [rendered]
chunk {scripts} scripts.403d9d57243d96fb1784.js, scripts.403d9d57243d96fb1784.js.map (scripts) 1.18 kB [entry] [rendered]
ERROR in Value [object Object] is not literal and cannot be used in this context.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! content-snare-client@1.2.0 build:ngx: `ng build --configuration=${NG_ENV:-prod} --deploy-url=${NG_DEPLOY_URL:-https://app.contentsnare.com/}`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the content-snare-client@1.2.0 build:ngx script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mark/.npm/_logs/2019-06-06T04_11_25_582Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! content-snare-client@1.2.0 build:aot: `npm run build:ngx`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the content-snare-client@1.2.0 build:aot script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
I reviewed the referenced log files and they provide no additional information.
The only error information that is produced is:
ERROR in Value [object Object] is not literal and cannot be used in this context.
Not sure if relevant, but the normal AoT non-ivy enabled compilation creates 28 separate chunks, with scripts being one of the last chunks created. In the above, it creates only 5 chunks.
🔬 Minimal Reproduction
I tried compiling an empty Angular 8 project and this compiles with Ivy enabled without issue.
It is very hard to provide a minimum project as my project is quite large and without any additional error information it would take me weeks to gradually remove code until the error goes away.
Although the project does comprise a dozen or so modules, the number of 3rd party NPM packages is quite small and I receive no NPM compatibility warnings when I run npm clean-install
.
Below is a list of installed project NPM packages if this helps:
"dependencies": {
"@angular/animations": "^8.0.0",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/forms": "^8.0.0",
"@angular/platform-browser": "^8.0.0",
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/router": "^8.0.0",
"@fullcalendar/core": "^4.2.0",
"@fullcalendar/daygrid": "^4.2.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"classlist.js": "^1.1.20150312",
"core-js": "^3.1.2",
"file-saver": "^2.0.1",
"moment": "^2.24.0",
"ng2-dragula": "^2.1.1",
"ngx-clipboard": "^12.0.1",
"ngx-filesaver": "^2.2.1",
"rollbar": "^2.7.1",
"rxjs": "^6.5.2",
"ts-md5": "^1.2.4",
"tslib": "^1.9.3",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.800.0",
"@angular/cli": "^8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/language-service": "^8.0.0",
"@biesbjerg/ngx-translate-extract": "^2.3.4",
"@compodoc/compodoc": "^1.1.9",
"@types/file-saver": "^2.0.1",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "~8.9.3",
"codelyzer": "^5.1.0",
"cspell": "^3.2.17",
"gzipper": "^2.6.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"prettier": "^1.17.1",
"protractor": "^5.4.2",
"ts-node": "~7.0.0",
"tslint": "~5.16.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "~3.4.5",
"webpack-bundle-analyzer": "^3.3.2"
}
🔥 Exception or Error
ERROR in Value [object Object] is not literal and cannot be used in this context.
🌍 Your Environment
Angular Version:
Angular CLI: 8.0.1
Node: 11.8.0
OS: linux x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.1
@angular-devkit/build-angular 0.800.1
@angular-devkit/build-optimizer 0.800.1
@angular-devkit/build-webpack 0.800.1
@angular-devkit/core 8.0.1
@angular-devkit/schematics 8.0.1
@angular/cli 8.0.1
@ngtools/webpack 8.0.1
@schematics/angular 8.0.1
@schematics/update 0.800.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:13 (4 by maintainers)
Good morning.
I can confirm that my entire application compiles and runs with Ivy enabled using 9.0.0-rc.9. The issue has been resolved.
Thank you all. I am in awe that our project - which is not small by any means - compiles and runs seamlessly in Ivy now. The implementation of Ivy must have been a huge undertaking for you. You are all absolute legends.
This is a known issue with the static analysis that the Ivy compiler does. We will need to support such constructions as
'foo' + 'bar'
as well asobjA || objB
. Today you get that error.Additionally, we still have some work to do in producing useful error messages for these cases instead of crashing out. Specifically, the error messages need to show where the static analyzer was unable to understand the code.