I have an error since yesterday I try to fix. I successfully built an android apk using:
ionic cordova build android --prod --release
But the app stuck on white screen on device and emulator (GenyMotion). I inspected the logcat of GenyMotion. I figured out these:
> I/chromium( 5497): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token )", source: http://localhost/runtime.fcad956485f9614ff8b1.js (1)
> D/SystemWebChromeClient( 5497): http://localhost/polyfills.49d987a1d15d60566c3f.js: Line 1 : Uncaught SyntaxError: Unexpected token =>
> I/chromium( 5497): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token =>", source: http://localhost/polyfills.49d987a1d15d60566c3f.js (1)
> D/SystemWebChromeClient( 5497): http://localhost/main.2be168d95557cbdc0a3f.js: Line 1 : Uncaught SyntaxError: Unexpected token =>
> I/chromium( 5497): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token =>", source: http://localhost/main.2be168d95557cbdc0a3f.js (1)
I don't know why. They are no errors when building.
My package.json
...
"@angular/common": "~12.0.1",
"@angular/core": "~12.0.1",
"@angular/forms": "~12.0.1",
"@angular/platform-browser": "~12.0.1",
"@angular/platform-browser-dynamic": "~12.0.1",
"@ionic/angular": "^5.5.2",
"ionic": "^5.4.16",
"cordova-android": "^9.0.0",
"cordova-browser": "^6.0.0",
"cordova-ios": "^5.1.1",
"cordova-plugin-ionic-webview": "^5.0.0",
...
"@typescript-eslint/eslint-plugin": "4.16.1",
"@typescript-eslint/parser": "4.16.1",
"typescript": "~4.2.4"
My tsconfig.json.
...
"target": "es2015",
"module": "es2020",
"lib": ["es2018", "dom"]
...
After a real battle in order to fix the issue since 3 days, i solved the problem. Ionic 5 angular 12 use es2015 as a target when building. I set "target" to es5 in tsconfig.json and errors in runtime.**.js, polyfills.**.json disappeared
es5 transform ES6 function to standard functions.
More info at https://www.typescriptlang.org/tsconfig
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With