{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/26","repository_url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter","labels_url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/26/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/26/events","html_url":"https://github.com/Microsoft/TypeScript-Babel-Starter/issues/26","id":375979648,"node_id":"MDU6SXNzdWUzNzU5Nzk2NDg=","number":26,"title":"regeneratorRuntime is not defined","user":{"login":"adilsoncarvalho","id":349796,"node_id":"MDQ6VXNlcjM0OTc5Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/349796?v=4","gravatar_id":"","url":"https://api.github.com/users/adilsoncarvalho","html_url":"https://github.com/adilsoncarvalho","followers_url":"https://api.github.com/users/adilsoncarvalho/followers","following_url":"https://api.github.com/users/adilsoncarvalho/following{/other_user}","gists_url":"https://api.github.com/users/adilsoncarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/adilsoncarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adilsoncarvalho/subscriptions","organizations_url":"https://api.github.com/users/adilsoncarvalho/orgs","repos_url":"https://api.github.com/users/adilsoncarvalho/repos","events_url":"https://api.github.com/users/adilsoncarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/adilsoncarvalho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-31T14:06:58Z","updated_at":"2018-11-11T08:38:55Z","closed_at":null,"author_association":"NONE","body":"Hi there.\r\n\r\nDo you guys have an option on how to deal with the `regeneratorRuntime is not defined` issue?\r\n\r\nI updates your `index.ts` and added the following method into the C class:\r\n\r\n```typescript\r\nasync metodo() {\r\n  return \"ok\";\r\n}\r\n```\r\n\r\nAfter building it and trying to invoke the transpiled code using `node ./lib/index` I got the following error:\r\n\r\n```\r\n$ node\r\n> require(\"./lib/index\")\r\nReferenceError: regeneratorRuntime is not defined\r\n    at /Users/adilson/dev/TypeScript-Babel-Starter/lib/index.js:46:7\r\n    at /Users/adilson/dev/TypeScript-Babel-Starter/lib/index.js:64:6\r\n> \r\n```\r\n\r\nThat's because of this part of the generated code that requires `regeneratorRuntime` to work:\r\n\r\n```javascript\r\n_createClass(C, [{\r\n  key: \"metodo\",\r\n  value: function () {\r\n    var _metodo = _asyncToGenerator(\r\n    /*#__PURE__*/\r\n    regeneratorRuntime.mark(function _callee() {\r\n      return regeneratorRuntime.wrap(function _callee$(_context) {\r\n        while (1) {\r\n          switch (_context.prev = _context.next) {\r\n            case 0:\r\n              return _context.abrupt(\"return\", \"ok\");\r\n\r\n            case 1:\r\n            case \"end\":\r\n              return _context.stop();\r\n          }\r\n        }\r\n      }, _callee, this);\r\n    }));\r\n\r\n    return function metodo() {\r\n      return _metodo.apply(this, arguments);\r\n    };\r\n  }()\r\n}]);\r\n```\r\n\r\nAll the post I saw so far mention those two options:\r\n\r\n* [@babel/plugin-transform-regenerator](https://babeljs.io/docs/en/babel-plugin-transform-regenerator) which I could not manage to get it working\r\n\r\n* to add `@babel/polyfill` that actually works but it is a terrible option when coding a new lib as there is no _central_ import point, making the require to happen on each file\r\n\r\nDo you have any tips on that?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/comments/437652709","html_url":"https://github.com/Microsoft/TypeScript-Babel-Starter/issues/26#issuecomment-437652709","issue_url":"https://api.github.com/repos/Microsoft/TypeScript-Babel-Starter/issues/26","id":437652709,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzY1MjcwOQ==","user":{"login":"mng-au","id":3161502,"node_id":"MDQ6VXNlcjMxNjE1MDI=","avatar_url":"https://avatars3.githubusercontent.com/u/3161502?v=4","gravatar_id":"","url":"https://api.github.com/users/mng-au","html_url":"https://github.com/mng-au","followers_url":"https://api.github.com/users/mng-au/followers","following_url":"https://api.github.com/users/mng-au/following{/other_user}","gists_url":"https://api.github.com/users/mng-au/gists{/gist_id}","starred_url":"https://api.github.com/users/mng-au/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mng-au/subscriptions","organizations_url":"https://api.github.com/users/mng-au/orgs","repos_url":"https://api.github.com/users/mng-au/repos","events_url":"https://api.github.com/users/mng-au/events{/privacy}","received_events_url":"https://api.github.com/users/mng-au/received_events","type":"User","site_admin":false},"created_at":"2018-11-11T08:38:55Z","updated_at":"2018-11-11T08:38:55Z","author_association":"NONE","body":"I am able to get `regeneratorRuntime is not defined` issue resolved today. I will note down what I found here.\r\n\r\nInstead of `@babel/plugin-transform-regenerator`, add `@babel/plugin-transform-runtime` and `@babel/runtime`.\r\n\r\n```sh\r\nyarn add -D @babel/plugin-transform-runtime @babel/runtime\r\n```\r\n\r\nThen add `@babel/plugin-transform-runtime` to `.babelrc`, and should look like the following:\r\n\r\n```json\r\n{\r\n    \"presets\": [\r\n        \"@babel/env\",\r\n        \"@babel/typescript\"\r\n    ],\r\n    \"plugins\": [\r\n        \"@babel/plugin-transform-runtime\",\r\n        \"@babel/proposal-class-properties\",\r\n        \"@babel/proposal-object-rest-spread\"\r\n    ]\r\n}\r\n```\r\n\r\nPlease let me know does it fix your issue with `regeneratorRuntime is not defined`. I will upload a small working webpack solution to github if necessary.\r\n\r\nAll the best.\r\n"}}
{"actor":{"display_login":"mng-au"}}