ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Sample app doesn't work with es6 target

Open kamiua opened this issue 10 years ago • 6 comments

Steps to reproduce:

  1. start new ionic app "ionic start app --v2 --ts"
  2. change target in tsconfig.js to es6
  3. add "use strict"; to app and pages files to prevent compile errors
  4. "ionic serve" results in blank screen and errors in console: app.bundle.js:33847 EXCEPTION: SyntaxError: Unexpected token { app.bundle.js:33838 EXCEPTION: SyntaxError: Unexpected token {BrowserDomAdapter.logError @ app.bundle.js:33838 app.bundle.js:33838 STACKTRACE:BrowserDomAdapter.logError @ app.bundle.js:33838 app.bundle.js:33838 SyntaxError: Unexpected token { at Function (native) at Object.evalExpression (http://localhost:8100/build/js/app.bundle.js:5202:13) at TemplateCompiler._createViewFactoryRuntime (http://localhost:8100/build/js/app.bundle.js:35374:28) at http://localhost:8100/build/js/app.bundle.js:35334:50 at Zone.run (http://localhost:8100/build/js/app.bundle.js:1161:18) at Zone.run (http://localhost:8100/build/js/app.bundle.js:17519:43) at zoneBoundFn (http://localhost:8100/build/js/app.bundle.js:1134:20) at lib$es6$promise$$internal$$tryCatch (http://localhost:8100/build/js/app.bundle.js:2534:17) at lib$es6$promise$$internal$$invokeCallback (http://localhost:8100/build/js/app.bundle.js:2546:18) at lib$es6$promise$$internal$$publish (http://localhost:8100/build/js/app.bundle.js:2517:12)BrowserDomAdapter.logError @ app.bundle.js:33838

Ionic info Cordova CLI: 6.0.0 Ionic Version: 2.0.0-alpha.57 Ionic CLI Version: 2.0.0-beta.17 Ionic App Lib Version: 2.0.0-beta.8 ios-deploy version: 1.8.5 ios-sim version: 5.0.6 OS: Mac OS X El Capitan Node Version: v5.6.0 Xcode version: Xcode 7.3 Build version 7D111g

kamiua avatar Feb 17 '16 15:02 kamiua

Thanks for the issue. I took a look at this to see if I could get ES6 working in Chrome Canary and the short story is there isn't a good answer for using ES6 yet.

I ran into several issues, mainly around getting webpack to know how to load ES6 modules and bundle them.

It seemed like the syntax error you're getting is from the ES5 version of Angular 2's template compiler getting confused by ES6 class names. If you'd like to use ES6, I believe you'll need to configure webpack to load the Angular2 ES6 sources located in angular2/es6/(dev | prod)/.

This will most likely be supported at some point, but is not high priority at the moment.

tlancina avatar Feb 17 '16 17:02 tlancina

Thanks for the clarification.

kamiua avatar Feb 17 '16 20:02 kamiua

This is also an issue in Angular 2. Targeting es6 in your tsconfig does not work without alot of hassle.

jgw96 avatar Feb 18 '16 00:02 jgw96

Why target es6? Is it to use async/await? Typescript 2.0 has async/await functionality coming to es3 and es5 targets, and that is due to land reasonably soon.

danbucholtz avatar Feb 18 '16 03:02 danbucholtz

Hi,

thanks for posting great tool. I am a newby in ionic and I need to run my ionic 2 app on old android devices (2.2) with ecmascript 3 support. Especially I got errors on "delete" methods which is reserved in es3, is there is option how to specify target ES3 or use es3ify to have compatibility to older browsers?

Any help appreciated, Eugene

evgeniynet avatar Apr 28 '16 16:04 evgeniynet

@evgeniynet Hey! I answered your question over at this issue https://github.com/driftyco/ionic-conference-app/issues/184. I am going to close this issue for now as it has been a little while since there was any activity on it. If anyone feels that it should still be open feel free to comment/reopen!

jgw96 avatar Apr 28 '16 18:04 jgw96