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

ui5-task-transpile - regeneratorRuntime is not defined #242

Closed
HeneryHawk opened this issue Jun 22, 2020 · 9 comments
Closed

ui5-task-transpile - regeneratorRuntime is not defined #242

HeneryHawk opened this issue Jun 22, 2020 · 9 comments

Comments

@HeneryHawk
Copy link

Hi
i use the task ui5-task-transpile to compile my es6 code to es5.
Unfortunately the app doesn't start after compiling because of the following error

regeneratorRuntime is not defined

I have seen the comment in the Main.controller.js of the demo app
Are there any plans to implement the functionality?

Many greetings

@vobu
Copy link
Contributor

vobu commented Jun 23, 2020

hi, i'm assuming you're using async/await in your code. this breaks the downport to ES5 because of the missing shim, as you experienced.
you can resolve this by using regenerator-runtime as a dev dependency and extending the build task. @lemaiwo has blogged about this and provided a how-to: https://blogs.sap.com/2019/08/28/ui5-tooling-custom-transpiler-babel-builder-extension-task/

hth, v.

@HeneryHawk
Copy link
Author

Hi Volker
thanks for your quick response.
Wouldn't it be cool to extend the existing transpile plugin to include regenerator-runtime in the build?

Regards
Simon

@vobu
Copy link
Contributor

vobu commented Jun 30, 2020

Wouldn't it be cool to extend the existing transpile plugin to include regenerator-runtime in the build?

ab-so-lutely. i'm sure both @petermuessig and me would appreciate you giving it a shot :)

@petermuessig
Copy link
Member

petermuessig commented Jun 30, 2020

Y-E-S! :-)

As Volker mentioned above, also @lemaiwo did it already in the past - he create a PR for another project which I did not continue anymore: petermuessig/my-es6-ui5-app#7

@lennart-m
Copy link
Contributor

lennart-m commented Jun 30, 2020

Hi, have you considered using babel-plugin-transform-async-to-promises in order to support async/await?
I find the resulting code a lot more readable and it does not require any additional code like regenerator-runtime, especially after activating the option inlineHelpers.

After all, we already have Promises in UI5.

@lemaiwo
Copy link
Contributor

lemaiwo commented Jul 1, 2020 via email

@lennart-m
Copy link
Contributor

Hi @lemaiwo
This can be done by installing the dependency babel-plugin-transform-async-to-promises and creating a file babel.config.json in the project folder having the following content:

{
  "plugins": [
    [
      "babel-plugin-transform-async-to-promises",
      {
        "inlineHelpers": true
      }
    ]
  ]
}

No changes to the task/middleware is required.

Though the default configuration by the ui5-task-transpile will be overridden once you have a non-empty configuration in babel.config.json.

Also this does not enable usage of async generator functions, just async regular functions. But this is already quite a step forward.

@lboehm
Copy link
Contributor

lboehm commented Jul 4, 2020

Hi @lennart-m,

from my point of view async generator functions aren't that important. Regular async functions are way more important. So this approach would absolutely meet my requirements. I would love to see this issue handled by this custom task.

Couldn't this be implemented similar to the removeConsoleStatements option, which is already implemented? I would prefer this approach, because it doesn't require a babel.config.json in the project.

It could be enabled by adding another option to custom task configuration:

builder:
  customTasks:
  - name: ui5-task-transpile
    afterTask: replaceVersion
    configuration:
      debug: true
      removeConsoleStatements: true
      transpileAsync: true                    <-- like this
      excludePatterns:
      - "lib/"
      - "another/dir/in/webapp"
      - "yet/another/dir"

In the transpile task the plugin could be loaded, if transpileAsync is set to true. (similar to this).

Best regards,
Lukas

@vobu
Copy link
Contributor

vobu commented Jul 24, 2020

this is closed via the double-team of #260 and the (soon to be merged) #266 - thus closing this

@vobu vobu closed this as completed Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants