leonardfactory / babel-plugin-transform-typescript-metadata

Babel plugin to emit decorator metadata like typescript compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESNext module doesn't seem to be working

Adamfsk opened this issue · comments

While this plugin is getting us most of the way to working experimental decorators in typescript (thank you!) it doesn't seem to work if the module in tsconfig.json is set to esnext.

I am trying to get this working in a library that uses inversifyJS dependency injection, and export to both umd and es modules outputs. When compiling to commonjs modules it works fine, but with esnext modules, babel starts replacing the decorator functions' this property with undefined:

(!) thishas been rewritten toundefinedhttps://rollupjs.org/guide/en#error-this-is-undefined src\Book.js 3: import { typeof as _typeof } from "\0rollupPluginBabelHelpers.js"; 4: 5: var __decorate = this && this.__decorate || function (decorators, target, key, desc) {

The last line above changes to the following after babel finishes:
var __decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
which unfortunately breaks everything.