systemjs / plugin-babel

SystemJS Babel Plugin
MIT License
83 stars 33 forks source link

Wrong scope when transpile to System.register? #88

Open RobertCZ opened 6 years ago

RobertCZ commented 6 years ago

Trying to transpile something like

class C {}
export function factory() {
    return new C()
}

with minimal config

    transpiler: 'plugin-babel',
    meta: {
        '*.js': {
            babelOptions: {
                es2015: false,
            },
        },
    },

and getting ReferenceError: C is not defined because it's transpiled to

(function(System, SystemJS) {System.register([], function (_export, _context) {
    "use strict";

    function factory() {
        return new C();
    }

    _export("factory", factory);

    return {
        setters: [],
        execute: function () {
            class C {}
        }
    };
});
})(System, System);

So scope for class C is wrong. Any way to fix/workaround it? Thanks

guybedford commented 5 years ago

This should be fixed in the latest Babel releases. An update to this plugin for newer Babel builds can be made.