remove es20xx prefixes from plugins and rename folders (#6575)

This commit is contained in:
Henry Zhu
2017-10-28 20:43:15 -04:00
committed by GitHub
parent 92a3caeb9c
commit 9ac326b075
1672 changed files with 1200 additions and 1203 deletions

View File

@@ -0,0 +1,3 @@
src
test
*.log

View File

@@ -0,0 +1,73 @@
# @babel/plugin-transform-modules-systemjs
> This plugin transforms ES2015 modules to [SystemJS](https://github.com/systemjs/systemjs).
## Example
**In**
```javascript
export default 42;
```
**Out**
```javascript
System.register([], function (_export, _context) {
return {
setters: [],
execute: function () {
_export("default", 42);
}
};
});
```
For dynamic import support (`import('./lazy.js').then(m => ...)`), enable the [syntax-dynamic-import](https://babeljs.io/docs/plugins/syntax-dynamic-import/) plugin before this one.
## Installation
```sh
npm install --save-dev @babel/plugin-transform-modules-systemjs
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
Without options:
```json
{
"plugins": ["@babel/transform-modules-systemjs"]
}
```
With options:
```json
{
"plugins": [
["@babel/transform-modules-systemjs", {
// outputs SystemJS.register(...)
"systemGlobal": "SystemJS"
}]
]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-modules-systemjs script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-systemjs"]
});
```

View File

@@ -0,0 +1,22 @@
{
"name": "@babel/plugin-transform-modules-systemjs",
"version": "7.0.0-beta.3",
"description": "This plugin transforms ES2015 modules to SystemJS",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-systemjs",
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-hoist-variables": "7.0.0-beta.3",
"@babel/template": "7.0.0-beta.3"
},
"keywords": [
"babel-plugin"
],
"peerDependencies": {
"@babel/core": "7.0.0-beta.3"
},
"devDependencies": {
"@babel/helper-plugin-test-runner": "7.0.0-beta.3",
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.3"
}
}

View File

@@ -0,0 +1,379 @@
import hoistVariables from "@babel/helper-hoist-variables";
import template from "@babel/template";
const buildTemplate = template(`
SYSTEM_REGISTER(MODULE_NAME, SOURCES, function (EXPORT_IDENTIFIER, CONTEXT_IDENTIFIER) {
"use strict";
BEFORE_BODY;
return {
setters: SETTERS,
execute: function () {
BODY;
}
};
});
`);
const buildExportAll = template(`
for (var KEY in TARGET) {
if (KEY !== "default" && KEY !== "__esModule") EXPORT_OBJ[KEY] = TARGET[KEY];
}
`);
const TYPE_IMPORT = "Import";
export default function({ types: t }, options) {
const { systemGlobal = "System" } = options;
const IGNORE_REASSIGNMENT_SYMBOL = Symbol();
const reassignmentVisitor = {
"AssignmentExpression|UpdateExpression"(path) {
if (path.node[IGNORE_REASSIGNMENT_SYMBOL]) return;
path.node[IGNORE_REASSIGNMENT_SYMBOL] = true;
const arg = path.get(path.isAssignmentExpression() ? "left" : "argument");
if (!arg.isIdentifier()) return;
const name = arg.node.name;
// redeclared in this scope
if (this.scope.getBinding(name) !== path.scope.getBinding(name)) return;
const exportedNames = this.exports[name];
if (!exportedNames) return;
let node = path.node;
// if it is a non-prefix update expression (x++ etc)
// then we must replace with the expression (_export('x', x + 1), x++)
// in order to ensure the same update expression value
let isPostUpdateExpression = path.isUpdateExpression() && !node.prefix;
if (isPostUpdateExpression) {
if (node.operator === "++") {
node = t.binaryExpression("+", node.argument, t.numericLiteral(1));
} else if (node.operator === "--") {
node = t.binaryExpression("-", node.argument, t.numericLiteral(1));
} else {
isPostUpdateExpression = false;
}
}
for (const exportedName of exportedNames) {
node = this.buildCall(exportedName, node).expression;
}
if (isPostUpdateExpression) {
node = t.sequenceExpression([node, path.node]);
}
path.replaceWith(node);
},
};
return {
visitor: {
CallExpression(path, state) {
if (path.node.callee.type === TYPE_IMPORT) {
const contextIdent = state.contextIdent;
path.replaceWith(
t.callExpression(
t.memberExpression(contextIdent, t.identifier("import")),
path.node.arguments,
),
);
}
},
ReferencedIdentifier(path, state) {
if (
path.node.name == "__moduleName" &&
!path.scope.hasBinding("__moduleName")
) {
path.replaceWith(
t.memberExpression(state.contextIdent, t.identifier("id")),
);
}
},
Program: {
enter(path, state) {
state.contextIdent = path.scope.generateUidIdentifier("context");
},
exit(path, state) {
const exportIdent = path.scope.generateUidIdentifier("export");
const contextIdent = state.contextIdent;
const exportNames = Object.create(null);
const modules = [];
let beforeBody = [];
const setters = [];
const sources = [];
const variableIds = [];
const removedPaths = [];
function addExportName(key, val) {
exportNames[key] = exportNames[key] || [];
exportNames[key].push(val);
}
function pushModule(source, key, specifiers) {
let module;
modules.forEach(function(m) {
if (m.key === source) {
module = m;
}
});
if (!module) {
modules.push(
(module = { key: source, imports: [], exports: [] }),
);
}
module[key] = module[key].concat(specifiers);
}
function buildExportCall(name, val) {
return t.expressionStatement(
t.callExpression(exportIdent, [t.stringLiteral(name), val]),
);
}
const body: Array<Object> = path.get("body");
let canHoist = true;
for (let path of body) {
if (path.isExportDeclaration()) path = path.get("declaration");
if (path.isVariableDeclaration() && path.node.kind !== "var") {
canHoist = false;
break;
}
}
for (const path of body) {
if (canHoist && path.isFunctionDeclaration()) {
beforeBody.push(path.node);
removedPaths.push(path);
} else if (path.isImportDeclaration()) {
const source = path.node.source.value;
pushModule(source, "imports", path.node.specifiers);
for (const name in path.getBindingIdentifiers()) {
path.scope.removeBinding(name);
variableIds.push(t.identifier(name));
}
path.remove();
} else if (path.isExportAllDeclaration()) {
pushModule(path.node.source.value, "exports", path.node);
path.remove();
} else if (path.isExportDefaultDeclaration()) {
const declar = path.get("declaration");
if (
declar.isClassDeclaration() ||
declar.isFunctionDeclaration()
) {
const id = declar.node.id;
const nodes = [];
if (id) {
nodes.push(declar.node);
nodes.push(buildExportCall("default", id));
addExportName(id.name, "default");
} else {
nodes.push(
buildExportCall("default", t.toExpression(declar.node)),
);
}
if (!canHoist || declar.isClassDeclaration()) {
path.replaceWithMultiple(nodes);
} else {
beforeBody = beforeBody.concat(nodes);
removedPaths.push(path);
}
} else {
path.replaceWith(buildExportCall("default", declar.node));
}
} else if (path.isExportNamedDeclaration()) {
const declar = path.get("declaration");
if (declar.node) {
path.replaceWith(declar);
const nodes = [];
let bindingIdentifiers;
if (path.isFunction()) {
const node = declar.node;
const name = node.id.name;
if (canHoist) {
addExportName(name, name);
beforeBody.push(node);
beforeBody.push(buildExportCall(name, node.id));
removedPaths.push(path);
} else {
bindingIdentifiers = { [name]: node.id };
}
} else {
bindingIdentifiers = declar.getBindingIdentifiers();
}
for (const name in bindingIdentifiers) {
addExportName(name, name);
nodes.push(buildExportCall(name, t.identifier(name)));
}
path.insertAfter(nodes);
} else {
const specifiers = path.node.specifiers;
if (specifiers && specifiers.length) {
if (path.node.source) {
pushModule(path.node.source.value, "exports", specifiers);
path.remove();
} else {
const nodes = [];
for (const specifier of specifiers) {
nodes.push(
buildExportCall(
specifier.exported.name,
specifier.local,
),
);
addExportName(
specifier.local.name,
specifier.exported.name,
);
}
path.replaceWithMultiple(nodes);
}
}
}
}
}
modules.forEach(function(specifiers) {
const setterBody = [];
const target = path.scope.generateUidIdentifier(specifiers.key);
for (let specifier of specifiers.imports) {
if (t.isImportNamespaceSpecifier(specifier)) {
setterBody.push(
t.expressionStatement(
t.assignmentExpression("=", specifier.local, target),
),
);
} else if (t.isImportDefaultSpecifier(specifier)) {
specifier = t.importSpecifier(
specifier.local,
t.identifier("default"),
);
}
if (t.isImportSpecifier(specifier)) {
setterBody.push(
t.expressionStatement(
t.assignmentExpression(
"=",
specifier.local,
t.memberExpression(target, specifier.imported),
),
),
);
}
}
if (specifiers.exports.length) {
const exportObjRef = path.scope.generateUidIdentifier(
"exportObj",
);
setterBody.push(
t.variableDeclaration("var", [
t.variableDeclarator(exportObjRef, t.objectExpression([])),
]),
);
for (const node of specifiers.exports) {
if (t.isExportAllDeclaration(node)) {
setterBody.push(
buildExportAll({
KEY: path.scope.generateUidIdentifier("key"),
EXPORT_OBJ: exportObjRef,
TARGET: target,
}),
);
} else if (t.isExportSpecifier(node)) {
setterBody.push(
t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(exportObjRef, node.exported),
t.memberExpression(target, node.local),
),
),
);
} else {
// todo
}
}
setterBody.push(
t.expressionStatement(
t.callExpression(exportIdent, [exportObjRef]),
),
);
}
sources.push(t.stringLiteral(specifiers.key));
setters.push(
t.functionExpression(
null,
[target],
t.blockStatement(setterBody),
),
);
});
let moduleName = this.getModuleName();
if (moduleName) moduleName = t.stringLiteral(moduleName);
if (canHoist) {
hoistVariables(path, id => variableIds.push(id));
}
if (variableIds.length) {
beforeBody.unshift(
t.variableDeclaration(
"var",
variableIds.map(id => t.variableDeclarator(id)),
),
);
}
path.traverse(reassignmentVisitor, {
exports: exportNames,
buildCall: buildExportCall,
scope: path.scope,
});
for (const path of removedPaths) {
path.remove();
}
path.node.body = [
buildTemplate({
SYSTEM_REGISTER: t.memberExpression(
t.identifier(systemGlobal),
t.identifier("register"),
),
BEFORE_BODY: beforeBody,
MODULE_NAME: moduleName,
SETTERS: t.arrayExpression(setters),
SOURCES: t.arrayExpression(sources),
BODY: path.node.body,
EXPORT_IDENTIFIER: exportIdent,
CONTEXT_IDENTIFIER: contextIdent,
}),
];
},
},
},
};
}

View File

@@ -0,0 +1,6 @@
export function lazyLoadOperation () {
return import('./x')
.then(function (x) {
x.y();
});
}

View File

@@ -0,0 +1,16 @@
System.register([], function (_export, _context) {
"use strict";
function lazyLoadOperation() {
return _context.import('./x').then(function (x) {
x.y();
});
}
_export("lazyLoadOperation", lazyLoadOperation);
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "syntax-dynamic-import", "transform-modules-systemjs"]
}

View File

@@ -0,0 +1,14 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const [foo, bar = 2] = [];
_export("foo", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1 @@
export const [foo, bar, ...baz] = [];

View File

@@ -0,0 +1,16 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const [foo, bar, ...baz] = [];
_export("foo", foo);
_export("bar", bar);
_export("baz", baz);
}
};
});

View File

@@ -0,0 +1 @@
export const [foo, bar] = [];

View File

@@ -0,0 +1,14 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const [foo, bar] = [];
_export("foo", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1 @@
export const { foo: { bar: [baz, qux] } } = {};

View File

@@ -0,0 +1,18 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const {
foo: {
bar: [baz, qux]
}
} = {};
_export("baz", baz);
_export("qux", qux);
}
};
});

View File

@@ -0,0 +1,17 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const {
foo,
bar = 1
} = {};
_export("foo", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1 @@
export const { foo, ...bar } = {};

View File

@@ -0,0 +1,17 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const {
foo,
...bar
} = {};
_export("foo", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-modules-systemjs", "syntax-object-rest-spread"]
}

View File

@@ -0,0 +1 @@
export const { foo: bar, baz } = {};

View File

@@ -0,0 +1,17 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
const {
foo: bar,
baz
} = {};
_export("bar", bar);
_export("baz", baz);
}
};
});

View File

@@ -0,0 +1 @@
export default {};

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", {});
}
};
});

View File

@@ -0,0 +1 @@
export default [];

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", []);
}
};
});

View File

@@ -0,0 +1 @@
export default foo;

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", foo);
}
};
});

View File

@@ -0,0 +1 @@
export default function () {}

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
_export("default", function () {});
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export default class {}

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
_export("default", class {});
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export default function foo () {}

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
function foo() {}
_export("default", foo);
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export default class Foo {}

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
class Foo {}
_export("default", Foo);
}
};
});

View File

@@ -0,0 +1 @@
export default (function(){return "foo"})();

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", function () {
return "foo";
}());
}
};
});

View File

@@ -0,0 +1 @@
export default 42;

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", 42);
}
};
});

View File

@@ -0,0 +1 @@
export {foo} from "foo";

View File

@@ -0,0 +1,13 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
_exportObj.foo = _foo.foo;
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo, bar} from "foo";

View File

@@ -0,0 +1,14 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
_exportObj.foo = _foo.foo;
_exportObj.bar = _foo.bar;
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo as bar} from "foo";

View File

@@ -0,0 +1,13 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
_exportObj.bar = _foo.foo;
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo as default} from "foo";

View File

@@ -0,0 +1,13 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
_exportObj.default = _foo.foo;
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo as default, bar} from "foo";

View File

@@ -0,0 +1,14 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
_exportObj.default = _foo.foo;
_exportObj.bar = _foo.bar;
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export * from "foo";

View File

@@ -0,0 +1,16 @@
System.register(["foo"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {
var _exportObj = {};
for (var _key in _foo) {
if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _foo[_key];
}
_export(_exportObj);
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo, bar};

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("foo", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1 @@
export {foo as bar};

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("bar", foo);
}
};
});

View File

@@ -0,0 +1 @@
export {foo as default};

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", foo);
}
};
});

View File

@@ -0,0 +1 @@
export {foo as default, bar};

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("default", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1 @@
export function foo() {}

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
function foo() {}
_export("foo", foo);
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export function foo2(bar) {}

View File

@@ -0,0 +1,12 @@
System.register([], function (_export, _context) {
"use strict";
function foo2(bar) {}
_export("foo2", foo2);
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export {foo};

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
_export("foo", foo);
}
};
});

View File

@@ -0,0 +1,9 @@
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7 () {}
export class foo8 {}
foo3 = 5;

View File

@@ -0,0 +1,42 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
var foo = 1;
_export("foo", foo);
var foo2 = function () {};
_export("foo2", foo2);
var foo3;
_export("foo3", foo3);
let foo4 = 2;
_export("foo4", foo4);
let foo5;
_export("foo5", foo5);
const foo6 = 3;
_export("foo6", foo6);
function foo7() {}
_export("foo7", foo7);
class foo8 {}
_export("foo8", foo8);
_export("foo3", foo3 = 5);
}
};
});

View File

@@ -0,0 +1,8 @@
System.register("my custom module name", [], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {}
};
});

View File

@@ -0,0 +1,4 @@
{
"moduleIds": true,
"moduleId": "my custom module name"
}

View File

@@ -0,0 +1,17 @@
import { isEven } from "./evens";
export function nextOdd(n) {
return p = isEven(n) ? n + 1 : n + 2;
}
export var p = 5;
for (var a in b) ;
for (var i = 0, j = 0;;) ;
export var isOdd = (function (isEven) {
return function (n) {
return !isEven(n);
};
})(isEven);

View File

@@ -0,0 +1,34 @@
System.register(["./evens"], function (_export, _context) {
"use strict";
var isEven, p, a, i, j, isOdd;
function nextOdd(n) {
return _export("p", p = isEven(n) ? n + 1 : n + 2);
}
_export("nextOdd", nextOdd);
return {
setters: [function (_evens) {
isEven = _evens.isEven;
}],
execute: function () {
_export("p", p = 5);
_export("p", p);
for (a in b);
for (i = 0, j = 0;;);
_export("isOdd", isOdd = function (isEven) {
return function (n) {
return !isEven(n);
};
}(isEven));
_export("isOdd", isOdd);
}
};
});

View File

@@ -0,0 +1,12 @@
export function a() {
alert("a");
c++;
}
export var c = 5;
function b() {
a();
}
b();

View File

@@ -0,0 +1,27 @@
System.register([], function (_export, _context) {
"use strict";
var c;
function a() {
alert("a");
_export("c", c + 1), c++;
}
_export("a", a);
function b() {
a();
}
return {
setters: [],
execute: function () {
_export("c", c = 5);
_export("c", c);
b();
}
};
});

View File

@@ -0,0 +1,2 @@
import foo from "foo";
import {default as foo2} from "foo";

View File

@@ -0,0 +1,12 @@
System.register(["foo"], function (_export, _context) {
"use strict";
var foo, foo2;
return {
setters: [function (_foo) {
foo = _foo.default;
foo2 = _foo.default;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
import * as foo from "foo";

View File

@@ -0,0 +1,11 @@
System.register(["foo"], function (_export, _context) {
"use strict";
var foo;
return {
setters: [function (_foo) {
foo = _foo;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
import foo, {baz as xyz} from "foo";

View File

@@ -0,0 +1,12 @@
System.register(["foo"], function (_export, _context) {
"use strict";
var foo, xyz;
return {
setters: [function (_foo) {
foo = _foo.default;
xyz = _foo.baz;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1,4 @@
import {bar} from "foo";
import {bar2, baz} from "foo";
import {bar as baz2} from "foo";
import {bar as baz3, xyz} from "foo";

View File

@@ -0,0 +1,16 @@
System.register(["foo"], function (_export, _context) {
"use strict";
var bar, bar2, baz, baz2, baz3, xyz;
return {
setters: [function (_foo) {
bar = _foo.bar;
bar2 = _foo.bar2;
baz = _foo.baz;
baz2 = _foo.bar;
baz3 = _foo.bar;
xyz = _foo.xyz;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1,2 @@
import "2";
import "1";

View File

@@ -0,0 +1,8 @@
System.register(["2", "1"], function (_export, _context) {
"use strict";
return {
setters: [function (_) {}, function (_2) {}],
execute: function () {}
};
});

View File

@@ -0,0 +1,3 @@
import "foo";
import "foo-bar";
import "./directory/foo-bar";

View File

@@ -0,0 +1,8 @@
System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export, _context) {
"use strict";
return {
setters: [function (_foo) {}, function (_fooBar) {}, function (_directoryFooBar) {}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
export var name = __moduleName;

View File

@@ -0,0 +1,13 @@
System.register([], function (_export, _context) {
"use strict";
var name;
return {
setters: [],
execute: function () {
_export("name", name = _context.id);
_export("name", name);
}
};
});

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-modules-systemjs"]
}

View File

@@ -0,0 +1,12 @@
import "foo";
import "foo-bar";
import "./directory/foo-bar";
import foo from "foo";
import * as foo2 from "foo";
import {bar} from "foo";
import {foo as bar2} from "foo";
export {test};
export var test2 = 5;
export default test;

View File

@@ -0,0 +1,22 @@
System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export, _context) {
"use strict";
var foo, foo2, bar, bar2, test2;
return {
setters: [function (_foo) {
foo = _foo.default;
foo2 = _foo;
bar = _foo.bar;
bar2 = _foo.foo;
}, function (_fooBar) {}, function (_directoryFooBar) {}],
execute: function () {
_export("test", test);
_export("test2", test2 = 5);
_export("test2", test2);
_export("default", test);
}
};
});

View File

@@ -0,0 +1,21 @@
export var test = 2;
test = 5;
test++;
(function () {
var test = 2;
test = 3;
test++;
})();
var a = 2;
export { a };
a = 3;
var b = 2;
export { b as c };
b = 3;
var d = 3;
export { d as e, d as f };
d = 4;

View File

@@ -0,0 +1,43 @@
System.register([], function (_export, _context) {
"use strict";
var test, a, b, d;
return {
setters: [],
execute: function () {
_export("test", test = 2);
_export("test", test);
_export("test", test = 5);
_export("test", test + 1), test++;
(function () {
var test = 2;
test = 3;
test++;
})();
_export("a", a = 2);
_export("a", a);
_export("a", a = 3);
_export("c", b = 2);
_export("c", b);
_export("c", b = 3);
_export("f", _export("e", d = 3));
_export("e", d);
_export("f", d);
_export("f", _export("e", d = 4));
}
};
});

View File

@@ -0,0 +1,3 @@
import runner from "@babel/helper-plugin-test-runner";
runner(__dirname);