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,132 @@
# @babel/plugin-transform-modules-commonjs
> This plugin transforms ES2015 modules to [CommonJS](http://wiki.commonjs.org/wiki/Modules/1.1).
## Example
**In**
```javascript
export default 42;
```
**Out**
```javascript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = 42;
```
## Installation
```sh
npm install --save-dev @babel/plugin-transform-modules-commonjs
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```js
// without options
{
"plugins": ["@babel/transform-modules-commonjs"]
}
// with options
{
"plugins": [
["@babel/transform-modules-commonjs", {
"allowTopLevelThis": true
}]
]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-modules-commonjs script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-commonjs"]
});
```
## Options
### `loose`
`boolean`, defaults to `false`.
As per the spec, `import` and `export` are only allowed to be used at the top
level. When in loose mode these are allowed to be used anywhere.
And by default, when using exports with babel a non-enumerable `__esModule` property
is exported.
```javascript
var foo = exports.foo = 5;
Object.defineProperty(exports, "__esModule", {
value: true
});
```
In environments that don't support this you can enable loose mode on `babel-plugin-transform-modules-commonjs`
and instead of using `Object.defineProperty` an assignment will be used instead.
```javascript
var foo = exports.foo = 5;
exports.__esModule = true;
```
### `strict`
`boolean`, defaults to `false`
By default, when using exports with babel a non-enumerable `__esModule` property
is exported. In some cases this property is used to determine if the import _is_ the
default export or if it _contains_ the default export.
```javascript
var foo = exports.foo = 5;
Object.defineProperty(exports, "__esModule", {
value: true
});
```
In order to prevent the `__esModule` property from being exported, you can set
the `strict` option to `true`.
### `noInterop`
`boolean`, defaults to `false`
By default, when using exports with babel a non-enumerable `__esModule` property
is exported. This property is then used to determine if the import _is_ the default
export or if it _contains_ the default export.
```javascript
"use strict";
var _foo = _interopRequireDefault(require("foo"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
```
In cases where the auto-unwrapping of `default` is not needed, you can set the
`noInterop` option to `true` to avoid the usage of the `interopRequireDefault`
helper (shown in inline form above).

View File

@@ -0,0 +1,21 @@
{
"name": "@babel/plugin-transform-modules-commonjs",
"version": "7.0.0-beta.3",
"description": "This plugin transforms ES2015 modules to CommonJS",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-commonjs",
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"@babel/helper-module-transforms": "7.0.0-beta.3",
"@babel/helper-simple-access": "7.0.0-beta.3",
"@babel/types": "7.0.0-beta.3"
},
"keywords": [
"babel-plugin"
],
"devDependencies": {
"@babel/core": "7.0.0-beta.3",
"@babel/helper-plugin-test-runner": "7.0.0-beta.3",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.3"
}
}

View File

@@ -0,0 +1,156 @@
import {
isModule,
rewriteModuleStatementsAndPrepareHeader,
isSideEffectImport,
buildNamespaceInitStatements,
ensureStatementsHoisted,
wrapInterop,
} from "@babel/helper-module-transforms";
import simplifyAccess from "@babel/helper-simple-access";
export default function({ types: t, template }, options) {
const {
loose,
allowTopLevelThis,
strict,
strictMode,
noInterop,
// Defaulting to 'true' for now. May change before 7.x major.
allowCommonJSExports = true,
} = options;
const getAssertion = localName => template.expression.ast`
(function(){
throw new Error("The CommonJS '" + "${localName}" + "' variable is not available in ES6 modules.");
})()
`;
const moduleExportsVisitor = {
ReferencedIdentifier(path) {
const localName = path.node.name;
if (localName !== "module" && localName !== "exports") return;
const localBinding = path.scope.getBinding(localName);
const rootBinding = this.scope.getBinding(localName);
if (
// redeclared in this scope
rootBinding !== localBinding ||
(path.parentPath.isObjectProperty({ value: path.node }) &&
path.parentPath.parentPath.isObjectPattern()) ||
path.parentPath.isAssignmentExpression({ left: path.node }) ||
path.isAssignmentExpression({ left: path.node })
) {
return;
}
path.replaceWith(getAssertion(localName));
},
AssignmentExpression(path) {
const left = path.get("left");
if (left.isIdentifier()) {
const localName = path.node.name;
if (localName !== "module" && localName !== "exports") return;
const localBinding = path.scope.getBinding(localName);
const rootBinding = this.scope.getBinding(localName);
// redeclared in this scope
if (rootBinding !== localBinding) return;
const right = path.get("right");
right.replaceWith(
t.sequenceExpression([right.node, getAssertion(localName)]),
);
} else if (left.isPattern()) {
const ids = left.getOuterBindingIdentifiers();
const localName = Object.keys(ids).filter(localName => {
if (localName !== "module" && localName !== "exports") return false;
return (
this.scope.getBinding(localName) ===
path.scope.getBinding(localName)
);
})[0];
if (localName) {
const right = path.get("right");
right.replaceWith(
t.sequenceExpression([right.node, getAssertion(localName)]),
);
}
}
},
};
return {
visitor: {
Program: {
exit(path) {
// For now this requires unambiguous rather that just sourceType
// because Babel currently parses all files as sourceType:module.
if (!isModule(path, true /* requireUnambiguous */)) return;
// Rename the bindings auto-injected into the scope so there is no
// risk of conflict between the bindings.
path.scope.rename("exports");
path.scope.rename("module");
path.scope.rename("require");
path.scope.rename("__filename");
path.scope.rename("__dirname");
// Rewrite references to 'module' and 'exports' to throw exceptions.
// These objects are specific to CommonJS and are not available in
// real ES6 implementations.
if (!allowCommonJSExports) {
simplifyAccess(path, new Set(["module", "exports"]));
path.traverse(moduleExportsVisitor, {
scope: path.scope,
});
}
let moduleName = this.getModuleName();
if (moduleName) moduleName = t.stringLiteral(moduleName);
const {
meta,
headers,
} = rewriteModuleStatementsAndPrepareHeader(path, {
exportName: "exports",
loose,
strict,
strictMode,
allowTopLevelThis,
noInterop,
});
for (const [source, metadata] of meta.source) {
const loadExpr = t.callExpression(t.identifier("require"), [
t.stringLiteral(source),
]);
let header;
if (isSideEffectImport(metadata)) {
header = t.expressionStatement(loadExpr);
} else {
header = t.variableDeclaration("var", [
t.variableDeclarator(
t.identifier(metadata.name),
wrapInterop(path, loadExpr, metadata.interop) || loadExpr,
),
]);
}
header.loc = metadata.loc;
headers.push(header);
headers.push(...buildNamespaceInitStatements(meta, metadata));
}
ensureStatementsHoisted(headers);
path.unshiftContainer("body", headers);
},
},
},
};
}

View File

@@ -0,0 +1,33 @@
const assert = require("assert");
const babel = require("@babel/core");
test("Doesn't use the same object for two different nodes in the AST", function() {
const code = 'import Foo from "bar"; Foo; Foo;';
const ast = babel.transform(code, {
plugins: [[require("../"), { loose: true }]],
}).ast;
assert.equal(ast.program.body[0].declarations[0].id.type, "Identifier");
assert.equal(ast.program.body[2].expression.type, "MemberExpression");
assert.equal(ast.program.body[2].expression.object.type, "Identifier");
assert.equal(ast.program.body[3].expression.type, "MemberExpression");
assert.equal(ast.program.body[3].expression.object.type, "Identifier");
assert.notStrictEqual(
ast.program.body[2].expression.object,
ast.program.body[3].expression.object,
"Expected different nodes in the AST to not be the same object (one)",
);
assert.notStrictEqual(
ast.program.body[0].declarations[0].id,
ast.program.body[3].expression.object,
"Expected different nodes in the AST to not be the same object (two)",
);
assert.notStrictEqual(
ast.program.body[0].declarations[0].id,
ast.program.body[2].expression.object,
"Expected different nodes in the AST to not be the same object (three)",
);
});

View File

@@ -0,0 +1,35 @@
const assert = require("assert");
const babel = require("@babel/core");
const vm = require("vm");
test("Re-export doesn't overwrite __esModule flag", function() {
let code = 'export * from "./dep";';
const depStub = {
__esModule: false,
};
const context = {
module: {
exports: {},
},
require: function(id) {
if (id === "./dep") return depStub;
return require(id);
},
};
context.exports = context.module.exports;
code = babel.transform(code, {
plugins: [[require("../"), { loose: true }]],
ast: false,
}).code;
vm.runInNewContext(code, context);
// exports.__esModule shouldn't be overwritten.
assert.equal(
context.exports.__esModule,
true,
"Expected exports.__esModule === true",
);
});

View File

@@ -0,0 +1,5 @@
{
"plugins": ["external-helpers", "transform-modules-commonjs"],
"auxiliaryCommentBefore": "before",
"auxiliaryCommentAfter": "after"
}

View File

@@ -0,0 +1,17 @@
import "foo";
import "foo-bar";
import "./directory/foo-bar";
import foo from "foo2";
import * as foo2 from "foo3";
import {bar} from "foo4";
import {foo as bar2} from "foo5";
var test;
export {test};
export var test2 = 5;
bar(foo, bar2);
/* my comment */
bar2;
foo;

View File

@@ -0,0 +1,85 @@
/*before*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test2 = exports.test = void 0;
/*after*/
/*before*/
require("foo")
/*after*/
;
/*before*/
require("foo-bar")
/*after*/
;
/*before*/
require("./directory/foo-bar")
/*after*/
;
var
/*before*/
_foo2 = babelHelpers.interopRequireDefault(require("foo2"))
/*after*/
;
var
/*before*/
foo2 = babelHelpers.interopRequireWildcard(require("foo3"))
/*after*/
;
var
/*before*/
_foo4 = require("foo4")
/*after*/
;
var
/*before*/
_foo5 = require("foo5")
/*after*/
;
var test;
/*before*/
exports.test = test;
/*after*/
var test2 = 5;
/*before*/
exports.test2 = test2;
/*after*/
/*before*/
(0, _foo4.bar)
/*after*/
(
/*before*/
_foo2.default
/*after*/
,
/*before*/
_foo5.foo
/*after*/
);
/* my comment */
/*before*/
_foo5.foo
/*after*/
;
/*before*/
_foo2.default
/*after*/
;

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
require("foo");
require("foo-bar");
require("./directory/foo-bar");

View File

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

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function () {
return "foo";
}();
exports.default = _default;

View File

@@ -0,0 +1,3 @@
export default new Cachier()
export function Cachier(databaseName) {}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Cachier = Cachier;
exports.default = void 0;
var _default = new Cachier();
exports.default = _default;
function Cachier(databaseName) {}

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {};
exports.default = _default;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = [];
exports.default = _default;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = foo;
exports.default = _default;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default() {}

View File

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

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class _default {}
exports.default = _default;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = foo;
function foo() {}

View File

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

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class Foo {}
exports.default = Foo;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var foo;
exports.default = foo;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = 42;
exports.default = _default;

View File

@@ -0,0 +1,18 @@
export let x = 0;
export let y = 0;
export function f1 () {
({x} = { x: 1 });
}
export function f2 () {
({x, y} = { x: 2, y: 3 });
}
export function f3 () {
[x, y, z] = [3, 4, 5]
}
export function f4 () {
[x, , y] = [3, 4, 5]
}

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.f1 = f1;
exports.f2 = f2;
exports.f3 = f3;
exports.f4 = f4;
exports.y = exports.x = void 0;
let x = 0;
exports.x = x;
let y = 0;
exports.y = y;
function f1() {
({
x
} = {
x: 1
});
exports.x = x;
}
function f2() {
({
x,
y
} = {
x: 2,
y: 3
});
exports.x = x, exports.y = y;
}
function f3() {
[x, y, z] = [3, 4, 5];
exports.x = x, exports.y = y;
}
function f4() {
[x,, y] = [3, 4, 5];
exports.x = x, exports.y = y;
}

View File

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

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "foo", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "foo", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
Object.defineProperty(exports, "bar", {
enumerable: true,
get: function () {
return _foo.bar;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "bar", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
Object.defineProperty(exports, "bar", {
enumerable: true,
get: function () {
return _foo.bar;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "foo", {
enumerable: true,
get: function () {
return _foo.default;
}
});
var _foo = babelHelpers.interopRequireDefault(require("foo"));

View File

@@ -0,0 +1,2 @@
import { foo, foo1, foo2, foo3, foo4, foo5, foo6, foo7, foo8, foo9, foo10, foo11, foo12, foo13, foo14, foo15, foo16, foo17, foo18, foo19, foo20, foo21, foo22, foo23, foo24, foo25, foo26, foo27, foo28, foo29, foo30, foo31, foo32, foo33, foo34, foo35, foo36, foo37, foo38, foo39, foo40, foo41, foo42, foo43, foo44, foo45, foo46, foo47, foo48, foo49, foo50, foo51, foo52, foo53, foo54, foo55, foo56, foo57, foo58, foo59, foo60, foo61, foo62, foo63, foo64, foo65, foo66, foo67, foo68, foo69, foo70, foo71, foo72, foo73, foo74, foo75, foo76, foo77, foo78, foo79, foo80, foo81, foo82, foo83, foo84, foo85, foo86, foo87, foo88, foo89, foo90, foo91, foo92, foo93, foo94, foo95, foo96, foo97, foo98, foo99, foo100 } from "foo";
export { foo, foo1, foo2, foo3, foo4, foo5, foo6, foo7, foo8, foo9, foo10, foo11, foo12, foo13, foo14, foo15, foo16, foo17, foo18, foo19, foo20, foo21, foo22, foo23, foo24, foo25, foo26, foo27, foo28, foo29, foo30, foo31, foo32, foo33, foo34, foo35, foo36, foo37, foo38, foo39, foo40, foo41, foo42, foo43, foo44, foo45, foo46, foo47, foo48, foo49, foo50, foo51, foo52, foo53, foo54, foo55, foo56, foo57, foo58, foo59, foo60, foo61, foo62, foo63, foo64, foo65, foo66, foo67, foo68, foo69, foo70, foo71, foo72, foo73, foo74, foo75, foo76, foo77, foo78, foo79, foo80, foo81, foo82, foo83, foo84, foo85, foo86, foo87, foo88, foo89, foo90, foo91, foo92, foo93, foo94, foo95, foo96, foo97, foo98, foo99, foo100 }

View File

@@ -0,0 +1,613 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "foo", {
enumerable: true,
get: function () {
return _foo.foo;
}
});
Object.defineProperty(exports, "foo1", {
enumerable: true,
get: function () {
return _foo.foo1;
}
});
Object.defineProperty(exports, "foo2", {
enumerable: true,
get: function () {
return _foo.foo2;
}
});
Object.defineProperty(exports, "foo3", {
enumerable: true,
get: function () {
return _foo.foo3;
}
});
Object.defineProperty(exports, "foo4", {
enumerable: true,
get: function () {
return _foo.foo4;
}
});
Object.defineProperty(exports, "foo5", {
enumerable: true,
get: function () {
return _foo.foo5;
}
});
Object.defineProperty(exports, "foo6", {
enumerable: true,
get: function () {
return _foo.foo6;
}
});
Object.defineProperty(exports, "foo7", {
enumerable: true,
get: function () {
return _foo.foo7;
}
});
Object.defineProperty(exports, "foo8", {
enumerable: true,
get: function () {
return _foo.foo8;
}
});
Object.defineProperty(exports, "foo9", {
enumerable: true,
get: function () {
return _foo.foo9;
}
});
Object.defineProperty(exports, "foo10", {
enumerable: true,
get: function () {
return _foo.foo10;
}
});
Object.defineProperty(exports, "foo11", {
enumerable: true,
get: function () {
return _foo.foo11;
}
});
Object.defineProperty(exports, "foo12", {
enumerable: true,
get: function () {
return _foo.foo12;
}
});
Object.defineProperty(exports, "foo13", {
enumerable: true,
get: function () {
return _foo.foo13;
}
});
Object.defineProperty(exports, "foo14", {
enumerable: true,
get: function () {
return _foo.foo14;
}
});
Object.defineProperty(exports, "foo15", {
enumerable: true,
get: function () {
return _foo.foo15;
}
});
Object.defineProperty(exports, "foo16", {
enumerable: true,
get: function () {
return _foo.foo16;
}
});
Object.defineProperty(exports, "foo17", {
enumerable: true,
get: function () {
return _foo.foo17;
}
});
Object.defineProperty(exports, "foo18", {
enumerable: true,
get: function () {
return _foo.foo18;
}
});
Object.defineProperty(exports, "foo19", {
enumerable: true,
get: function () {
return _foo.foo19;
}
});
Object.defineProperty(exports, "foo20", {
enumerable: true,
get: function () {
return _foo.foo20;
}
});
Object.defineProperty(exports, "foo21", {
enumerable: true,
get: function () {
return _foo.foo21;
}
});
Object.defineProperty(exports, "foo22", {
enumerable: true,
get: function () {
return _foo.foo22;
}
});
Object.defineProperty(exports, "foo23", {
enumerable: true,
get: function () {
return _foo.foo23;
}
});
Object.defineProperty(exports, "foo24", {
enumerable: true,
get: function () {
return _foo.foo24;
}
});
Object.defineProperty(exports, "foo25", {
enumerable: true,
get: function () {
return _foo.foo25;
}
});
Object.defineProperty(exports, "foo26", {
enumerable: true,
get: function () {
return _foo.foo26;
}
});
Object.defineProperty(exports, "foo27", {
enumerable: true,
get: function () {
return _foo.foo27;
}
});
Object.defineProperty(exports, "foo28", {
enumerable: true,
get: function () {
return _foo.foo28;
}
});
Object.defineProperty(exports, "foo29", {
enumerable: true,
get: function () {
return _foo.foo29;
}
});
Object.defineProperty(exports, "foo30", {
enumerable: true,
get: function () {
return _foo.foo30;
}
});
Object.defineProperty(exports, "foo31", {
enumerable: true,
get: function () {
return _foo.foo31;
}
});
Object.defineProperty(exports, "foo32", {
enumerable: true,
get: function () {
return _foo.foo32;
}
});
Object.defineProperty(exports, "foo33", {
enumerable: true,
get: function () {
return _foo.foo33;
}
});
Object.defineProperty(exports, "foo34", {
enumerable: true,
get: function () {
return _foo.foo34;
}
});
Object.defineProperty(exports, "foo35", {
enumerable: true,
get: function () {
return _foo.foo35;
}
});
Object.defineProperty(exports, "foo36", {
enumerable: true,
get: function () {
return _foo.foo36;
}
});
Object.defineProperty(exports, "foo37", {
enumerable: true,
get: function () {
return _foo.foo37;
}
});
Object.defineProperty(exports, "foo38", {
enumerable: true,
get: function () {
return _foo.foo38;
}
});
Object.defineProperty(exports, "foo39", {
enumerable: true,
get: function () {
return _foo.foo39;
}
});
Object.defineProperty(exports, "foo40", {
enumerable: true,
get: function () {
return _foo.foo40;
}
});
Object.defineProperty(exports, "foo41", {
enumerable: true,
get: function () {
return _foo.foo41;
}
});
Object.defineProperty(exports, "foo42", {
enumerable: true,
get: function () {
return _foo.foo42;
}
});
Object.defineProperty(exports, "foo43", {
enumerable: true,
get: function () {
return _foo.foo43;
}
});
Object.defineProperty(exports, "foo44", {
enumerable: true,
get: function () {
return _foo.foo44;
}
});
Object.defineProperty(exports, "foo45", {
enumerable: true,
get: function () {
return _foo.foo45;
}
});
Object.defineProperty(exports, "foo46", {
enumerable: true,
get: function () {
return _foo.foo46;
}
});
Object.defineProperty(exports, "foo47", {
enumerable: true,
get: function () {
return _foo.foo47;
}
});
Object.defineProperty(exports, "foo48", {
enumerable: true,
get: function () {
return _foo.foo48;
}
});
Object.defineProperty(exports, "foo49", {
enumerable: true,
get: function () {
return _foo.foo49;
}
});
Object.defineProperty(exports, "foo50", {
enumerable: true,
get: function () {
return _foo.foo50;
}
});
Object.defineProperty(exports, "foo51", {
enumerable: true,
get: function () {
return _foo.foo51;
}
});
Object.defineProperty(exports, "foo52", {
enumerable: true,
get: function () {
return _foo.foo52;
}
});
Object.defineProperty(exports, "foo53", {
enumerable: true,
get: function () {
return _foo.foo53;
}
});
Object.defineProperty(exports, "foo54", {
enumerable: true,
get: function () {
return _foo.foo54;
}
});
Object.defineProperty(exports, "foo55", {
enumerable: true,
get: function () {
return _foo.foo55;
}
});
Object.defineProperty(exports, "foo56", {
enumerable: true,
get: function () {
return _foo.foo56;
}
});
Object.defineProperty(exports, "foo57", {
enumerable: true,
get: function () {
return _foo.foo57;
}
});
Object.defineProperty(exports, "foo58", {
enumerable: true,
get: function () {
return _foo.foo58;
}
});
Object.defineProperty(exports, "foo59", {
enumerable: true,
get: function () {
return _foo.foo59;
}
});
Object.defineProperty(exports, "foo60", {
enumerable: true,
get: function () {
return _foo.foo60;
}
});
Object.defineProperty(exports, "foo61", {
enumerable: true,
get: function () {
return _foo.foo61;
}
});
Object.defineProperty(exports, "foo62", {
enumerable: true,
get: function () {
return _foo.foo62;
}
});
Object.defineProperty(exports, "foo63", {
enumerable: true,
get: function () {
return _foo.foo63;
}
});
Object.defineProperty(exports, "foo64", {
enumerable: true,
get: function () {
return _foo.foo64;
}
});
Object.defineProperty(exports, "foo65", {
enumerable: true,
get: function () {
return _foo.foo65;
}
});
Object.defineProperty(exports, "foo66", {
enumerable: true,
get: function () {
return _foo.foo66;
}
});
Object.defineProperty(exports, "foo67", {
enumerable: true,
get: function () {
return _foo.foo67;
}
});
Object.defineProperty(exports, "foo68", {
enumerable: true,
get: function () {
return _foo.foo68;
}
});
Object.defineProperty(exports, "foo69", {
enumerable: true,
get: function () {
return _foo.foo69;
}
});
Object.defineProperty(exports, "foo70", {
enumerable: true,
get: function () {
return _foo.foo70;
}
});
Object.defineProperty(exports, "foo71", {
enumerable: true,
get: function () {
return _foo.foo71;
}
});
Object.defineProperty(exports, "foo72", {
enumerable: true,
get: function () {
return _foo.foo72;
}
});
Object.defineProperty(exports, "foo73", {
enumerable: true,
get: function () {
return _foo.foo73;
}
});
Object.defineProperty(exports, "foo74", {
enumerable: true,
get: function () {
return _foo.foo74;
}
});
Object.defineProperty(exports, "foo75", {
enumerable: true,
get: function () {
return _foo.foo75;
}
});
Object.defineProperty(exports, "foo76", {
enumerable: true,
get: function () {
return _foo.foo76;
}
});
Object.defineProperty(exports, "foo77", {
enumerable: true,
get: function () {
return _foo.foo77;
}
});
Object.defineProperty(exports, "foo78", {
enumerable: true,
get: function () {
return _foo.foo78;
}
});
Object.defineProperty(exports, "foo79", {
enumerable: true,
get: function () {
return _foo.foo79;
}
});
Object.defineProperty(exports, "foo80", {
enumerable: true,
get: function () {
return _foo.foo80;
}
});
Object.defineProperty(exports, "foo81", {
enumerable: true,
get: function () {
return _foo.foo81;
}
});
Object.defineProperty(exports, "foo82", {
enumerable: true,
get: function () {
return _foo.foo82;
}
});
Object.defineProperty(exports, "foo83", {
enumerable: true,
get: function () {
return _foo.foo83;
}
});
Object.defineProperty(exports, "foo84", {
enumerable: true,
get: function () {
return _foo.foo84;
}
});
Object.defineProperty(exports, "foo85", {
enumerable: true,
get: function () {
return _foo.foo85;
}
});
Object.defineProperty(exports, "foo86", {
enumerable: true,
get: function () {
return _foo.foo86;
}
});
Object.defineProperty(exports, "foo87", {
enumerable: true,
get: function () {
return _foo.foo87;
}
});
Object.defineProperty(exports, "foo88", {
enumerable: true,
get: function () {
return _foo.foo88;
}
});
Object.defineProperty(exports, "foo89", {
enumerable: true,
get: function () {
return _foo.foo89;
}
});
Object.defineProperty(exports, "foo90", {
enumerable: true,
get: function () {
return _foo.foo90;
}
});
Object.defineProperty(exports, "foo91", {
enumerable: true,
get: function () {
return _foo.foo91;
}
});
Object.defineProperty(exports, "foo92", {
enumerable: true,
get: function () {
return _foo.foo92;
}
});
Object.defineProperty(exports, "foo93", {
enumerable: true,
get: function () {
return _foo.foo93;
}
});
Object.defineProperty(exports, "foo94", {
enumerable: true,
get: function () {
return _foo.foo94;
}
});
Object.defineProperty(exports, "foo95", {
enumerable: true,
get: function () {
return _foo.foo95;
}
});
Object.defineProperty(exports, "foo96", {
enumerable: true,
get: function () {
return _foo.foo96;
}
});
Object.defineProperty(exports, "foo97", {
enumerable: true,
get: function () {
return _foo.foo97;
}
});
Object.defineProperty(exports, "foo98", {
enumerable: true,
get: function () {
return _foo.foo98;
}
});
Object.defineProperty(exports, "foo99", {
enumerable: true,
get: function () {
return _foo.foo99;
}
});
Object.defineProperty(exports, "foo100", {
enumerable: true,
get: function () {
return _foo.foo100;
}
});
var _foo = require("foo");

View File

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

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _foo = require("foo");
Object.keys(_foo).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _foo[key];
}
});
});

View File

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

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bar = exports.foo = void 0;
var foo, bar;
exports.bar = bar;
exports.foo = foo;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bar = void 0;
var foo;
exports.bar = foo;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var foo;
exports.default = foo;

View File

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

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bar = exports.default = void 0;
var foo, bar;
exports.bar = bar;
exports.default = foo;

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = void 0;
var foo;
exports.foo = foo;

View File

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

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo8 = foo8;
exports.foo9 = exports.foo7 = exports.foo6 = exports.foo5 = exports.foo4 = exports.foo3 = exports.bar = exports.foo2 = exports.foo = void 0;
var foo = 1;
exports.foo = foo;
var foo2 = 1,
bar = 2;
exports.bar = bar;
exports.foo2 = foo2;
var foo3 = function () {};
exports.foo3 = foo3;
var foo4;
exports.foo4 = foo4;
let foo5 = 2;
exports.foo5 = foo5;
let foo6;
exports.foo6 = foo6;
const foo7 = 3;
exports.foo7 = foo7;
function foo8() {}
class foo9 {}
exports.foo9 = foo9;

View File

@@ -0,0 +1,11 @@
import { isEven } from "./evens";
export function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
export var isOdd = (function (isEven) {
return function (n) {
return !isEven(n);
};
})(isEven);

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nextOdd = nextOdd;
exports.isOdd = void 0;
var _evens = require("./evens");
function nextOdd(n) {
return (0, _evens.isEven)(n) ? n + 1 : n + 2;
}
var isOdd = function (isEven) {
return function (n) {
return !isEven(n);
};
}(_evens.isEven);
exports.isOdd = isOdd;

View File

@@ -0,0 +1,2 @@
var __esModule;
export { __esModule };

View File

@@ -0,0 +1,4 @@
{
"throws": "Illegal export \"__esModule\"",
"plugins": ["transform-modules-commonjs"]
}

View File

@@ -0,0 +1 @@
export var __esModule = false;

View File

@@ -0,0 +1,4 @@
{
"throws": "Illegal export \"__esModule\"",
"plugins": ["transform-modules-commonjs"]
}

View File

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

View File

@@ -0,0 +1,6 @@
"use strict";
var _foo = babelHelpers.interopRequireDefault(require("foo"));
_foo.default;
_foo.default;

View File

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

View File

@@ -0,0 +1,3 @@
"use strict";
var foo = babelHelpers.interopRequireWildcard(require("foo"));

View File

@@ -0,0 +1,5 @@
var _taggedTemplateLiteral = require("@babel/runtime/helpers/taggedTemplateLiteral");
var _templateObject = /*#__PURE__*/ _taggedTemplateLiteral(["foo"], ["foo"]);
tag(_templateObject);

View File

@@ -0,0 +1,7 @@
{
"plugins": [
"transform-runtime",
"transform-template-literals",
"transform-modules-commonjs"
]
}

View File

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

View File

@@ -0,0 +1,6 @@
"use strict";
var _foo = babelHelpers.interopRequireWildcard(require("foo"));
_foo.default;
_foo.baz;

View File

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

View File

@@ -0,0 +1,10 @@
"use strict";
var _foo = require("foo");
_foo.bar;
_foo.bar2;
_foo.baz;
_foo.bar;
_foo.bar;
_foo.xyz;

View File

@@ -0,0 +1,4 @@
import './foo';
import bar from './bar';
import './derp';
import { qux } from './qux';

View File

@@ -0,0 +1,9 @@
"use strict";
require("./foo");
var _bar = babelHelpers.interopRequireDefault(require("./bar"));
require("./derp");
var _qux = require("./qux");

View File

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

View File

@@ -0,0 +1,7 @@
"use strict";
require("foo");
require("foo-bar");
require("./directory/foo-bar");

View File

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

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.module = _module;
function _module() {}

View File

@@ -0,0 +1,3 @@
export {};
console.log(helper);

View File

@@ -0,0 +1,7 @@
"use strict";
var _interopRequireDefault3 = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireDefault2 = _interopRequireDefault3(require("@babel/runtime/helpers/interopRequireDefault"));
console.log(_interopRequireDefault2.default);

View File

@@ -0,0 +1,7 @@
{
"plugins": [
"transform-modules-commonjs",
"transform-runtime",
"./plugin"
]
}

View File

@@ -0,0 +1,11 @@
module.exports = function() {
return {
visitor: {
Identifier: function(path) {
if (path.node.name !== "helper") return;
path.replaceWith(this.addHelper("interopRequireDefault"));
},
},
};
};

View File

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

View File

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

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test2 = exports.test = void 0;
require("foo");
require("foo-bar");
require("./directory/foo-bar");
var _foo2 = babelHelpers.interopRequireDefault(require("foo2"));
var foo2 = babelHelpers.interopRequireWildcard(require("foo3"));
var _foo4 = require("foo4");
var _foo5 = require("foo5");
var test;
exports.test = test;
var test2 = 5;
exports.test2 = test2;
_foo4.bar;
_foo5.foo;
_foo2.default;

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,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.f = exports.e = exports.c = exports.a = exports.test = void 0;
var test = 2;
exports.test = test;
exports.test = test = 5;
exports.test = test = test + 1;
(function () {
var test = 2;
test = 3;
test++;
})();
var a = 2;
exports.a = a;
exports.a = a = 3;
var b = 2;
exports.c = b;
exports.c = b = 3;
var d = 3;
exports.f = exports.e = d;
exports.f = exports.e = d = 4;

View File

@@ -0,0 +1,17 @@
import Foo from "foo";
import * as Bar from "bar";
import { Baz } from "baz";
Foo = 42;
Bar = 43;
Baz = 44;
({Foo} = {});
({Bar} = {});
({Baz} = {});
({prop: Foo} = {});
({prop: Bar} = {});
({prop: Baz} = {});

View File

@@ -0,0 +1,43 @@
"use strict";
var _foo = _interopRequireDefault(require("foo"));
var Bar = _interopRequireWildcard(require("bar"));
var _baz = require("baz");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_foo.default = (42, function () {
throw new Error('"' + "Foo" + '" is read-only.');
}());
Bar = (43, function () {
throw new Error('"' + "Bar" + '" is read-only.');
}());
_baz.Baz = (44, function () {
throw new Error('"' + "Baz" + '" is read-only.');
}());
({
Foo: _foo.default
} = {});
({
Bar
} = ({}, function () {
throw new Error('"' + "Bar" + '" is read-only.');
}()));
({
Baz: _baz.Baz
} = {});
({
prop: _foo.default
} = {});
({
prop: Bar
} = ({}, function () {
throw new Error('"' + "Bar" + '" is read-only.');
}()));
({
prop: _baz.Baz
} = {});

View File

@@ -0,0 +1,23 @@
import "foo";
var exports = "local exports";
var module = "local module";
console.log(exports);
console.log(exports.prop);
exports++;
exports += 4;
({ exports } = {});
[ exports ] = [];
exports = {};
exports.prop = "";
console.log(module);
console.log(module.exports);
module++;
module += 4;
({ module } = {});
[ module ] = [];
module = {};
module.prop = "";

View File

@@ -0,0 +1,26 @@
"use strict";
require("foo");
var _exports = "local exports";
var _module = "local module";
console.log(_exports);
console.log(_exports.prop);
_exports++;
_exports += 4;
({
exports: _exports
} = {});
[_exports] = [];
_exports = {};
_exports.prop = "";
console.log(_module);
console.log(_module.exports);
_module++;
_module += 4;
({
module: _module
} = {});
[_module] = [];
_module = {};
_module.prop = "";

Some files were not shown because too many files have changed in this diff Show More