Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when targeting ES2015+ #253

Open
tomc974 opened this issue May 23, 2018 · 4 comments
Open

Error when targeting ES2015+ #253

tomc974 opened this issue May 23, 2018 · 4 comments

Comments

@tomc974
Copy link

tomc974 commented May 23, 2018

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
Copy link
Member

dylans commented May 23, 2018

@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
Copy link
Author

tomc974 commented May 23, 2018

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

  • Windows 10 (10.0.17134.48)
  • Node.js 8.11.1 and NPM 6.0.1
  • Chrome 66 and Edge 17

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

  • In Chrome Uncaught TypeError: Class constructor HelloWorld cannot be invoked without 'new'
  • In Edge SCRIPT5632: Class constructor cannot be called without the new keyword

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.

@dylans dylans added the bug label May 23, 2018
@nicknisi
Copy link
Member

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
Copy link

This is fixed as a forwards compatible change by dojo/cli-build-app#100. And will be in cli-build-app version 2.0.1

@matt-gadd matt-gadd added enhancement and removed bug labels Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants