Giter Site home page Giter Site logo

Comments (3)

choclaudio avatar choclaudio commented on September 3, 2024 1

Hi there! While we wait for this particular issue to be solved. What should we do in the meantime to get async/await working?

having the --web-component flag still produces the same problem.
installing babel-polyfill on my project does not solve the problem.
adding a babel section with includePolyfill: true in ember-cli-build.js does not solve the problem.

Any combination of the above does not seem to work.

from glimmer-application.

matt-mendonca avatar matt-mendonca commented on September 3, 2024 1

As a quick work around, I switched the target in the .tsconfig to es5:

 {
   "compilerOptions": {
-    "target": "es6",
+    "target": "es5",
     "module": "es2015",
     "inlineSourceMap": true,
     "inlineSources": true,

If the browsers you are targeting already have promises, then that should do the trick.

Typescript will warn that you'll need to explicitly include promises (since es5 didn't have them):
An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.

That should be something like this:

{
   "compilerOptions": {
-    "target": "es6",
+    "target": "es5",
     "module": "es2015",
     "inlineSourceMap": true,
     "inlineSources": true,
     "moduleResolution": "node",
-    "experimentalDecorators": true
+    "experimentalDecorators": true,
+    "lib": [
+      "es2015"
+    ]
   },

However, looks like we can't manually specify extra libs in the tsconfig file with broccoli yet and adding the lib property causes the build to fail (tildeio/broccoli-typescript-compiler#35):

The Broccoli Plugin: [broccoli-typescript-compiler] failed with:
TypeError: Cannot read property 'length' of undefined

So, don't add the lib property and just ignore the typescript warning.

Overall, not ideal, but it at least got me started.

from glimmer-application.

locks avatar locks commented on September 3, 2024

Instructions now at https://github.com/glimmerjs/glimmer-application-pipeline#enabling-use-of-async-await-in-components.

from glimmer-application.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.