Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31e6b18346 | ||
|
|
d17ac92a3f | ||
|
|
188bcb70f7 | ||
|
|
b8bd11a0e7 | ||
|
|
45bc74efe7 | ||
|
|
7eb169a894 | ||
|
|
eed4f312d8 | ||
|
|
44e4dc970f | ||
|
|
5d32432e67 | ||
|
|
9c9af6dbbd | ||
|
|
70cd650e10 | ||
|
|
c7bb00d58d | ||
|
|
623be068c4 | ||
|
|
71f5c9791d | ||
|
|
3e6e86d073 | ||
|
|
a0fb398ca2 | ||
|
|
71b9f19e6a | ||
|
|
c45ce58f0c | ||
|
|
d32f587e3c | ||
|
|
9e1874ba89 | ||
|
|
35fdc5c5d8 | ||
|
|
a4035fc257 | ||
|
|
42e3dc7a70 | ||
|
|
cdccf24515 |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -13,6 +13,31 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.7.2
|
||||
|
||||
* **New Feature**
|
||||
* `"both"` option for `sourceMap`.
|
||||
* Add output types to external helpers. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
|
||||
* **Bug Fix**
|
||||
* Fix node duplication sometimes resulting in a recursion error.
|
||||
* Ignore `break`s within cases inside `for...of`.
|
||||
* **Polish**
|
||||
* Split up variable declarations and export declarations to allow easier transformation.
|
||||
|
||||
## 4.7.0
|
||||
|
||||
* **Bug Fix**
|
||||
* Add `alternate` to list of `STATEMENT_OR_BLOCK` keys.
|
||||
* Add support for module specifiers to `t.isReferenced`.
|
||||
* **New Feature**
|
||||
* Add `inputSourceMap` option.
|
||||
* **Polish**
|
||||
* Throw an error on different `babel` and `babel-runtime` versions.
|
||||
* Replicate module environment for `babel-node` eval.
|
||||
* Clean up classes output.
|
||||
* **Spec Compliancy**
|
||||
* Make it illegal to use a rest parameter on a setter.
|
||||
|
||||
## 4.6.6
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var util = require("../lib/babel/util");
|
||||
var runtime = require("../lib/babel/build-external-helpers");
|
||||
console.log(runtime());
|
||||
|
||||
commander.option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", util.list);
|
||||
commander.option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");
|
||||
|
||||
commander.usage("[options]");
|
||||
commander.parse(process.argv);
|
||||
|
||||
console.log(runtime(commander.whitelist, commander.outputType));
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
var sourceMapToComment = require("source-map-to-comment");
|
||||
var sourceMap = require("source-map");
|
||||
var chokidar = require("chokidar");
|
||||
var path = require("path");
|
||||
var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
var convertSourceMap = require("convert-source-map");
|
||||
var sourceMap = require("source-map");
|
||||
var chokidar = require("chokidar");
|
||||
var path = require("path");
|
||||
var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
module.exports = function (commander, filenames) {
|
||||
var results = [];
|
||||
@@ -42,7 +42,7 @@ module.exports = function (commander, filenames) {
|
||||
});
|
||||
|
||||
if (commander.sourceMapsInline || (!commander.outFile && commander.sourceMaps)) {
|
||||
code += "\n" + sourceMapToComment(map);
|
||||
code += "\n" + convertSourceMap.fromObject(map).toComment();
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.7.0",
|
||||
"version": "4.7.2",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.6.6",
|
||||
"version": "4.7.1",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
@@ -57,7 +57,7 @@ var compile = function (filename) {
|
||||
|
||||
if (!result) {
|
||||
result = babel.transformFileSync(filename, extend(opts, {
|
||||
sourceMap: true,
|
||||
sourceMap: "both",
|
||||
ast: false
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import buildHelpers from "./build-helpers";
|
||||
import generator from "./generation";
|
||||
import * as messages from "./messages";
|
||||
import * as util from "./util";
|
||||
import t from "./types";
|
||||
|
||||
export default function (whitelist) {
|
||||
var namespace = t.identifier("babelHelpers");
|
||||
|
||||
function buildGlobal(namespace, builder) {
|
||||
var body = [];
|
||||
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
|
||||
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
|
||||
@@ -17,7 +16,58 @@ export default function (whitelist) {
|
||||
)
|
||||
]));
|
||||
|
||||
buildHelpers(body, namespace, whitelist);
|
||||
builder(body);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
function buildUmd(namespace, builder) {
|
||||
var body = [];
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(namespace, t.identifier("global"))
|
||||
]));
|
||||
|
||||
builder(body);
|
||||
|
||||
var container = util.template("umd-commonjs-strict", {
|
||||
FACTORY_PARAMETERS: t.identifier("global"),
|
||||
BROWSER_ARGUMENTS: t.assignmentExpression("=", t.memberExpression(t.identifier("root"), namespace), t.objectExpression({})),
|
||||
COMMON_ARGUMENTS: t.identifier("exports"),
|
||||
AMD_ARGUMENTS: t.arrayExpression([t.literal("exports")]),
|
||||
FACTORY_BODY: body,
|
||||
UMD_ROOT: t.identifier("this")
|
||||
});
|
||||
return t.program([container]);
|
||||
}
|
||||
|
||||
function buildVar(namespace, builder) {
|
||||
var body = [];
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(namespace, t.objectExpression({}))
|
||||
]));
|
||||
builder(body);
|
||||
return t.program(body);
|
||||
}
|
||||
|
||||
export default function (whitelist, outputType = "global") {
|
||||
var namespace = t.identifier("babelHelpers");
|
||||
var builder = function (body) {
|
||||
return buildHelpers(body, namespace, whitelist);
|
||||
};
|
||||
|
||||
var tree;
|
||||
|
||||
var build = {
|
||||
global: buildGlobal,
|
||||
umd: buildUmd,
|
||||
var: buildVar
|
||||
}[outputType];
|
||||
|
||||
if (build) {
|
||||
tree = build(namespace, builder);
|
||||
} else {
|
||||
throw new Error(messages.get("unsupportedOutputType", outputType));
|
||||
}
|
||||
|
||||
return generator(tree).code;
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ var highlight = function (text) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = function (lines, lineNumber, colNumber) {
|
||||
export default function (lines, lineNumber, colNumber) {
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
|
||||
if (chalk.supportsColor) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from "../types";
|
||||
|
||||
module.exports = function (ast, comments, tokens) {
|
||||
export default function (ast, comments, tokens) {
|
||||
if (ast && ast.type === "Program") {
|
||||
return t.file(ast, comments || [], tokens || []);
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module.exports = function () {
|
||||
export default function () {
|
||||
return Object.create(null);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import estraverse from "estraverse";
|
||||
import codeFrame from "./code-frame";
|
||||
import acorn from "acorn-babel";
|
||||
|
||||
module.exports = function (opts, code, callback) {
|
||||
export default function (opts, code, callback) {
|
||||
try {
|
||||
var comments = [];
|
||||
var tokens = [];
|
||||
|
||||
@@ -20,7 +20,8 @@ export var messages = {
|
||||
didYouMean: "Did you mean $1?",
|
||||
evalInStrictMode: "eval is not allowed in strict mode",
|
||||
codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
|
||||
missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues"
|
||||
missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
|
||||
unsupportedOutputType: "Unsupported output type $1"
|
||||
};
|
||||
|
||||
export function get(key) {
|
||||
|
||||
@@ -285,7 +285,7 @@ export default class File {
|
||||
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap;
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
|
||||
@@ -339,7 +339,11 @@ export default class File {
|
||||
this.dynamicImported.push(declar);
|
||||
if (noDefault) this.dynamicImportedNoDefault.push(declar);
|
||||
|
||||
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
|
||||
if (this.transformers["es6.modules"].canRun()) {
|
||||
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
|
||||
} else {
|
||||
this.dynamicImports.push(declar);
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
@@ -479,14 +483,16 @@ export default class File {
|
||||
var inputMap = opts.inputSourceMap;
|
||||
|
||||
if (inputMap) {
|
||||
map.sources[0] = inputMap.file;
|
||||
|
||||
var inputMapConsumer = new sourceMap.SourceMapConsumer(inputMap);
|
||||
var outputMapConsumer = new sourceMap.SourceMapConsumer(map);
|
||||
var outputMapGenerator = sourceMap.SourceMapGenerator.fromSourceMap(outputMapConsumer);
|
||||
outputMapGenerator.applySourceMap(inputMapConsumer);
|
||||
|
||||
var mergedMap = outputMapGenerator.toJSON();
|
||||
mergedMap.sources = map.sources
|
||||
mergedMap.file = map.file;
|
||||
mergedMap.sources = inputMap.sources
|
||||
mergedMap.file = inputMap.file;
|
||||
return mergedMap;
|
||||
}
|
||||
|
||||
@@ -521,8 +527,11 @@ export default class File {
|
||||
|
||||
result.map = this.mergeSourceMap(result.map);
|
||||
|
||||
if (opts.sourceMap === "inline") {
|
||||
if (opts.sourceMap === "inline" || opts.sourceMap === "both") {
|
||||
result.code += "\n" + convertSourceMap.fromObject(result.map).toComment();
|
||||
}
|
||||
|
||||
if (opts.sourceMap === "both") {
|
||||
result.map = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
var isAssignment = function (node) {
|
||||
return node.operator === opts.operator + "=";
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function build(node, buildBody) {
|
||||
export default function build(node, buildBody) {
|
||||
var self = node.blocks.shift();
|
||||
if (!self) return;
|
||||
|
||||
@@ -20,4 +20,4 @@ module.exports = function build(node, buildBody) {
|
||||
self.right,
|
||||
t.blockStatement([child])
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
var buildAssignment = function (left, right) {
|
||||
return t.assignmentExpression("=", left, right);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ import esutils from "esutils";
|
||||
import * as react from "./react";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
exports.check = function (node) {
|
||||
if (t.isJSX(node)) return true;
|
||||
if (react.isCreateClass(node)) return true;
|
||||
|
||||
@@ -45,7 +45,7 @@ var getPropRef = function (node, nodes, file, scope) {
|
||||
return temp;
|
||||
};
|
||||
|
||||
module.exports = function (node, nodes, file, scope, allowedSingleIdent) {
|
||||
export default function (node, nodes, file, scope, allowedSingleIdent) {
|
||||
var obj;
|
||||
if (t.isIdentifier(node) && allowedSingleIdent) {
|
||||
obj = node;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (node) {
|
||||
export default function (node) {
|
||||
var lastNonDefault = 0;
|
||||
for (var i = 0; i < node.params.length; i++) {
|
||||
if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
|
||||
|
||||
@@ -16,7 +16,7 @@ var visitor = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (node, callId, scope) {
|
||||
export default function (node, callId, scope) {
|
||||
node.async = false;
|
||||
node.generator = true;
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ var remapVisitor = {
|
||||
};
|
||||
|
||||
var importsVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
if (t.isImportDeclaration(node)) {
|
||||
ImportDeclaration: {
|
||||
enter(node, parent, scope, formatter) {
|
||||
formatter.hasLocalImports = true;
|
||||
extend(formatter.localImports, t.getBindingIdentifiers(node));
|
||||
formatter.bumpImportOccurences(node);
|
||||
@@ -52,9 +52,9 @@ var importsVisitor = {
|
||||
};
|
||||
|
||||
var exportsVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
var declar = node && node.declaration;
|
||||
if (t.isExportDeclaration(node)) {
|
||||
ExportDeclaration: {
|
||||
enter(node, parent, scope, formatter) {
|
||||
var declar = node.declaration;
|
||||
formatter.hasLocalImports = true;
|
||||
|
||||
if (declar && t.isStatement(declar)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
commonStrict: require("./common-strict"),
|
||||
amdStrict: require("./amd-strict"),
|
||||
umdStrict: require("./umd-strict"),
|
||||
|
||||
11
src/babel/transformation/templates/umd-commonjs-strict.js
Normal file
11
src/babel/transformation/templates/umd-commonjs-strict.js
Normal file
@@ -0,0 +1,11 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(AMD_ARGUMENTS, factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
factory(COMMON_ARGUMENTS);
|
||||
} else {
|
||||
factory(BROWSER_ARGUMENTS);
|
||||
}
|
||||
})(UMD_ROOT, function (FACTORY_PARAMETERS) {
|
||||
FACTORY_BODY
|
||||
});
|
||||
@@ -52,6 +52,9 @@ var breakVisitor = {
|
||||
if (!node.label && state.ignoreLabeless) return;
|
||||
if (node.label && node.label.name !== state.label) return;
|
||||
|
||||
// break statements mean something different in this context
|
||||
if (t.isSwitchCase(parent)) return;
|
||||
|
||||
var ret = t.expressionStatement(
|
||||
t.callExpression(t.memberExpression(state.iteratorKey, t.identifier("return")), [])
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as strict from "../../helpers/strict";
|
||||
|
||||
export function Program(program, parent, scope, file) {
|
||||
if (!file.transformers["es6.modules"].canRun()) return;
|
||||
|
||||
strict.wrap(program, function () {
|
||||
program.body = file.dynamicImports.concat(program.body);
|
||||
});
|
||||
|
||||
if (!file.transformers["es6.modules"].canRun()) return;
|
||||
|
||||
if (file.moduleFormatter.transform) {
|
||||
file.moduleFormatter.transform(program);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,16 @@ export function ExportDeclaration(node, parent, scope) {
|
||||
node.declaration = null;
|
||||
node._blockHoist = 2;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isVariableDeclaration(declar)) {
|
||||
var specifiers = [];
|
||||
|
||||
var bindings = t.getBindingIdentifiers(declar);
|
||||
for (var key in bindings) {
|
||||
var id = bindings[key];
|
||||
specifiers.push(t.exportSpecifier(id, id));
|
||||
}
|
||||
|
||||
return [declar, t.exportDeclaration(null, specifiers)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
|
||||
// check if the input Literal `source` is an alternate casing of "react"
|
||||
var check = function (source, file) {
|
||||
function check(source, file) {
|
||||
if (t.isLiteral(source)) {
|
||||
var name = source.value;
|
||||
var lower = name.toLowerCase();
|
||||
@@ -11,7 +11,7 @@ var check = function (source, file) {
|
||||
throw file.errorWithNode(source, messages.get("didYouMean", "react"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function CallExpression(node, parent, scope, file) {
|
||||
if (t.isIdentifier(node.callee, { name: "require" }) && node.arguments.length === 1) {
|
||||
|
||||
@@ -6,10 +6,9 @@ export default class TraversalContext {
|
||||
constructor(scope, opts, state, parentPath) {
|
||||
this.shouldFlatten = false;
|
||||
this.parentPath = parentPath;
|
||||
|
||||
this.scope = scope;
|
||||
this.state = state;
|
||||
this.opts = opts;
|
||||
this.scope = scope;
|
||||
this.state = state;
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
flatten() {
|
||||
|
||||
@@ -4,11 +4,10 @@ import Scope from "./scope";
|
||||
import t from "../types";
|
||||
|
||||
export default class TraversalPath {
|
||||
constructor(parentPath, parent, container) {
|
||||
this.parentPath = parentPath;
|
||||
this.container = container;
|
||||
this.parent = parent;
|
||||
this.data = {};
|
||||
constructor(parent, container) {
|
||||
this.container = container;
|
||||
this.parent = parent;
|
||||
this.data = {};
|
||||
}
|
||||
|
||||
static get(parentPath, context, parent, container, key) {
|
||||
@@ -25,11 +24,11 @@ export default class TraversalPath {
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
path = new TraversalPath(parentPath, parent, container);
|
||||
path = new TraversalPath(parent, container);
|
||||
paths.push(path);
|
||||
}
|
||||
|
||||
path.setContext(context, key);
|
||||
path.setContext(parentPath, context, key);
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -57,15 +56,16 @@ export default class TraversalPath {
|
||||
this.scope = TraversalPath.getScope(this.node, this.parent, this.context.scope);
|
||||
}
|
||||
|
||||
setContext(context, key) {
|
||||
setContext(parentPath, context, key) {
|
||||
this.shouldRemove = false;
|
||||
this.shouldSkip = false;
|
||||
this.shouldStop = false;
|
||||
|
||||
this.context = context;
|
||||
this.state = context.state;
|
||||
this.opts = context.opts;
|
||||
this.key = key;
|
||||
this.parentPath = parentPath;
|
||||
this.context = context;
|
||||
this.state = context.state;
|
||||
this.opts = context.opts;
|
||||
this.key = key;
|
||||
|
||||
this.setScope();
|
||||
}
|
||||
|
||||
@@ -144,22 +144,6 @@ t.toComputedKey = function (node, key) {
|
||||
return key;
|
||||
};
|
||||
|
||||
/*
|
||||
* Shallowly checks to see if the passed `node` is falsy.
|
||||
*
|
||||
* @param {Object} node
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
t.isFalsyExpression = function (node) {
|
||||
if (t.isLiteral(node)) {
|
||||
return !node.value;
|
||||
} else if (t.isIdentifier(node)) {
|
||||
return node.name === "undefined";
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Turn an array of statement `nodes` into a `SequenceExpression`.
|
||||
*
|
||||
@@ -453,6 +437,8 @@ t.cloneDeep = function (node) {
|
||||
var newNode = {};
|
||||
|
||||
for (var key in node) {
|
||||
if (key[0] === "_") continue;
|
||||
|
||||
var val = node[key];
|
||||
|
||||
if (val) {
|
||||
|
||||
@@ -86,8 +86,8 @@ var run = function (task, done) {
|
||||
}
|
||||
};
|
||||
|
||||
var fn = new Function("require", "done", execCode);
|
||||
fn.call(global, fakeRequire, chai.assert, done);
|
||||
var fn = new Function("require", "done", "exports", execCode);
|
||||
fn.call(global, fakeRequire, chai.assert, {}, done);
|
||||
} catch (err) {
|
||||
err.message = exec.loc + ": " + err.message;
|
||||
err.message += codeFrame(execCode);
|
||||
|
||||
2
test/fixtures/transformation/es6-block-scoping-tdz-fail/export.js
vendored
Normal file
2
test/fixtures/transformation/es6-block-scoping-tdz-fail/export.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
a;
|
||||
export const a = 1;
|
||||
2
test/fixtures/transformation/es6-block-scoping-tdz-pass/export.js
vendored
Normal file
2
test/fixtures/transformation/es6-block-scoping-tdz-pass/export.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export const a = 1;
|
||||
a;
|
||||
6
test/fixtures/transformation/es6-for-of-loose/ignore-cases/actual.js
vendored
Normal file
6
test/fixtures/transformation/es6-for-of-loose/ignore-cases/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
for (var i of foo) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
21
test/fixtures/transformation/es6-for-of-loose/ignore-cases/expected.js
vendored
Normal file
21
test/fixtures/transformation/es6-for-of-loose/ignore-cases/expected.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
for (var _iterator = foo, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var i = _ref;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
6
test/fixtures/transformation/es6-for-of/ignore-cases/actual.js
vendored
Normal file
6
test/fixtures/transformation/es6-for-of/ignore-cases/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
for (var i of foo) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
29
test/fixtures/transformation/es6-for-of/ignore-cases/expected.js
vendored
Normal file
29
test/fixtures/transformation/es6-for-of/ignore-cases/expected.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = foo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var i = _step.value;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator["return"]) {
|
||||
_iterator["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,22 @@ define(["exports"], function (exports) {
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = exports.foo = 1;
|
||||
var foo = exports.foo = 1;
|
||||
var bar = exports.bar = 2;
|
||||
var foo2 = exports.foo2 = function foo2() {};
|
||||
var foo3 = exports.foo3 = undefined;
|
||||
var foo4 = exports.foo4 = 2;
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
var foo = 1;
|
||||
exports.foo = foo;
|
||||
var foo = 1,
|
||||
bar = 2;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
var foo2 = function foo2() {};
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5 = undefined;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
|
||||
function foo7() {}
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@ define(["exports", "./evens"], function (exports, _evens) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
var isOdd = exports.isOdd = (function (isEven) {
|
||||
var isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
exports.isOdd = isOdd;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
@@ -9,8 +9,9 @@ define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports,
|
||||
var bar = _foo.bar;
|
||||
var bar2 = _foo.foo;
|
||||
exports.test = test;
|
||||
var test2 = exports.test2 = 5;
|
||||
var test2 = 5;
|
||||
|
||||
exports.test2 = test2;
|
||||
exports["default"] = test;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
var test = exports.test = 2;
|
||||
var test = 2;
|
||||
exports.test = test;
|
||||
test = exports.test = 5;
|
||||
test = exports.test += 1;
|
||||
|
||||
|
||||
@@ -3,14 +3,22 @@
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = exports.foo = 1;
|
||||
var foo = exports.foo = 1;
|
||||
var bar = exports.bar = 2;
|
||||
var foo2 = exports.foo2 = function foo2() {};
|
||||
var foo3 = exports.foo3 = undefined;
|
||||
var foo4 = exports.foo4 = 2;
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
var foo = 1;
|
||||
exports.foo = foo;
|
||||
var foo = 1,
|
||||
bar = 2;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
var foo2 = function foo2() {};
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5 = undefined;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
|
||||
function foo7() {}
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@ function nextOdd(n) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
var isOdd = exports.isOdd = (function (isEven) {
|
||||
var isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
exports.isOdd = isOdd;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var foo = exports.foo = 5;
|
||||
exports.__esModule = true;
|
||||
var foo = 5;
|
||||
exports.foo = foo;
|
||||
exports.__esModule = true;
|
||||
@@ -19,7 +19,8 @@ var bar = require("foo4").bar;
|
||||
var bar2 = require("foo5").foo;
|
||||
|
||||
exports.test = test;
|
||||
var test = exports.test = 5;
|
||||
var test = 5;
|
||||
exports.test = test;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var test = exports.test = 2;
|
||||
var test = 2;
|
||||
exports.test = test;
|
||||
test = exports.test = 5;
|
||||
test = exports.test += 1;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ var foo = 1;
|
||||
var foo = 1,
|
||||
bar = 2;
|
||||
var foo2 = function foo2() {};
|
||||
var foo3 = undefined;
|
||||
var foo3;
|
||||
var foo4 = 2;
|
||||
var foo5 = undefined;
|
||||
var foo6 = 3;
|
||||
|
||||
@@ -12,12 +12,28 @@ System.register([], function (_export) {
|
||||
|
||||
_classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
foo = _export("foo", 1);
|
||||
foo2 = _export("foo2", function foo2() {});
|
||||
foo3 = _export("foo3", undefined);
|
||||
foo4 = _export("foo4", 2);
|
||||
foo5 = _export("foo5", undefined);
|
||||
foo6 = _export("foo6", 3);
|
||||
foo = 1;
|
||||
|
||||
_export("foo", foo);
|
||||
|
||||
foo2 = function foo2() {};
|
||||
|
||||
_export("foo2", foo2);
|
||||
|
||||
_export("foo3", foo3);
|
||||
|
||||
foo4 = 2;
|
||||
|
||||
_export("foo4", foo4);
|
||||
|
||||
foo5 = undefined;
|
||||
|
||||
_export("foo5", foo5);
|
||||
|
||||
foo6 = 3;
|
||||
|
||||
_export("foo6", foo6);
|
||||
|
||||
foo8 = _export("foo8", function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
});
|
||||
|
||||
@@ -14,12 +14,17 @@ System.register(["./evens"], function (_export) {
|
||||
execute: function () {
|
||||
"use strict";
|
||||
|
||||
p = _export("p", 5);
|
||||
isOdd = _export("isOdd", (function (isEven) {
|
||||
p = 5;
|
||||
|
||||
_export("p", p);
|
||||
|
||||
isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven));
|
||||
})(isEven);
|
||||
|
||||
_export("isOdd", isOdd);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -12,7 +12,9 @@ System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
|
||||
|
||||
_export("test", test);
|
||||
|
||||
test2 = _export("test2", 5);
|
||||
test2 = 5;
|
||||
|
||||
_export("test2", test2);
|
||||
|
||||
_export("default", test);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ System.register([], function (_export) {
|
||||
execute: function () {
|
||||
"use strict";
|
||||
|
||||
test = _export("test", 2);
|
||||
test = 2;
|
||||
|
||||
_export("test", test);
|
||||
|
||||
_export("test", test = 5);
|
||||
_export("test", test += 1);
|
||||
|
||||
@@ -10,14 +10,22 @@
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = exports.foo = 1;
|
||||
var foo = exports.foo = 1;
|
||||
var bar = exports.bar = 2;
|
||||
var foo2 = exports.foo2 = function foo2() {};
|
||||
var foo3 = exports.foo3 = undefined;
|
||||
var foo4 = exports.foo4 = 2;
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
var foo = 1;
|
||||
exports.foo = foo;
|
||||
var foo = 1,
|
||||
bar = 2;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
var foo2 = function foo2() {};
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5 = undefined;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
|
||||
function foo7() {}
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
var isOdd = exports.isOdd = (function (isEven) {
|
||||
var isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
exports.isOdd = isOdd;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
var bar = _foo.bar;
|
||||
var bar2 = _foo.foo;
|
||||
exports.test = test;
|
||||
var test2 = exports.test2 = 5;
|
||||
var test2 = 5;
|
||||
|
||||
exports.test2 = test2;
|
||||
exports["default"] = test;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
})(function (exports) {
|
||||
"use strict";
|
||||
|
||||
var test = exports.test = 2;
|
||||
var test = 2;
|
||||
exports.test = test;
|
||||
test = exports.test = 5;
|
||||
test = exports.test += 1;
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ var foo = _babelHelpers.interopRequire(_someModule);
|
||||
|
||||
var bar = _babelHelpers.interopRequireWildcard(_someModule);
|
||||
|
||||
var myWord = exports.myWord = _core.Symbol("abc");
|
||||
var myWord = _core.Symbol("abc");
|
||||
exports.myWord = myWord;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
3
test/fixtures/transformation/utility.remove-console/nested/actual.js
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/nested/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function foo() {
|
||||
console.log("foo");
|
||||
}
|
||||
3
test/fixtures/transformation/utility.remove-console/nested/expected.js
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/nested/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {}
|
||||
3
test/fixtures/transformation/utility.remove-console/options.json
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": ["utility.removeConsole"]
|
||||
}
|
||||
1
test/fixtures/transformation/utility.remove-console/top-level/actual.js
vendored
Normal file
1
test/fixtures/transformation/utility.remove-console/top-level/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log("foo");
|
||||
1
test/fixtures/transformation/utility.remove-console/top-level/expected.js
vendored
Normal file
1
test/fixtures/transformation/utility.remove-console/top-level/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";
|
||||
Reference in New Issue
Block a user