I'm using @angular/cli I upgraded to the 3.0.0-beta.3 and I'm getting an import error on this import:
import 'core-js/es7/reflect';
Yes, in core-js@3 es7 path removed. Use, for example, core-js/proposals/reflect-metadata.
Find the polyfills.ts in src folder and comment the line "import 'core-js/es7/reflect'" as it is not required if using AOT
I have the Angular 7 CLI working fine with core-js 3. Work around the incompatibility by adding this to your tsconfig.json file:
{
"compilerOptions": {
"paths": {
"core-js/es7/reflect": [
"node_modules/core-js/proposals/reflect-metadata"
]
}
}
}
This works by making the TypeScript compiler resolve core-js/es7/reflect to core-js/proposals/reflect-metadata. No edits in jit-polyfills.js needed.
I had the same issue as @dvdmunckh but additionally I was receiving multiple es6 issues too, I resolved them by adding one more line
"core-js/es6/*": ["node_modules/core-js/es"],
I've roll backed the version of to "core-js": "2.6.5" from"core-js": "3.0.0" and its started working. Below is my package.json.
"dependencies": {
"@angular/animations": "7.2.11",
"@angular/common": "7.2.11",
"@angular/compiler": "7.2.11",
"@angular/core": "7.2.11",
"@angular/forms": "7.2.11",
"@angular/http": "7.2.11",
"@angular/material": "7.3.6",
"@angular/platform-browser": "7.2.11",
"@angular/platform-browser-dynamic": "7.2.11",
"@angular/platform-server": "7.2.11",
"@angular/router": "7.2.11",
"@nguniversal/module-map-ngfactory-loader": "7.1.1",
"ajv": "6.10.0",
"aspnet-prerendering": "3.0.1",
"bootstrap": "4.3.1",
"core-js": "2.6.5",
"devextreme": "18.2.7",
"devextreme-angular": "^18.2.7",
"font-awesome": "4.7.0",
"jquery": "3.3.1",
"popper.js": "1.14.7",
"rxjs": "6.4.0",
"rxjs-compat": "6.4.0",
"stream": "0.0.2",
"web-animations-js": "2.3.1",
"zone.js": "0.9.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.6",
"@angular/cli": "7.3.6",
"@angular/compiler-cli": "7.2.11",
"@angular/language-service": "7.2.11",
"@types/jasmine": "3.3.12",
"@types/jasminewd2": "2.0.6",
"@types/node": "11.12.0",
"codelyzer": "4.5.0",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.5",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"protractor": "6.0.0",
"ts-node": "8.0.3",
"tslint": "5.14.0",
"typescript": "3.2.4",
"webpack-cli": "3.3.0"
},
Find the polyfills.ts in src folder and comment the line "import 'core-js/es7/reflect'" as it is not required if using AOT
Or just change it to latest core-js path since AOT qualifier applies only if you rely on Angular decorators alone (i.e. none of your dependencies apply their own decorators).
import 'core-js/proposals/reflect-metadata'
EDIT:
unintuitively (both tsconfig.ts and node_modules are in project root) prefixing the import like "../node_modules/core-js/..." gets the build working.
The compilerOptions paths workaround appears to do nothing as of angular-devkit 0.13.8 and core-js 3.0.1.
Is there a viable workaround short of hacking jit-polyfills.js (brittle) or just giving up and rolling back to core-js 2.x?
@dvdmunckhof thanks. worked for me.
edit: I'm quite dumb actually, you juste have to import core-js/es/array haha
nb : note that with angular 8 you no longer need to import reflect as it is bundled by default in angular cli
I had an error : Error: Can't resolve 'core-js/es7/array'
Resolved by adding :"core-js/es7/*": ["node_modules/core-js/es"]
resulting in addition with all of the fixes :
"paths": {
"core-js/es7/reflect": [
"node_modules/core-js/proposals/reflect-metadata"
],
"core-js/es6/*": ["node_modules/core-js/es"],
"core-js/es7/*": ["node_modules/core-js/es"]
}
Not working for me.
"paths": {
"core-js/es7/reflect": [
"./node_modules/core-js/proposals/reflect-metadata"
]
}
Module not found: Error: Can't resolve 'core-js/es7/reflect'
Not working for me, my package.json
"dependencies": {
"@angular/animations": "~8.2.6",
"@angular/common": "~8.2.6",
"@angular/compiler": "~8.2.6",
"@angular/core": "~8.2.6",
"@angular/forms": "~8.2.6",
"@angular/http": "~8.0.0-beta.10",
"@angular/platform-browser": "~8.2.6",
"@angular/platform-browser-dynamic": "~8.2.6",
"@angular/router": "~8.2.6",
"core-js": "^3.2.1",
"nativescript-angular": "~8.2.1",
"nativescript-theme-core": "~2.0.20",
"reflect-metadata": "~0.1.13",
"rxjs": "~6.5.3",
"tns-core-modules": "~6.1.1",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.6",
"@angular-devkit/build-angular": "~0.803.4",
"@nativescript/schematics": "~0.7.1",
"@nativescript/tslint-rules": "~0.0.4",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.7.5",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"nativescript-dev-webpack": "~1.2.0",
"protractor": "~5.4.2",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "~3.6.3",
"node-sass": "^4.12.0"
}
my tsconfig
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom", "es6", "es2015.iterable"],
"baseUrl": ".",
"paths": {
"@src/": ["src/.android.ts", "src/.ios.ts", "src/.tns.ts", "src/.web.ts", "src/.ts"],
"core-js/es7/reflect": ["node_modules/core-js/proposals/reflect-metadata"],
"core-js/es6/": ["node_modules/core-js/es"],
"core-js/es7/": ["node_modules/core-js/es"]
}
}
}
@Arystosedes, this workaround is not needed when using Angular 8, as Angular 8 uses core-js 3 out of the box.
Most helpful comment
I have the Angular 7 CLI working fine with core-js 3. Work around the incompatibility by adding this to your
tsconfig.jsonfile:This works by making the TypeScript compiler resolve
core-js/es7/reflecttocore-js/proposals/reflect-metadata. No edits injit-polyfills.jsneeded.