jarslab / babel-maven-plugin

Babel transcription plugin for Maven
MIT License
25 stars 8 forks source link

Uncaught ReferenceError: regeneratorRuntime is not defined #15

Closed rohityadav225 closed 4 years ago

rohityadav225 commented 4 years ago

When i try to use async/await feature, i get Uncaught ReferenceError: regeneratorRuntime is not defined error message. I guess i have to add @babel/plugin-transform-runtime plugin but i am not sure how to add the babel plugins using babel-maven-plugin. can you please let me know

My presets are <presets>es2015,es2016,es2017</presets>

milpol commented 4 years ago

Interesting. I've added test for simple async syntax and it works (with Babel7 + es2017 preset), so I assume your source code is more complicated than that. Plugins support is missing though, I'll add that.

rohityadav225 commented 4 years ago

I am using babel standalone 6.26.0, do you suggest using latest babel standalone version ? i couldn't find babel7 standalone. Also, do you have any timeline for plugins support ? Thanks.

milpol commented 4 years ago

You can take it from any CDN, the latest one is here for example: https://unpkg.com/@babel/standalone@7.9.6/babel.min.js

I'll add simple plugins definition today/tomorrow but it will require you to include the plugin into the babel source. I have some foggy idea how to include plugins as an external context but it will require more time to experiments.

rohityadav225 commented 4 years ago

Thanks.

I am trying to define modules similar to what we do in .babelrc. I was also planning to do something like below code so that we can disable modules.

{
  "presets": [
    ["es2015", { "modules": false }]
  ]
}
rohityadav225 commented 4 years ago

I still get ReferenceError: regeneratorRuntime is not defined even after using babel v7.9.6, looks like i might need something like

{
  "plugins": [
    ["transform-runtime", {
      "regenerator": true
    }]
  ]
}
milpol commented 4 years ago

I've published version 1.5 (it'll take a few minutes since it reach central). You can add plugins with: <plugins>['transform-runtime', {'regenerator': true}]</plugins> I've added test for it, it works with Babel version 7.x

rohityadav225 commented 4 years ago

Thanks. I still don't see v1.5 on maven central.

rohityadav225 commented 4 years ago

I was able to use v1.5 and the transpiled file generated for me has var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); and i get require is not defined error.

milpol commented 4 years ago

You need to use module loader in your code. Or switch Babel to use systemjs. There should be a plugin for this.