dojo / meta

:rocket: Dojo - meta information for the project.
Other
226 stars 50 forks source link

Error when targeting ES2015+ #253

Open tomc974 opened 6 years ago

tomc974 commented 6 years ago

Hi,

I'm currently trying to build a simple app with Dojo 2 and used the dojo-cli to create a project. I noticed in the generated tsconfig.json that the target is set to es5. With this setting my application is working fine, however if I try to set the target to ES2015+, I get a run-time error.

To reproduce this issue, just create a project with dojo-cli and change the target in tsconfig.json to es2015.

So now I'm wondering why a brand new framework like Dojo 2 can't be compiled to ES2015+...

dylans commented 6 years ago

@tomc974 this should work. Could you provide a bit more information about what you're including in your app and what the run-time error is that you get and in which run-time environments? My guess without having any details is that there may be a missing polyfill or shim that might still be needed for certain features in some browsers. Though it's always possible we missed something, so if you can share more details that would be helpful. Thanks!

tomc974 commented 6 years ago

@dylans Thanks for your answer. Here are some details about my environment:

I build the website with dojo build --mode dev -w memory -s and in the console I have the following error :

To reproduce, just create a project with dojo create app --name dummy and change the target in tsconfig.json to es2015. The error occurs with just that modification.

nicknisi commented 6 years ago

This appears to be caused in this case by the ProjectorMixin expecting the widget passed to it to not be a ES class. This is because the Dojo packages are compiled to ES5, so the ProjectorMixin is attempting to call apply on the class, which isn't allowed. image

We do currently ship es2015 classes that are used with the cli-build-widget commands to target evergreen browsers, but do not currently enable that functionality for cli-build-app commands. We would like to switch this up and support evergreen browsers first, as discussed in dojo/cli-build-app#64 and dojo/cli-build-app#65.

matt-gadd commented 6 years ago

This is fixed as a forwards compatible change by https://github.com/dojo/cli-build-app/pull/100. And will be in cli-build-app version 2.0.1