systemjs / plugin-babel

SystemJS Babel Plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong scope when transpile to System.register?

RobertCZ opened this issue · comments

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

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