Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12b1de7c9d | ||
|
|
721636f475 | ||
|
|
4c94941ceb | ||
|
|
f06535e915 | ||
|
|
389914c427 | ||
|
|
c7f5715d8e | ||
|
|
29f866525e | ||
|
|
de61455a55 | ||
|
|
fd579a8772 | ||
|
|
8e708906a8 | ||
|
|
b7680059c8 | ||
|
|
239369314c | ||
|
|
f2d1fc47d1 | ||
|
|
aab35736c5 | ||
|
|
a9405e5e80 | ||
|
|
9880990fa7 | ||
|
|
6674611b26 | ||
|
|
e92ec6aba7 | ||
|
|
1801b725bd | ||
|
|
72de8f5c9b | ||
|
|
895d965568 | ||
|
|
3a11c7d46b | ||
|
|
92d9b3ff5f | ||
|
|
630f1717f0 | ||
|
|
e6e93840a6 | ||
|
|
b2ad79cf88 | ||
|
|
706797eb47 | ||
|
|
4163d1372a | ||
|
|
4413da8d6e | ||
|
|
8e23d623c8 | ||
|
|
e712c5225b | ||
|
|
8bdb723004 | ||
|
|
9f912f548e | ||
|
|
41d721e372 | ||
|
|
df6ffe025c | ||
|
|
28b6b4af44 | ||
|
|
9e80071caa | ||
|
|
0da4303358 | ||
|
|
83e225f30a | ||
|
|
420505ca40 | ||
|
|
f9a26fd903 | ||
|
|
ca0539190e | ||
|
|
2e3226b520 | ||
|
|
7959852eeb |
6
.jscsrc
6
.jscsrc
@@ -14,7 +14,6 @@
|
||||
},
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpaceBeforePostfixUnaryOperators": true,
|
||||
@@ -33,10 +32,8 @@
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireSpaceBeforeBinaryOperators": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireDotNotation": true,
|
||||
"requireSpacesInForStatement": true,
|
||||
"requireCurlyBraces": [
|
||||
"do"
|
||||
@@ -52,7 +49,8 @@
|
||||
"return",
|
||||
"try",
|
||||
"catch",
|
||||
"typeof"
|
||||
"typeof",
|
||||
"function"
|
||||
],
|
||||
"validateLineBreaks": "LF",
|
||||
"validateQuoteMarks": "\"",
|
||||
|
||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -11,10 +11,36 @@
|
||||
|
||||
_Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
## 3.3.3
|
||||
## 3.3.7
|
||||
|
||||
* **Bug Fix**
|
||||
* Add `--use-strict` to valid node flags in `6to5-node`.
|
||||
* Fix booleans not being properly stripped from the arguments in `6to5-node`.
|
||||
* Force `.js` extension when writing files to directories with `6to5`.
|
||||
|
||||
## 3.3.5
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix block scoping inside of while loops.
|
||||
* Make module name regex more conservative. Thanks [@johlrich](https://github.com/johlrich)!
|
||||
* Fix block scoping of constants.
|
||||
* Fix istanbul interop.
|
||||
* Make JSX transforming more inline with the official transformer with spaces after non-empty last lines.
|
||||
* **Polish**
|
||||
* Make it illegal to export a property called `__esModule`.
|
||||
|
||||
## 3.3.4
|
||||
|
||||
* **Polish**
|
||||
* Add istanbul `require` interop.
|
||||
* **Bug Fix**
|
||||
* Fix incorrect source map column tracking in specific scenarios.
|
||||
|
||||
## 3.3.3
|
||||
|
||||
* **Polish**
|
||||
* Remap top level `this` to `undefined` instead of throwing an error.
|
||||
* **Bug Fix**
|
||||
* Run `selfContained` transformer over the regenerator runtime when building `6to5-runtime`.
|
||||
* Fix `t.isReferenced` not properly allowing `value` nodes.
|
||||
|
||||
@@ -325,8 +351,8 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
* **Polish**
|
||||
* Rest parameters now allocate the array before populating.
|
||||
* **Internal**
|
||||
* `for...in` loops have been changed to optimised `for` loops - better performance and no enumeration of protoype keys.
|
||||
* Parts of the code generator have now been optimised thanks to [gaearon](https://github.com/gaearon).
|
||||
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of protoype keys.
|
||||
* Parts of the code generator have now been optimized thanks to [gaearon](https://github.com/gaearon).
|
||||
|
||||
## 2.12.3
|
||||
|
||||
@@ -349,7 +375,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
* **Bug Fix**
|
||||
* Support non-string JSX literals.
|
||||
* **New Feature**
|
||||
* Loose mode for some transformers that enables non-spec behaviour.
|
||||
* Loose mode for some transformers that enables non-spec behavior.
|
||||
* **Internal**
|
||||
* Uglify `--mangle sort` has been added to the build script, cutting minified scripts in half.
|
||||
|
||||
@@ -787,7 +813,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
## 1.13.2
|
||||
|
||||
* Optimise `Array.from` usage by adding a helper method.
|
||||
* Optimize `Array.from` usage by adding a helper method.
|
||||
* Upgrade `acorn-6to5`.
|
||||
|
||||
## 1.13.1
|
||||
|
||||
2
NOTES.md
2
NOTES.md
@@ -1,3 +1,3 @@
|
||||
# Notes
|
||||
|
||||
* Wildcard exports/imports wont normalise if `export default` is a non-object. See [#224](https://github.com/6to5/6to5/issues/224).
|
||||
* Wildcard exports/imports wont normalize if `export default` is a non-object. See [#224](https://github.com/6to5/6to5/issues/224).
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* when found, before invoking the "real" _6to5-node(1) executable.
|
||||
*/
|
||||
|
||||
var args = ["--harmony", __dirname + "/_6to5-node"];
|
||||
var args = [__dirname + "/_6to5-node"];
|
||||
|
||||
process.argv.slice(2).forEach(function(arg){
|
||||
var flag = arg.split("=")[0];
|
||||
@@ -35,6 +35,7 @@ process.argv.slice(2).forEach(function(arg){
|
||||
case "--prof":
|
||||
case "--throw-deprecation":
|
||||
case "--trace-deprecation":
|
||||
case "--use-strict":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ module.exports = function (commander, filenames, opts) {
|
||||
}
|
||||
|
||||
var write = function (src, relative) {
|
||||
// remove extension and then append back on .js
|
||||
relative = relative.replace(/\.(\w*?)$/, "") + ".js";
|
||||
|
||||
var dest = path.join(commander.outDir, relative);
|
||||
|
||||
var data = util.compile(src, { sourceMapName: dest });
|
||||
|
||||
@@ -72,7 +72,8 @@ if (program.eval || program.print) {
|
||||
}
|
||||
|
||||
if (arg[0] === "-") {
|
||||
if (program[arg.slice(2)]) {
|
||||
var parsedArg = program[arg.slice(2)];
|
||||
if (parsedArg && parsedArg !== true) {
|
||||
ignoreNext = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,16 +4,17 @@ module.exports = File;
|
||||
|
||||
var SHEBANG_REGEX = /^\#\!.*/;
|
||||
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var transform = require("./transformation");
|
||||
var generate = require("./generation");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
var contains = require("lodash/collection/contains");
|
||||
var clone = require("./helpers/clone");
|
||||
var Scope = require("./traverse/scope");
|
||||
var util = require("./util");
|
||||
var t = require("./types");
|
||||
var contains = require("lodash/collection/contains");
|
||||
var path = require("path");
|
||||
var each = require("lodash/collection/each");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var t = require("./types");
|
||||
|
||||
function File(opts) {
|
||||
this.dynamicImportIds = {};
|
||||
@@ -24,7 +25,7 @@ function File(opts) {
|
||||
this.data = {};
|
||||
|
||||
this.lastStatements = [];
|
||||
this.opts = this.normaliseOptions(opts);
|
||||
this.opts = this.normalizeOptions(opts);
|
||||
this.ast = {};
|
||||
|
||||
this.buildTransformers();
|
||||
@@ -50,7 +51,9 @@ File.helpers = [
|
||||
"typeof",
|
||||
"extends",
|
||||
"get",
|
||||
"set"
|
||||
"set",
|
||||
"class-call-check",
|
||||
"class-super-constructor-call"
|
||||
];
|
||||
|
||||
File.validOptions = [
|
||||
@@ -85,7 +88,7 @@ File.validOptions = [
|
||||
"accept"
|
||||
];
|
||||
|
||||
File.prototype.normaliseOptions = function (opts) {
|
||||
File.prototype.normalizeOptions = function (opts) {
|
||||
opts = clone(opts);
|
||||
|
||||
for (var key in opts) {
|
||||
@@ -115,9 +118,11 @@ File.prototype.normaliseOptions = function (opts) {
|
||||
ast: true
|
||||
});
|
||||
|
||||
// normalise windows path separators to unix
|
||||
// normalize windows path separators to unix
|
||||
opts.filename = opts.filename.replace(/\\/g, "/");
|
||||
|
||||
opts.basename = path.basename(opts.filename, path.extname(opts.filename));
|
||||
|
||||
opts.blacklist = util.arrayify(opts.blacklist);
|
||||
opts.whitelist = util.arrayify(opts.whitelist);
|
||||
opts.optional = util.arrayify(opts.optional);
|
||||
@@ -402,14 +407,14 @@ File.prototype.generateUid = function (name, scope) {
|
||||
do {
|
||||
uid = this._generateUid(name, i);
|
||||
i++;
|
||||
} while (scope.has(uid));
|
||||
} while (scope.hasReference(uid));
|
||||
return uid;
|
||||
};
|
||||
|
||||
File.prototype.generateUidIdentifier = function (name, scope) {
|
||||
scope = scope || this.scope;
|
||||
var id = t.identifier(this.generateUid(name, scope));
|
||||
scope.add(id);
|
||||
scope.addDeclarationToFunctionScope("var", id);
|
||||
return id;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ function CodeGenerator(ast, opts, code) {
|
||||
|
||||
this.comments = ast.comments || [];
|
||||
this.tokens = ast.tokens || [];
|
||||
this.format = CodeGenerator.normaliseOptions(code, opts);
|
||||
this.format = CodeGenerator.normalizeOptions(code, opts);
|
||||
this.ast = ast;
|
||||
|
||||
this.whitespace = new Whitespace(this.tokens, this.comments);
|
||||
@@ -39,7 +39,7 @@ each(Buffer.prototype, function (fn, key) {
|
||||
};
|
||||
});
|
||||
|
||||
CodeGenerator.normaliseOptions = function (code, opts) {
|
||||
CodeGenerator.normalizeOptions = function (code, opts) {
|
||||
var style = " ";
|
||||
if (code) {
|
||||
var indent = detectIndent(code).indent;
|
||||
@@ -179,7 +179,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
newline(true);
|
||||
|
||||
if (opts.before) opts.before();
|
||||
this.map.mark(node, "start");
|
||||
this.map.mark(node);
|
||||
|
||||
this[node.type](node, this.buildPrint(node), parent);
|
||||
|
||||
@@ -189,7 +189,6 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
}
|
||||
if (needsParens) this.push(")");
|
||||
|
||||
this.map.mark(node, "end");
|
||||
if (opts.after) opts.after();
|
||||
|
||||
newline(false);
|
||||
|
||||
@@ -30,7 +30,7 @@ SourceMap.prototype.get = function () {
|
||||
}
|
||||
};
|
||||
|
||||
SourceMap.prototype.mark = function (node, type) {
|
||||
SourceMap.prototype.mark = function (node) {
|
||||
var loc = node.loc;
|
||||
if (!loc) return; // no location info
|
||||
|
||||
@@ -46,9 +46,7 @@ SourceMap.prototype.mark = function (node, type) {
|
||||
column: position.column
|
||||
};
|
||||
|
||||
var original = loc[type];
|
||||
|
||||
if (generated.line === original.line && generated.column === original.column) return; // nothing to map
|
||||
var original = loc.start;
|
||||
|
||||
map.addMapping({
|
||||
source: this.opts.sourceFileName,
|
||||
|
||||
0
lib/6to5/optimisation/index.js
Normal file
0
lib/6to5/optimisation/index.js
Normal file
@@ -34,20 +34,14 @@ var cache = registerCache.get();
|
||||
var transformOpts = {};
|
||||
var ignoreRegex = /node_modules/;
|
||||
var onlyRegex;
|
||||
var whitelist = [];
|
||||
var exts = {};
|
||||
var maps = {};
|
||||
var old = require.extensions[".js"];
|
||||
|
||||
var mtime = function (filename) {
|
||||
return +fs.statSync(filename).mtime;
|
||||
};
|
||||
|
||||
var loader = function (m, filename) {
|
||||
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
|
||||
return old.apply(this, arguments);
|
||||
}
|
||||
|
||||
var compile = function (filename) {
|
||||
var result;
|
||||
|
||||
if (cache) {
|
||||
@@ -57,11 +51,12 @@ var loader = function (m, filename) {
|
||||
}
|
||||
}
|
||||
|
||||
result = result || to5.transformFileSync(filename, extend({
|
||||
whitelist: whitelist,
|
||||
sourceMap: true,
|
||||
ast: false
|
||||
}, transformOpts));
|
||||
if (!result) {
|
||||
result = to5.transformFileSync(filename, extend({
|
||||
sourceMap: true,
|
||||
ast: false
|
||||
}, transformOpts));
|
||||
}
|
||||
|
||||
if (cache) {
|
||||
result.mtime = mtime(filename);
|
||||
@@ -70,7 +65,54 @@ var loader = function (m, filename) {
|
||||
|
||||
maps[filename] = result.map;
|
||||
|
||||
m._compile(result.code, filename);
|
||||
return result.code;
|
||||
};
|
||||
|
||||
var shouldIgnore = function (filename) {
|
||||
return (ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename));
|
||||
};
|
||||
|
||||
var istanbulMonkey = {};
|
||||
|
||||
if (process.env.running_under_istanbul) { // jshint ignore:line
|
||||
// we need to monkey patch fs.readFileSync so we can hook into
|
||||
// what istanbul gets, it's extremely dirty but it's the only way
|
||||
var _readFileSync = fs.readFileSync;
|
||||
|
||||
fs.readFileSync = function (filename) {
|
||||
if (istanbulMonkey[filename]) {
|
||||
delete istanbulMonkey[filename];
|
||||
var code = compile(filename);
|
||||
istanbulMonkey[filename] = true;
|
||||
return code;
|
||||
} else {
|
||||
return _readFileSync.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var istanbulLoader = function (m, filename, old) {
|
||||
istanbulMonkey[filename] = true;
|
||||
old(m, filename);
|
||||
};
|
||||
|
||||
var normalLoader = function (m, filename) {
|
||||
m._compile(compile(filename), filename);
|
||||
};
|
||||
|
||||
var registerExtension = function (ext) {
|
||||
var old = require.extensions[ext];
|
||||
|
||||
var loader = normalLoader;
|
||||
if (process.env.running_under_istanbul) loader = istanbulLoader; // jshint ignore:line
|
||||
|
||||
require.extensions[ext] = function (m, filename) {
|
||||
if (shouldIgnore(filename)) {
|
||||
old(m, filename);
|
||||
} else {
|
||||
loader(m, filename, old);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var hookExtensions = function (_exts) {
|
||||
@@ -82,14 +124,14 @@ var hookExtensions = function (_exts) {
|
||||
|
||||
each(_exts, function (ext) {
|
||||
exts[ext] = require.extensions[ext];
|
||||
require.extensions[ext] = loader;
|
||||
registerExtension(ext);
|
||||
});
|
||||
};
|
||||
|
||||
hookExtensions(util.canCompile.EXTENSIONS);
|
||||
|
||||
module.exports = function (opts) {
|
||||
// normalise options
|
||||
// normalize options
|
||||
opts = opts || {};
|
||||
|
||||
if (opts.only != null) onlyRegex = util.regexify(opts.only);
|
||||
|
||||
73
lib/6to5/transformation/helpers/define-map.js
Normal file
73
lib/6to5/transformation/helpers/define-map.js
Normal file
@@ -0,0 +1,73 @@
|
||||
var cloneDeep = require("lodash/lang/cloneDeep");
|
||||
var traverse = require("../../traverse");
|
||||
var clone = require("lodash/lang/clone");
|
||||
var each = require("lodash/collection/each");
|
||||
var has = require("lodash/object/has");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.push = function (mutatorMap, key, kind, computed, value) {
|
||||
var alias;
|
||||
|
||||
if (t.isIdentifier(key)) {
|
||||
alias = key.name;
|
||||
if (computed) alias = "computed:" + alias;
|
||||
} else if (t.isLiteral(key)) {
|
||||
alias = String(key.value);
|
||||
} else {
|
||||
alias = JSON.stringify(traverse.removeProperties(cloneDeep(key)));
|
||||
}
|
||||
|
||||
var map;
|
||||
if (has(mutatorMap, alias)) {
|
||||
map = mutatorMap[alias];
|
||||
} else {
|
||||
map = {};
|
||||
}
|
||||
mutatorMap[alias] = map;
|
||||
|
||||
map._key = key;
|
||||
if (computed) {
|
||||
map._computed = true;
|
||||
}
|
||||
|
||||
map[kind] = value;
|
||||
};
|
||||
|
||||
exports.build = function (mutatorMap) {
|
||||
var objExpr = t.objectExpression([]);
|
||||
|
||||
each(mutatorMap, function (map) {
|
||||
var mapNode = t.objectExpression([]);
|
||||
|
||||
var propNode = t.property("init", map._key, mapNode, map._computed);
|
||||
|
||||
if (!map.get && !map.set) {
|
||||
map.writable = t.literal(true);
|
||||
}
|
||||
|
||||
if (map.enumerable === false) {
|
||||
delete map.enumerable;
|
||||
} else {
|
||||
map.enumerable = t.literal(true);
|
||||
}
|
||||
|
||||
map.configurable = t.literal(true);
|
||||
|
||||
each(map, function (node, key) {
|
||||
if (key[0] === "_") return;
|
||||
|
||||
node = clone(node);
|
||||
var inheritNode = node;
|
||||
if (t.isMethodDefinition(node)) node = node.value;
|
||||
|
||||
var prop = t.property("init", t.identifier(key), node);
|
||||
t.inheritsComments(prop, inheritNode);
|
||||
t.removeComments(inheritNode);
|
||||
mapNode.properties.push(prop);
|
||||
});
|
||||
|
||||
objExpr.properties.push(propNode);
|
||||
});
|
||||
|
||||
return objExpr;
|
||||
};
|
||||
@@ -5,7 +5,7 @@ var t = require("../../types");
|
||||
var getObjRef = function (node, nodes, file, scope) {
|
||||
var ref;
|
||||
if (t.isIdentifier(node)) {
|
||||
if (scope.has(node.name, true)) {
|
||||
if (scope.hasBinding(node.name)) {
|
||||
// this variable is declared in scope so we can be 100% sure
|
||||
// that evaluating it multiple times wont trigger a getter
|
||||
// or something else
|
||||
@@ -18,7 +18,7 @@ var getObjRef = function (node, nodes, file, scope) {
|
||||
} else if (t.isMemberExpression(node)) {
|
||||
ref = node.object;
|
||||
|
||||
if (t.isIdentifier(ref) && scope.has(ref.name)) {
|
||||
if (t.isIdentifier(ref) && scope.hasReference(ref.name)) {
|
||||
// the object reference that we need to save is locally declared
|
||||
// so as per the previous comment we can be 100% sure evaluating
|
||||
// it multiple times will be safe
|
||||
|
||||
@@ -14,7 +14,7 @@ var visitor = {
|
||||
|
||||
// check that we don't have a local variable declared as that removes the need
|
||||
// for the wrapper
|
||||
var localDeclar = scope.get(state.id, true);
|
||||
var localDeclar = scope.getBinding(state.id);
|
||||
if (localDeclar !== state.outerDeclar) return;
|
||||
|
||||
state.selfReference = true;
|
||||
@@ -32,7 +32,7 @@ exports.property = function (node, file, scope) {
|
||||
var state = {
|
||||
id: id,
|
||||
selfReference: false,
|
||||
outerDeclar: scope.get(id, true),
|
||||
outerDeclar: scope.getBinding(id),
|
||||
};
|
||||
|
||||
traverse(node, visitor, scope, state);
|
||||
|
||||
@@ -14,7 +14,7 @@ function transform(code, opts) {
|
||||
}
|
||||
|
||||
transform.fromAst = function (ast, code, opts) {
|
||||
ast = util.normaliseAst(ast);
|
||||
ast = util.normalizeAst(ast);
|
||||
|
||||
var file = new File(opts);
|
||||
file.addCode(code);
|
||||
|
||||
@@ -45,7 +45,7 @@ var exportsVisitor = {
|
||||
formatter.hasLocalImports = true;
|
||||
|
||||
if (declar && t.isStatement(declar)) {
|
||||
extend(formatter.localExports, t.getDeclarations(declar));
|
||||
extend(formatter.localExports, t.getBindingIdentifiers(declar));
|
||||
}
|
||||
|
||||
if (!node.default) {
|
||||
@@ -67,7 +67,7 @@ var importsVisitor = {
|
||||
enter: function (node, parent, scope, context, formatter) {
|
||||
if (t.isImportDeclaration(node)) {
|
||||
formatter.hasLocalImports = true;
|
||||
extend(formatter.localImports, t.getDeclarations(node));
|
||||
extend(formatter.localImports, t.getBindingIdentifiers(node));
|
||||
formatter.bumpImportOccurences(node);
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ DefaultFormatter.prototype.remapExportAssignment = function (node) {
|
||||
DefaultFormatter.prototype.isLocalReference = function (node, scope) {
|
||||
var localExports = this.localExports;
|
||||
var name = node.name;
|
||||
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.get(name, true);
|
||||
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.getBinding(name);
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.getModuleName = function () {
|
||||
@@ -171,12 +171,12 @@ DefaultFormatter.prototype.getModuleName = function () {
|
||||
|
||||
if (!opts.keepModuleIdExtensions) {
|
||||
// remove extension
|
||||
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
|
||||
filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
|
||||
}
|
||||
|
||||
moduleName += filenameRelative;
|
||||
|
||||
// normalise path separators
|
||||
// normalize path separators
|
||||
moduleName = moduleName.replace(/\\/g, "/");
|
||||
|
||||
return moduleName;
|
||||
@@ -212,6 +212,12 @@ DefaultFormatter.prototype.getExternalReference = function (node, nodes) {
|
||||
}
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.checkExportIdentifier = function (node) {
|
||||
if (t.isIdentifier(node, { name: "__esModule" })) {
|
||||
throw this.file.errorWithNode(node, "Illegal export __esModule - this is used internally for CommonJS interop");
|
||||
}
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
var inherits = false;
|
||||
if (node.specifiers.length === 1) inherits = node;
|
||||
@@ -224,7 +230,7 @@ DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
nodes.push(this.buildExportsWildcard(ref, node));
|
||||
} else {
|
||||
if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
|
||||
// importing a default so we need to normalise it
|
||||
// importing a default so we need to normalize it
|
||||
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
|
||||
} else {
|
||||
ref = t.memberExpression(ref, t.getSpecifierId(specifier));
|
||||
@@ -251,6 +257,7 @@ DefaultFormatter.prototype.buildExportsWildcard = function (objectIdentifier) {
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
|
||||
this.checkExportIdentifier(id);
|
||||
return util.template("exports-assign", {
|
||||
VALUE: init,
|
||||
KEY: id
|
||||
|
||||
5
lib/6to5/transformation/templates/class-call-check.js
Normal file
5
lib/6to5/transformation/templates/class-call-check.js
Normal file
@@ -0,0 +1,5 @@
|
||||
(function (instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
});
|
||||
@@ -1,3 +1,5 @@
|
||||
if (Object.getPrototypeOf(CLASS_NAME) !== null) {
|
||||
Object.getPrototypeOf(CLASS_NAME).apply(this, arguments);
|
||||
}
|
||||
(function (instance, Constructor) {
|
||||
if (Object.getPrototypeOf(Constructor) !== null) {
|
||||
Object.getPrototypeOf(Constructor).apply(instance, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,12 +20,12 @@ function Transformer(key, transformer, opts) {
|
||||
this.playground = !!transformer.playground;
|
||||
this.secondPass = !!transformer.secondPass;
|
||||
this.optional = !!transformer.optional;
|
||||
this.handlers = this.normalise(transformer);
|
||||
this.handlers = this.normalize(transformer);
|
||||
this.opts = opts || {};
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
Transformer.prototype.normalise = function (transformer) {
|
||||
Transformer.prototype.normalize = function (transformer) {
|
||||
var self = this;
|
||||
|
||||
if (isFunction(transformer)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
var defineMap = require("../../helpers/define-map");
|
||||
var t = require("../../../types");
|
||||
|
||||
exports.ObjectExpression = function (node) {
|
||||
var mutatorMap = {};
|
||||
@@ -10,7 +10,7 @@ exports.ObjectExpression = function (node) {
|
||||
node.properties = node.properties.filter(function (prop) {
|
||||
if (prop.kind === "get" || prop.kind === "set") {
|
||||
hasAny = true;
|
||||
util.pushMutatorMap(mutatorMap, prop.key, prop.kind, prop.computed, prop.value);
|
||||
defineMap.push(mutatorMap, prop.key, prop.kind, prop.computed, prop.value);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -21,6 +21,6 @@ exports.ObjectExpression = function (node) {
|
||||
|
||||
return t.callExpression(
|
||||
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
|
||||
[node, util.buildDefineProperties(mutatorMap)]
|
||||
[node, defineMap.build(mutatorMap)]
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ var visitor = {
|
||||
if (!declared) return;
|
||||
|
||||
// declared node is different in this scope
|
||||
if (scope.get(node.name, true) !== declared) return;
|
||||
if (scope.getBinding(node.name) !== declared) return;
|
||||
|
||||
var declaredLoc = declared.loc;
|
||||
var referenceLoc = node.loc;
|
||||
|
||||
@@ -29,7 +29,7 @@ var isVar = function (node, parent) {
|
||||
return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
|
||||
};
|
||||
|
||||
var standardiseLets = function (declars) {
|
||||
var standardizeLets = function (declars) {
|
||||
for (var i = 0; i < declars.length; i++) {
|
||||
delete declars[i]._let;
|
||||
}
|
||||
@@ -45,15 +45,15 @@ exports.Loop = function (node, parent, scope, context, file) {
|
||||
t.ensureBlock(node);
|
||||
node.body._letDeclarators = [init];
|
||||
}
|
||||
var letScoping = new LetScoping(node, node.body, parent, scope, file);
|
||||
letScoping.run();
|
||||
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
|
||||
blockScoping.run();
|
||||
};
|
||||
|
||||
exports.Program =
|
||||
exports.BlockStatement = function (block, parent, scope, context, file) {
|
||||
if (!t.isLoop(parent)) {
|
||||
var letScoping = new LetScoping(false, block, parent, scope, file);
|
||||
letScoping.run();
|
||||
var blockScoping = new BlockScoping(false, block, parent, scope, file);
|
||||
blockScoping.run();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ exports.BlockStatement = function (block, parent, scope, context, file) {
|
||||
* @param {File} file
|
||||
*/
|
||||
|
||||
function LetScoping(loopParent, block, parent, scope, file) {
|
||||
function BlockScoping(loopParent, block, parent, scope, file) {
|
||||
this.loopParent = loopParent;
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
@@ -84,7 +84,7 @@ function LetScoping(loopParent, block, parent, scope, file) {
|
||||
* Start the ball rolling.
|
||||
*/
|
||||
|
||||
LetScoping.prototype.run = function () {
|
||||
BlockScoping.prototype.run = function () {
|
||||
var block = this.block;
|
||||
if (block._letDone) return;
|
||||
block._letDone = true;
|
||||
@@ -110,11 +110,11 @@ function replace(node, parent, scope, context, remaps) {
|
||||
var remap = remaps[node.name];
|
||||
if (!remap) return;
|
||||
|
||||
var own = scope.get(node.name, true);
|
||||
if (own === remap.node) {
|
||||
var ownBinding = scope.getBinding(node.name);
|
||||
if (ownBinding === remap.binding) {
|
||||
node.name = remap.uid;
|
||||
} else {
|
||||
// scope already has it's own declaration that doesn't
|
||||
// scope already has it's own binding that doesn't
|
||||
// match the one we have a stored replacement for
|
||||
if (context) context.skip();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ function traverseReplace(node, parent, scope, remaps) {
|
||||
* Description
|
||||
*/
|
||||
|
||||
LetScoping.prototype.remap = function () {
|
||||
BlockScoping.prototype.remap = function () {
|
||||
var hasRemaps = false;
|
||||
var letRefs = this.letReferences;
|
||||
var scope = this.scope;
|
||||
@@ -149,13 +149,13 @@ LetScoping.prototype.remap = function () {
|
||||
// this is the defining identifier of a declaration
|
||||
var ref = letRefs[key];
|
||||
|
||||
if (scope.parentHas(key)) {
|
||||
if (scope.parentHasReference(key)) {
|
||||
var uid = scope.generateUidIdentifier(ref.name).name;
|
||||
ref.name = uid;
|
||||
|
||||
hasRemaps = true;
|
||||
remaps[key] = remaps[uid] = {
|
||||
node: ref,
|
||||
binding: ref,
|
||||
uid: uid
|
||||
};
|
||||
}
|
||||
@@ -179,7 +179,7 @@ LetScoping.prototype.remap = function () {
|
||||
* Description
|
||||
*/
|
||||
|
||||
LetScoping.prototype.needsClosure = function () {
|
||||
BlockScoping.prototype.needsClosure = function () {
|
||||
var block = this.block;
|
||||
|
||||
// if we're inside of a for loop then we search to see if there are any
|
||||
@@ -227,7 +227,7 @@ var letReferenceFunctionVisitor = {
|
||||
|
||||
// this scope has a variable with the same name so it couldn't belong
|
||||
// to our let scope
|
||||
if (scope.hasOwn(node.name, true)) return;
|
||||
if (scope.hasOwnBinding(node.name)) return;
|
||||
|
||||
// not a part of our scope
|
||||
if (!state.letReferences[node.name]) return;
|
||||
@@ -249,7 +249,7 @@ var letReferenceBlockVisitor = {
|
||||
* Description
|
||||
*/
|
||||
|
||||
LetScoping.prototype.getLetReferences = function () {
|
||||
BlockScoping.prototype.getLetReferences = function () {
|
||||
var block = this.block;
|
||||
|
||||
var declarators = block._letDeclarators || [];
|
||||
@@ -258,7 +258,7 @@ LetScoping.prototype.getLetReferences = function () {
|
||||
//
|
||||
for (var i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
extend(this.outsideLetReferences, t.getDeclarations(declar));
|
||||
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -274,7 +274,7 @@ LetScoping.prototype.getLetReferences = function () {
|
||||
//
|
||||
for (i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
var keys = t.getDeclarations(declar);
|
||||
var keys = t.getBindingIdentifiers(declar);
|
||||
extend(this.letReferences, keys);
|
||||
this.hasLetReferences = true;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ LetScoping.prototype.getLetReferences = function () {
|
||||
if (!this.hasLetReferences) return;
|
||||
|
||||
// set let references to plain var references
|
||||
standardiseLets(declarators);
|
||||
standardizeLets(declarators);
|
||||
|
||||
var state = {
|
||||
letReferences: this.letReferences,
|
||||
@@ -374,7 +374,7 @@ var loopLabelVisitor = {
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
LetScoping.prototype.checkLoop = function () {
|
||||
BlockScoping.prototype.checkLoop = function () {
|
||||
var state = {
|
||||
hasBreakContinue: false,
|
||||
ignoreLabeless: false,
|
||||
@@ -413,7 +413,7 @@ var hoistVarDeclarationsVisitor = {
|
||||
* once we wrap everything in a closure.
|
||||
*/
|
||||
|
||||
LetScoping.prototype.hoistVarDeclarations = function () {
|
||||
BlockScoping.prototype.hoistVarDeclarations = function () {
|
||||
traverse(this.block, hoistVarDeclarationsVisitor, this.scope, this);
|
||||
};
|
||||
|
||||
@@ -425,7 +425,7 @@ LetScoping.prototype.hoistVarDeclarations = function () {
|
||||
* @returns {Array}
|
||||
*/
|
||||
|
||||
LetScoping.prototype.pushDeclar = function (node) {
|
||||
BlockScoping.prototype.pushDeclar = function (node) {
|
||||
this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
|
||||
return t.variableDeclarator(declar.id);
|
||||
})));
|
||||
@@ -450,7 +450,7 @@ LetScoping.prototype.pushDeclar = function (node) {
|
||||
* @param {Node} call CallExpression
|
||||
*/
|
||||
|
||||
LetScoping.prototype.build = function (ret, call) {
|
||||
BlockScoping.prototype.build = function (ret, call) {
|
||||
var has = this.has;
|
||||
if (has.hasReturn || has.hasBreakContinue) {
|
||||
this.buildHas(ret, call);
|
||||
@@ -466,7 +466,7 @@ LetScoping.prototype.build = function (ret, call) {
|
||||
* @param {Node} call CallExpression
|
||||
*/
|
||||
|
||||
LetScoping.prototype.buildHas = function (ret, call) {
|
||||
BlockScoping.prototype.buildHas = function (ret, call) {
|
||||
var body = this.body;
|
||||
|
||||
body.push(t.variableDeclaration("var", [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
var ReplaceSupers = require("../../helpers/replace-supers");
|
||||
var nameMethod = require("../../helpers/name-method");
|
||||
var defineMap = require("../../helpers/define-map");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
|
||||
@@ -66,12 +67,19 @@ Class.prototype.run = function () {
|
||||
|
||||
var body = this.body = [];
|
||||
|
||||
var constructorBody = t.blockStatement([
|
||||
t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [
|
||||
t.thisExpression(),
|
||||
className
|
||||
]))
|
||||
]);
|
||||
var constructor;
|
||||
|
||||
if (this.node.id) {
|
||||
constructor = t.functionDeclaration(className, [], t.blockStatement([]));
|
||||
constructor = t.functionDeclaration(className, [], constructorBody);
|
||||
body.push(constructor);
|
||||
} else {
|
||||
constructor = t.functionExpression(null, [], t.blockStatement([]));
|
||||
constructor = t.functionExpression(null, [], constructorBody);
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(className, constructor)
|
||||
]));
|
||||
@@ -160,24 +168,31 @@ Class.prototype.buildBody = function () {
|
||||
|
||||
// we have no constructor, we have a super, and the super doesn't appear to be falsy
|
||||
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
|
||||
var defaultConstructorTemplate = "class-super-constructor-call";
|
||||
if (this.isLoose) defaultConstructorTemplate += "-loose";
|
||||
var helperName = "class-super-constructor-call";
|
||||
|
||||
constructor.body.body.push(util.template(defaultConstructorTemplate, {
|
||||
CLASS_NAME: className,
|
||||
SUPER_NAME: this.superName
|
||||
}, true));
|
||||
if (this.isLoose) {
|
||||
constructor.body.body.push(util.template(helperName + "-loose", {
|
||||
CLASS_NAME: className,
|
||||
SUPER_NAME: this.superName
|
||||
}, true));
|
||||
} else {
|
||||
constructor.body.body.push(
|
||||
t.expressionStatement(
|
||||
t.callExpression(this.file.addHelper(helperName), [t.thisExpression(), className])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var instanceProps;
|
||||
var staticProps;
|
||||
|
||||
if (this.hasInstanceMutators) {
|
||||
instanceProps = util.buildDefineProperties(this.instanceMutatorMap);
|
||||
instanceProps = defineMap.build(this.instanceMutatorMap);
|
||||
}
|
||||
|
||||
if (this.hasStaticMutators) {
|
||||
staticProps = util.buildDefineProperties(this.staticMutatorMap);
|
||||
staticProps = defineMap.build(this.staticMutatorMap);
|
||||
}
|
||||
|
||||
if (instanceProps || staticProps) {
|
||||
@@ -230,8 +245,8 @@ Class.prototype.pushMethod = function (node) {
|
||||
this.hasInstanceMutators = true;
|
||||
}
|
||||
|
||||
util.pushMutatorMap(mutatorMap, methodName, kind, node.computed, node);
|
||||
util.pushMutatorMap(mutatorMap, methodName, "enumerable", node.computed, false);
|
||||
defineMap.push(mutatorMap, methodName, kind, node.computed, node);
|
||||
defineMap.push(mutatorMap, methodName, "enumerable", node.computed, false);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -255,5 +270,5 @@ Class.prototype.pushConstructor = function (method) {
|
||||
|
||||
construct._ignoreUserWhitespace = true;
|
||||
construct.params = fn.params;
|
||||
construct.body = fn.body;
|
||||
construct.body.body = construct.body.body.concat(fn.body.body);
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@ var t = require("../../../types");
|
||||
|
||||
var visitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isDeclaration(node) || t.isAssignmentExpression(node)) {
|
||||
var ids = t.getDeclarations(node);
|
||||
if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {
|
||||
var ids = t.getBindingIdentifiers(node);
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
@@ -21,6 +21,9 @@ var visitor = {
|
||||
// constant so we can just ignore it
|
||||
if (id === constant) continue;
|
||||
|
||||
var localBinding = scope.getBinding(key);
|
||||
if (localBinding !== constant) continue;
|
||||
|
||||
throw state.file.errorWithNode(id, key + " is read-only");
|
||||
}
|
||||
} else if (t.isScope(node)) {
|
||||
|
||||
@@ -26,7 +26,7 @@ exports.ExportDeclaration = function (node, parent, scope, context, file) {
|
||||
var i;
|
||||
|
||||
if (node.declaration) {
|
||||
// make sure variable exports have an initialiser
|
||||
// make sure variable exports have an initializer
|
||||
// this is done here to avoid duplicating it in the module formatters
|
||||
if (t.isVariableDeclaration(node.declaration)) {
|
||||
var declar = node.declaration.declarations[0];
|
||||
|
||||
@@ -13,7 +13,7 @@ var hasDefaults = function (node) {
|
||||
|
||||
var iifeVisitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isReferencedIdentifier(node, parent) && state.scope.hasOwn(node.name)) {
|
||||
if (t.isReferencedIdentifier(node, parent) && state.scope.hasOwnReference(node.name)) {
|
||||
state.iife = true;
|
||||
context.stop();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ exports.Function = function (node, parent, scope) {
|
||||
node.params[i] = scope.generateUidIdentifier("x");
|
||||
|
||||
if (!state.iife) {
|
||||
if (t.isIdentifier(right) && scope.hasOwn(right.name)) {
|
||||
if (t.isIdentifier(right) && scope.hasOwnReference(right.name)) {
|
||||
state.iife = true;
|
||||
} else {
|
||||
traverse(right, iifeVisitor, scope, state);
|
||||
|
||||
@@ -58,7 +58,7 @@ var spec = function (node, body, objId, initProps, file) {
|
||||
var props = node.properties;
|
||||
var prop, key;
|
||||
|
||||
// normalise key
|
||||
// normalize key
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
prop = props[i];
|
||||
|
||||
@@ -12,7 +12,6 @@ module.exports = {
|
||||
"playground.objectGetterMemoization": require("./playground/object-getter-memoization"),
|
||||
|
||||
react: require("./other/react"),
|
||||
"optimisation.react": require("./optimisation/react"),
|
||||
|
||||
_modules: require("./internal/modules"),
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
module.exports = BaseOptimiser;
|
||||
|
||||
var object = require("../../../../helpers/object");
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
|
||||
function BaseOptimiser(node) {
|
||||
this.methods = object();
|
||||
this.types = object();
|
||||
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
|
||||
BaseOptimiser.prototype.run = function () {
|
||||
this.getMethods();
|
||||
this.getTypes();
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an `ObjectExpression` `node` that contains `propTypes`.
|
||||
*
|
||||
* Search it and match it against the types that we can optimise
|
||||
* and register it for consumption later.
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
|
||||
BaseOptimiser.prototype.addPropTypes = function (node) {
|
||||
var props = node.properties;
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
this.addPropType(props[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a `Property` node as a prop type.
|
||||
*
|
||||
* We'll try and resolve it to a known type if we can and normalise
|
||||
* it for consumption later.
|
||||
*
|
||||
* @param {Node} prop
|
||||
*/
|
||||
|
||||
BaseOptimiser.prototype.addPropType = function () {
|
||||
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
module.exports = CreateClassOptimiser;
|
||||
|
||||
var BaseOptimiser = require("./base");
|
||||
var util = require("../../../../util");
|
||||
var t = require("../../../../types");
|
||||
|
||||
function CreateClassOptimiser() {
|
||||
BaseOptimiser.apply(this, arguments);
|
||||
}
|
||||
|
||||
util.inherits(CreateClassOptimiser, BaseOptimiser);
|
||||
|
||||
/**
|
||||
* Get all function expressions.
|
||||
*/
|
||||
|
||||
CreateClassOptimiser.prototype.getMethods = function () {
|
||||
var props = this.node.properties;
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var prop = props[i];
|
||||
|
||||
// irrelevant
|
||||
if (!t.isFunctionExpression(prop.value)) continue;
|
||||
|
||||
// deopt
|
||||
if (prop.computed) continue;
|
||||
|
||||
this.methods[prop.key.name] = prop;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a `propTypes` property.
|
||||
*/
|
||||
|
||||
CreateClassOptimiser.prototype.getTypes = function () {
|
||||
var props = this.node.properties;
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var prop = props[i];
|
||||
var key = t.toComputedKey(prop, prop.key);
|
||||
|
||||
if (t.isLiteral(key, { value: "propTypes" }) && t.isObjectExpression(prop.value)) {
|
||||
this.addPropTypes(prop.value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
var CreateClassOptimiser = require("./create-class");
|
||||
var NativeClassOptimiser = require("./native-class");
|
||||
var react = require("../../../helpers/react");
|
||||
|
||||
exports.optional = true;
|
||||
|
||||
exports.CallExpression = function (node) {
|
||||
if (react.isCreateClass(node)) {
|
||||
new CreateClassOptimiser(node.arguments[0]).run();
|
||||
}
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node) {
|
||||
if (react.isReactComponent(node.superClass)) {
|
||||
new NativeClassOptimiser(node).run();
|
||||
}
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
module.exports = NativeClassOptimiser;
|
||||
|
||||
var BaseOptimiser = require("./base");
|
||||
var util = require("../../../../util");
|
||||
var t = require("../../../../types");
|
||||
|
||||
function NativeClassOptimiser() {
|
||||
BaseOptimiser.apply(this, arguments);
|
||||
}
|
||||
|
||||
util.inherits(NativeClassOptimiser, BaseOptimiser);
|
||||
|
||||
/**
|
||||
* Get all instance methods.
|
||||
*/
|
||||
|
||||
NativeClassOptimiser.prototype.getMethods = function () {
|
||||
var body = this.node.body;
|
||||
|
||||
for (var i = 0; i < body.length; i++) {
|
||||
var node = body[i];
|
||||
|
||||
// PrivateDeclaration etc
|
||||
if (!t.isMethodDefinition(node)) continue;
|
||||
|
||||
// deopt
|
||||
if (node.computed) continue;
|
||||
|
||||
// irrelevant
|
||||
if (node.static) continue;
|
||||
|
||||
this.methods[node.key.name] = node;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
|
||||
NativeClassOptimiser.prototype.getTypes = function () {
|
||||
|
||||
};
|
||||
@@ -171,11 +171,21 @@ exports.JSXElement = {
|
||||
var cleanJSXElementLiteralChild = function (child, args) {
|
||||
var lines = child.value.split(/\r\n|\n|\r/);
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var lastNonEmptyLine = 0;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
if (lines[i].match(/[^ \t]/)) {
|
||||
lastNonEmptyLine = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
var line = lines[i];
|
||||
|
||||
var isFirstLine = i === 0;
|
||||
var isLastLine = i === lines.length - 1;
|
||||
var isLastNonEmptyLine = i === lastNonEmptyLine;
|
||||
|
||||
// replace rendered whitespace tabs with spaces
|
||||
var trimmedLine = line.replace(/\t/g, " ");
|
||||
@@ -191,6 +201,10 @@ var cleanJSXElementLiteralChild = function (child, args) {
|
||||
}
|
||||
|
||||
if (trimmedLine) {
|
||||
if (!isLastNonEmptyLine) {
|
||||
trimmedLine += " ";
|
||||
}
|
||||
|
||||
args.push(t.literal(trimmedLine));
|
||||
}
|
||||
}
|
||||
@@ -199,8 +213,6 @@ var cleanJSXElementLiteralChild = function (child, args) {
|
||||
// display names
|
||||
|
||||
var addDisplayName = function (id, call) {
|
||||
if (!react.isCreateClass(call)) return;
|
||||
|
||||
var props = call.arguments[0].properties;
|
||||
var safe = true;
|
||||
|
||||
@@ -217,6 +229,12 @@ var addDisplayName = function (id, call) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.ExportDeclaration = function (node, parent, scope, context, file) {
|
||||
if (node.default && react.isCreateClass(node.declaration)) {
|
||||
addDisplayName(file.opts.basename, node.declaration);
|
||||
}
|
||||
};
|
||||
|
||||
exports.AssignmentExpression =
|
||||
exports.Property =
|
||||
exports.VariableDeclarator = function (node) {
|
||||
@@ -237,7 +255,7 @@ exports.VariableDeclarator = function (node) {
|
||||
left = left.property;
|
||||
}
|
||||
|
||||
if (t.isIdentifier(left)) {
|
||||
if (t.isIdentifier(left) && react.isCreateClass(right)) {
|
||||
addDisplayName(left.name, right);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ var astVisitor = {
|
||||
context.skip();
|
||||
return t.prependToMemberExpression(node, file.get("coreIdentifier"));
|
||||
}
|
||||
} else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && contains(ALIASABLE_CONSTRUCTORS, node.name) && !scope.get(node.name, true)) {
|
||||
} else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && contains(ALIASABLE_CONSTRUCTORS, node.name) && !scope.getBinding(node.name)) {
|
||||
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
|
||||
return t.memberExpression(file.get("coreIdentifier"), node);
|
||||
} else if (t.isCallExpression(node)) {
|
||||
|
||||
@@ -7,19 +7,19 @@ exports.optional = true;
|
||||
|
||||
exports.Identifier = function (node, parent, scope, context, file) {
|
||||
if (!t.isReferenced(node, parent)) return;
|
||||
if (scope.has(node.name, true)) return;
|
||||
if (scope.hasBinding(node.name)) return;
|
||||
|
||||
var msg = "Reference to undeclared variable";
|
||||
|
||||
// get the closest declaration to offer as a suggestion
|
||||
// the variable name may have just been mistyped
|
||||
|
||||
var declarations = scope.getAllDeclarations();
|
||||
var bindings = scope.getAllBindings();
|
||||
|
||||
var closest;
|
||||
var shortest = -1;
|
||||
|
||||
for (var name in declarations) {
|
||||
for (var name in bindings) {
|
||||
var distance = levenshtein(node.name, name);
|
||||
if (distance <= 0 || distance > 3) continue;
|
||||
if (distance <= shortest) continue;
|
||||
|
||||
@@ -2,20 +2,19 @@
|
||||
|
||||
module.exports = Scope;
|
||||
|
||||
var contains = require("lodash/collection/contains");
|
||||
var traverse = require("./index");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
var globals = require("globals");
|
||||
var flatten = require("lodash/array/flatten");
|
||||
var extend = require("lodash/object/extend");
|
||||
var object = require("../helpers/object");
|
||||
var t = require("../types");
|
||||
var each = require("lodash/collection/each");
|
||||
var has = require("lodash/object/has");
|
||||
var contains = require("lodash/collection/contains");
|
||||
var flatten = require("lodash/array/flatten");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
|
||||
var FOR_KEYS = ["left", "init"];
|
||||
var t = require("../types");
|
||||
|
||||
/**
|
||||
* This searches the current "scope" and collects all references/declarations
|
||||
* This searches the current "scope" and collects all references/bindings
|
||||
* within.
|
||||
*
|
||||
* @param {Node} block
|
||||
@@ -31,30 +30,11 @@ function Scope(block, parentBlock, parent, file) {
|
||||
this.parentBlock = parentBlock;
|
||||
this.block = block;
|
||||
|
||||
var info = this.getInfo();
|
||||
this.references = info.references;
|
||||
this.declarations = info.declarations;
|
||||
this.declarationKinds = info.declarationKinds;
|
||||
this.crawl();
|
||||
}
|
||||
|
||||
Scope.defaultDeclarations = flatten([globals.builtin, globals.browser, globals.node].map(Object.keys));
|
||||
|
||||
Scope.prototype._add = function (node, references, throwOnDuplicate) {
|
||||
if (!node) return;
|
||||
|
||||
var ids = t.getDeclarations(node);
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
|
||||
if (throwOnDuplicate && references[key]) {
|
||||
throw this.file.errorWithNode(id, "Duplicate declaration", TypeError);
|
||||
}
|
||||
|
||||
references[key] = id;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
@@ -130,7 +110,7 @@ Scope.prototype.generateUidBasedOnNode = function (parent) {
|
||||
*/
|
||||
|
||||
Scope.prototype.generateTempBasedOnNode = function (node) {
|
||||
if (t.isIdentifier(node) && this.has(node.name, true)) {
|
||||
if (t.isIdentifier(node) && this.hasBinding(node.name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,12 +122,91 @@ Scope.prototype.generateTempBasedOnNode = function (node) {
|
||||
return id;
|
||||
};
|
||||
|
||||
Scope.prototype.checkBlockScopedCollisions = function (key, id) {
|
||||
if (this.declarationKinds["let"][key] || this.declarationKinds["const"][key]) {
|
||||
throw this.file.errorWithNode(id, "Duplicate declaration " + key, TypeError);
|
||||
}
|
||||
};
|
||||
|
||||
Scope.prototype.inferType = function (node) {
|
||||
var target;
|
||||
|
||||
if (t.isVariableDeclarator(node)) {
|
||||
target = node.init;
|
||||
}
|
||||
|
||||
if (t.isArrayExpression(target) || t.isObjectExpression(target)) {
|
||||
// todo: possibly call some helper that will resolve these to a type annotation
|
||||
}
|
||||
|
||||
if (t.isCallExpression(target)) {
|
||||
target = target.callee;
|
||||
}
|
||||
|
||||
if (t.isMemberExpression(target)) {
|
||||
// todo: crawl this and find the correct type, bail on anything that we cannot
|
||||
// possibly be 100% confident on
|
||||
}
|
||||
|
||||
if (t.isIdentifier(target)) {
|
||||
return this.getType(target.name);
|
||||
}
|
||||
};
|
||||
|
||||
Scope.prototype.registerType = function (key, id, node) {
|
||||
var type;
|
||||
|
||||
if (id.typeAnnotation) {
|
||||
type = id.typeAnnotation;
|
||||
}
|
||||
|
||||
if (!type) {
|
||||
type = this.inferType(node);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
|
||||
this.types[key] = type;
|
||||
}
|
||||
};
|
||||
|
||||
Scope.prototype.register = function (node, reference, kind) {
|
||||
if (t.isVariableDeclaration(node)) {
|
||||
return this.registerVariableDeclaration(node);
|
||||
}
|
||||
|
||||
var ids = t.getBindingIdentifiers(node);
|
||||
|
||||
extend(this.references, ids);
|
||||
|
||||
if (reference) return;
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
|
||||
this.checkBlockScopedCollisions(key, id);
|
||||
|
||||
this.registerType(key, id, node);
|
||||
this.bindings[key] = id;
|
||||
}
|
||||
|
||||
var kinds = this.declarationKinds[kind];
|
||||
if (kinds) extend(kinds, ids);
|
||||
};
|
||||
|
||||
Scope.prototype.registerVariableDeclaration = function (declar) {
|
||||
var declars = declar.declarations;
|
||||
for (var i = 0; i < declars.length; i++) {
|
||||
this.register(declars[i], false, declar.kind);
|
||||
}
|
||||
};
|
||||
|
||||
var functionVariableVisitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isFor(node)) {
|
||||
each(FOR_KEYS, function (key) {
|
||||
each(t.FOR_INIT_KEYS, function (key) {
|
||||
var declar = node[key];
|
||||
if (t.isVar(declar)) state.add(declar);
|
||||
if (t.isVar(declar)) state.scope.register(declar);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,64 +217,76 @@ var functionVariableVisitor = {
|
||||
// function identifier doesn't belong to this scope
|
||||
if (state.blockId && node === state.blockId) return;
|
||||
|
||||
// delegate block scope handling to the `blockVariableVisitor`
|
||||
if (t.isBlockScoped(node)) return;
|
||||
|
||||
// this will be hit again once we traverse into it after this iteration
|
||||
if (t.isExportDeclaration(node) && t.isDeclaration(node.declaration)) return;
|
||||
|
||||
// we've ran into a declaration!
|
||||
// we'll let the BlockStatement scope deal with `let` declarations unless
|
||||
if (t.isDeclaration(node) && !t.isBlockScoped(node)) {
|
||||
state.add(node);
|
||||
}
|
||||
if (t.isDeclaration(node)) state.scope.register(node);
|
||||
}
|
||||
};
|
||||
|
||||
var programReferenceVisitor = {
|
||||
enter: function (node, parent, scope, context, add) {
|
||||
if (t.isReferencedIdentifier(node, parent) && !scope.has(node.name)) {
|
||||
add(node, true);
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isReferencedIdentifier(node, parent) && !scope.hasReference(node.name)) {
|
||||
state.register(node, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var blockVariableVisitor = {
|
||||
enter: function (node, parent, scope, context, add) {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isBlockScoped(node)) {
|
||||
add(node, false, t.isLet(node));
|
||||
state.register(node);
|
||||
} else if (t.isScope(node)) {
|
||||
context.skip();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Scope.prototype.getInfo = function () {
|
||||
Scope.prototype.crawl = function () {
|
||||
var parent = this.parent;
|
||||
var block = this.block;
|
||||
var self = this;
|
||||
if (block._scopeInfo) return block._scopeInfo;
|
||||
var i;
|
||||
|
||||
var info = block._scopeInfo = {};
|
||||
var references = info.references = object();
|
||||
var declarations = info.declarations = object();
|
||||
var declarationKinds = info.declarationKinds = {};
|
||||
//
|
||||
|
||||
var add = function (node, reference, throwOnDuplicate) {
|
||||
self._add(node, references);
|
||||
var info = block._scopeInfo;
|
||||
if (info) {
|
||||
extend(this, info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reference) {
|
||||
self._add(node, declarations, throwOnDuplicate);
|
||||
self._add(node, declarationKinds[node.kind] = declarationKinds[node.kind] || object());
|
||||
}
|
||||
info = block._scopeInfo = {
|
||||
declarationKinds: {
|
||||
"const": object(),
|
||||
"var": object(),
|
||||
"let": object()
|
||||
},
|
||||
|
||||
references: object(),
|
||||
bindings: object(),
|
||||
types: object(),
|
||||
};
|
||||
|
||||
if (parent && t.isBlockStatement(block) && t.isFor(parent.block, { body: block })) {
|
||||
// delegate block let declarations to the parent loop
|
||||
return info;
|
||||
extend(this, info);
|
||||
|
||||
//
|
||||
|
||||
if (parent && t.isBlockStatement(block) && t.isLoop(parent.block, { body: block })) {
|
||||
// delegate let bindings to the parent loop
|
||||
return;
|
||||
}
|
||||
|
||||
// ForStatement - left, init
|
||||
|
||||
if (t.isFor(block)) {
|
||||
each(FOR_KEYS, function (key) {
|
||||
var node = block[key];
|
||||
if (t.isBlockScoped(node)) add(node, false, true);
|
||||
});
|
||||
if (t.isLoop(block)) {
|
||||
for (i = 0; i < t.FOR_INIT_KEYS.length; i++) {
|
||||
var node = block[t.FOR_INIT_KEYS[i]];
|
||||
if (t.isBlockScoped(node)) this.register(node, false, true);
|
||||
}
|
||||
|
||||
if (t.isBlockStatement(block.body)) {
|
||||
block = block.body;
|
||||
@@ -225,19 +296,27 @@ Scope.prototype.getInfo = function () {
|
||||
// Program, BlockStatement - let variables
|
||||
|
||||
if (t.isBlockStatement(block) || t.isProgram(block)) {
|
||||
traverse(block, blockVariableVisitor, this, add);
|
||||
traverse(block, blockVariableVisitor, this, this);
|
||||
}
|
||||
|
||||
// CatchClause - param
|
||||
|
||||
if (t.isCatchClause(block)) {
|
||||
add(block.param);
|
||||
this.register(block.param);
|
||||
}
|
||||
|
||||
// ComprehensionExpression - blocks
|
||||
|
||||
if (t.isComprehensionExpression(block)) {
|
||||
add(block);
|
||||
this.register(block);
|
||||
}
|
||||
|
||||
// Function - params, rest
|
||||
|
||||
if (t.isFunction(block)) {
|
||||
for (i = 0; i < block.params.length; i++) {
|
||||
this.register(block.params[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Program, Function - var variables
|
||||
@@ -245,7 +324,7 @@ Scope.prototype.getInfo = function () {
|
||||
if (t.isProgram(block) || t.isFunction(block)) {
|
||||
traverse(block, functionVariableVisitor, this, {
|
||||
blockId: block.id,
|
||||
add: add
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
|
||||
@@ -253,25 +332,15 @@ Scope.prototype.getInfo = function () {
|
||||
if (!t.isProperty(this.parentBlock, { method: true })) {
|
||||
// SpiderMonkey AST doesn't use MethodDefinition here when it probably
|
||||
// should since they should be semantically the same?
|
||||
add(block.id);
|
||||
this.register(block.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Program
|
||||
|
||||
if (t.isProgram(block)) {
|
||||
traverse(block, programReferenceVisitor, this, add);
|
||||
traverse(block, programReferenceVisitor, this, this);
|
||||
}
|
||||
|
||||
// Function - params, rest
|
||||
|
||||
if (t.isFunction(block)) {
|
||||
each(block.params, function (param) {
|
||||
add(param);
|
||||
});
|
||||
}
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -304,12 +373,20 @@ Scope.prototype.push = function (opts) {
|
||||
* Walk up the scope tree until we hit a `Function` and then
|
||||
* push our `node` to it's references.
|
||||
*
|
||||
* @param {String} kind
|
||||
* @param {Object} node
|
||||
*/
|
||||
|
||||
Scope.prototype.add = function (node) {
|
||||
Scope.prototype.addDeclarationToFunctionScope = function (kind, node) {
|
||||
var scope = this.getFunctionParent();
|
||||
scope._add(node, scope.references);
|
||||
var ids = t.getBindingIdentifiers(node);
|
||||
|
||||
extend(scope.bindings, ids);
|
||||
extend(scope.references, ids);
|
||||
|
||||
// this ignores the duplicate declaration logic specified in `getInfo`
|
||||
// but it doesn't really matter
|
||||
extend(scope.declarationKinds[kind], ids);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -326,17 +403,17 @@ Scope.prototype.getFunctionParent = function () {
|
||||
};
|
||||
|
||||
/**
|
||||
* Walks the scope tree and gathers **all** declarations.
|
||||
* Walks the scope tree and gathers **all** bindings.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Scope.prototype.getAllDeclarations = function () {
|
||||
Scope.prototype.getAllBindings = function () {
|
||||
var ids = object();
|
||||
|
||||
var scope = this;
|
||||
do {
|
||||
defaults(ids, scope.declarations);
|
||||
defaults(ids, scope.bindings);
|
||||
scope = scope.parent;
|
||||
} while (scope);
|
||||
|
||||
@@ -362,77 +439,56 @@ Scope.prototype.getAllDeclarationsOfKind = function (kind) {
|
||||
return ids;
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
*/
|
||||
//
|
||||
|
||||
Scope.prototype.get = function (id, decl) {
|
||||
return id && (this.getOwn(id, decl) || this.parentGet(id, decl));
|
||||
Scope.prototype.get = function (id, type) {
|
||||
return id && (this.getOwn(id, type) || this.parentGet(id, type));
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
*/
|
||||
|
||||
Scope.prototype.getOwn = function (id, decl) {
|
||||
var refs = this.references;
|
||||
if (decl) refs = this.declarations;
|
||||
return has(refs, id) && refs[id];
|
||||
Scope.prototype.getOwn = function (id, type) {
|
||||
var refs = {
|
||||
reference: this.references,
|
||||
binding: this.bindings,
|
||||
type: this.types
|
||||
}[type];
|
||||
return refs && has(refs, id) && refs[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
*/
|
||||
|
||||
Scope.prototype.parentGet = function (id, decl) {
|
||||
return this.parent && this.parent.get(id, decl);
|
||||
Scope.prototype.parentGet = function (id, type) {
|
||||
return this.parent && this.parent.get(id, type);
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
Scope.prototype.has = function (id, decl) {
|
||||
Scope.prototype.has = function (id, type) {
|
||||
if (!id) return false;
|
||||
if (this.hasOwn(id, decl)) return true;
|
||||
if (this.parentHas(id, decl)) return true;
|
||||
if (this.hasOwn(id, type)) return true;
|
||||
if (this.parentHas(id, type)) return true;
|
||||
if (contains(Scope.defaultDeclarations, id)) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
Scope.prototype.hasOwn = function (id, decl) {
|
||||
return !!this.getOwn(id, decl);
|
||||
Scope.prototype.hasOwn = function (id, type) {
|
||||
return !!this.getOwn(id, type);
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {String} [id]
|
||||
* @param {Boolean} [decl]
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
Scope.prototype.parentHas = function (id, decl) {
|
||||
return this.parent && this.parent.has(id, decl);
|
||||
Scope.prototype.parentHas = function (id, type) {
|
||||
return this.parent && this.parent.has(id, type);
|
||||
};
|
||||
|
||||
each({
|
||||
reference: "Reference",
|
||||
binding: "Binding",
|
||||
type: "Type"
|
||||
}, function (title, type) {
|
||||
each([
|
||||
"get",
|
||||
"has",
|
||||
"getOwn",
|
||||
"hasOwn",
|
||||
"parentGet",
|
||||
"parentHas",
|
||||
], function (methodName) {
|
||||
Scope.prototype[methodName + title] = function (id) {
|
||||
return this[methodName](id, type);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"BreakStatement": ["Statement"],
|
||||
"ContinueStatement": ["Statement"],
|
||||
"DebuggerStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement", "Loop", "While"],
|
||||
"DoWhileStatement": ["Statement", "Loop", "While", "Scope"],
|
||||
"IfStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement"],
|
||||
"SwitchStatement": ["Statement"],
|
||||
"ThrowStatement": ["Statement"],
|
||||
"TryStatement": ["Statement"],
|
||||
"WhileStatement": ["Statement", "Loop", "While"],
|
||||
"WhileStatement": ["Statement", "Loop", "While", "Scope"],
|
||||
"WithStatement": ["Statement"],
|
||||
"EmptyStatement": ["Statement"],
|
||||
"LabeledStatement": ["Statement"],
|
||||
|
||||
@@ -34,11 +34,11 @@ function registerType(type, skipAliasCheck) {
|
||||
}
|
||||
|
||||
t.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body"];
|
||||
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
|
||||
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
|
||||
t.FOR_INIT_KEYS = ["left", "init"];
|
||||
|
||||
t.VISITOR_KEYS = require("./visitor-keys");
|
||||
|
||||
t.ALIAS_KEYS = require("./alias-keys");
|
||||
t.ALIAS_KEYS = require("./alias-keys");
|
||||
|
||||
t.FLIPPED_ALIAS_KEYS = {};
|
||||
|
||||
@@ -560,17 +560,14 @@ t.toBlock = function (node, parent) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a list of identifiers that will be assigned
|
||||
* as a result of runtime evaluation.
|
||||
*
|
||||
* If an identifier is passed as `node` instead of a
|
||||
* declaration then it's assumed to be an assignable.
|
||||
* Return a list of binding identifiers associated with
|
||||
* the input `node`.
|
||||
*
|
||||
* @param {Object} node
|
||||
* @returns {Array|Object}
|
||||
*/
|
||||
|
||||
t.getDeclarations = function (node) {
|
||||
t.getBindingIdentifiers = function (node) {
|
||||
var search = [].concat(node);
|
||||
var ids = object();
|
||||
|
||||
@@ -578,7 +575,7 @@ t.getDeclarations = function (node) {
|
||||
var id = search.shift();
|
||||
if (!id) continue;
|
||||
|
||||
var keys = t.getDeclarations.keys[id.type];
|
||||
var keys = t.getBindingIdentifiers.keys[id.type];
|
||||
|
||||
if (t.isIdentifier(id)) {
|
||||
ids[id.name] = id;
|
||||
@@ -597,7 +594,7 @@ t.getDeclarations = function (node) {
|
||||
return ids;
|
||||
};
|
||||
|
||||
t.getDeclarations.keys = {
|
||||
t.getBindingIdentifiers.keys = {
|
||||
AssignmentExpression: ["left"],
|
||||
ImportBatchSpecifier: ["name"],
|
||||
ImportSpecifier: ["name", "id"],
|
||||
@@ -608,6 +605,7 @@ t.getDeclarations.keys = {
|
||||
MemeberExpression: ["object"],
|
||||
SpreadElement: ["argument"],
|
||||
RestElement: ["argument"],
|
||||
UpdateExpression: ["argument"],
|
||||
Property: ["value"],
|
||||
ComprehensionBlock: ["left"],
|
||||
AssignmentPattern: ["left"],
|
||||
@@ -638,7 +636,7 @@ t.isLet = function (node) {
|
||||
*/
|
||||
|
||||
t.isBlockScoped = function (node) {
|
||||
return t.isFunctionDeclaration(node) || t.isLet(node);
|
||||
return t.isFunctionDeclaration(node) || t.isClassDeclaration(node) || t.isLet(node);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ var isNumber = require("lodash/lang/isNumber");
|
||||
var isString = require("lodash/lang/isString");
|
||||
var isRegExp = require("lodash/lang/isRegExp");
|
||||
var isEmpty = require("lodash/lang/isEmpty");
|
||||
var clone = require("lodash/lang/clone");
|
||||
var cloneDeep = require("lodash/lang/cloneDeep");
|
||||
var has = require("lodash/object/has");
|
||||
var contains = require("lodash/collection/contains");
|
||||
@@ -81,73 +80,6 @@ exports.sourceMapToComment = function (map) {
|
||||
return "//# sourceMappingURL=data:application/json;base64," + base64;
|
||||
};
|
||||
|
||||
exports.pushMutatorMap = function (mutatorMap, key, kind, computed, value) {
|
||||
var alias;
|
||||
|
||||
if (t.isIdentifier(key)) {
|
||||
alias = key.name;
|
||||
if (computed) alias = "computed:" + alias;
|
||||
} else if (t.isLiteral(key)) {
|
||||
alias = String(key.value);
|
||||
} else {
|
||||
alias = JSON.stringify(traverse.removeProperties(cloneDeep(key)));
|
||||
}
|
||||
|
||||
var map;
|
||||
if (has(mutatorMap, alias)) {
|
||||
map = mutatorMap[alias];
|
||||
} else {
|
||||
map = {};
|
||||
}
|
||||
mutatorMap[alias] = map;
|
||||
|
||||
map._key = key;
|
||||
if (computed) {
|
||||
map._computed = true;
|
||||
}
|
||||
|
||||
map[kind] = value;
|
||||
};
|
||||
|
||||
exports.buildDefineProperties = function (mutatorMap) {
|
||||
var objExpr = t.objectExpression([]);
|
||||
|
||||
each(mutatorMap, function (map) {
|
||||
var mapNode = t.objectExpression([]);
|
||||
|
||||
var propNode = t.property("init", map._key, mapNode, map._computed);
|
||||
|
||||
if (!map.get && !map.set) {
|
||||
map.writable = t.literal(true);
|
||||
}
|
||||
|
||||
if (map.enumerable === false) {
|
||||
delete map.enumerable;
|
||||
} else {
|
||||
map.enumerable = t.literal(true);
|
||||
}
|
||||
|
||||
map.configurable = t.literal(true);
|
||||
|
||||
each(map, function (node, key) {
|
||||
if (key[0] === "_") return;
|
||||
|
||||
node = clone(node);
|
||||
var inheritNode = node;
|
||||
if (t.isMethodDefinition(node)) node = node.value;
|
||||
|
||||
var prop = t.property("init", t.identifier(key), node);
|
||||
t.inheritsComments(prop, inheritNode);
|
||||
t.removeComments(inheritNode);
|
||||
mapNode.properties.push(prop);
|
||||
});
|
||||
|
||||
objExpr.properties.push(propNode);
|
||||
});
|
||||
|
||||
return objExpr;
|
||||
};
|
||||
|
||||
var templateVisitor = {
|
||||
enter: function (node, parent, scope, context, nodes) {
|
||||
if (t.isIdentifier(node) && has(nodes, node.name)) {
|
||||
@@ -191,7 +123,7 @@ exports.repeat = function (width, cha) {
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.normaliseAst = function (ast, comments, tokens) {
|
||||
exports.normalizeAst = function (ast, comments, tokens) {
|
||||
if (ast && ast.type === "Program") {
|
||||
return t.file(ast, comments || [], tokens || []);
|
||||
} else {
|
||||
@@ -218,7 +150,7 @@ exports.parse = function (opts, code, callback) {
|
||||
|
||||
estraverse.attachComments(ast, comments, tokens);
|
||||
|
||||
ast = exports.normaliseAst(ast, comments, tokens);
|
||||
ast = exports.normalizeAst(ast, comments, tokens);
|
||||
|
||||
if (callback) {
|
||||
return callback(ast);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "3.3.3",
|
||||
"version": "3.3.7",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://6to5.org/",
|
||||
"repository": "6to5/6to5",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5-runtime",
|
||||
"description": "6to5 selfContained runtime",
|
||||
"version": "3.3.2",
|
||||
"version": "3.3.5",
|
||||
"repository": "6to5/6to5",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
@@ -3,7 +3,7 @@ var path = require("path");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
var humanise = function (val, noext) {
|
||||
var humanize = function (val, noext) {
|
||||
if (noext) val = path.basename(val, path.extname(val));
|
||||
return val.replace(/-/g, " ");
|
||||
};
|
||||
@@ -37,7 +37,7 @@ exports.get = function (entryName, entryLoc) {
|
||||
var suite = {
|
||||
options: {},
|
||||
tests: [],
|
||||
title: humanise(suiteName),
|
||||
title: humanize(suiteName),
|
||||
filename: entryLoc + "/" + suiteName
|
||||
};
|
||||
suites.push(suite);
|
||||
@@ -83,7 +83,7 @@ exports.get = function (entryName, entryLoc) {
|
||||
if (taskOptsLoc) _.merge(taskOpts, require(taskOptsLoc));
|
||||
|
||||
var test = {
|
||||
title: humanise(taskName, true),
|
||||
title: humanize(taskName, true),
|
||||
disabled: taskName[0] === ".",
|
||||
options: taskOpts,
|
||||
exec: {
|
||||
|
||||
@@ -114,10 +114,10 @@ var run = function (task, done) {
|
||||
var consumer = new sourceMap.SourceMapConsumer(result.map);
|
||||
|
||||
_.each(task.sourceMappings, function (mapping, i) {
|
||||
var expect = mapping.original;
|
||||
var actual = mapping.original;
|
||||
|
||||
var actual = consumer.originalPositionFor(mapping.generated);
|
||||
chai.expect({ line: actual.line, column: actual.column }).to.deep.equal(expect);
|
||||
var expect = consumer.originalPositionFor(mapping.generated);
|
||||
chai.expect({ line: expect.line, column: expect.column }).to.deep.equal(actual);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0lBQU0sSUFBSSxZQUFKLElBQUkiLCJmaWxlIjoic3JjL2Jhci9iYXIuanMiLCJzb3VyY2VzQ29udGVudCI6WyJjbGFzcyBUZXN0IHtcblxufSJdfQ==
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7SUFBTSxnQkFBQTt3QkFBQSIsImZpbGUiOiJzcmMvYmFyL2Jhci5qcyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59Il19
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9mb28uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxHQUFHLENBQUMsR0FBRyxDQUFDLFVBQUEsQ0FBQztTQUFJLENBQUMsR0FBRyxVQUFVO0NBQUEsQ0FBQyxDQUFDIiwiZmlsZSI6InNyYy9mb28uanMiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9mb28uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxJQUFJLElBQUksVUFBQTtTQUFLLElBQUkiLCJmaWxlIjoic3JjL2Zvby5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
//# sourceMappingURL=bar.js.map
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["src/bar/bar.js"],"names":[],"mappings":";;IAAM,IAAI,YAAJ,IAAI","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}
|
||||
{"version":3,"sources":["src/bar/bar.js"],"names":[],"mappings":";;;;IAAM,gBAAA;wBAAA","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["src/foo.js"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,UAAU;CAAA,CAAC,CAAC","file":"src/foo.js","sourcesContent":["arr.map(x => x * MULTIPLIER);"]}
|
||||
{"version":3,"sources":["src/foo.js"],"names":[],"mappings":";;AAAA,IAAI,IAAI,UAAA;SAAK,IAAI","file":"src/foo.js","sourcesContent":["arr.map(x => x * MULTIPLIER);"]}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
|
||||
@@ -4,4 +4,4 @@ arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLEdBQUcsQ0FBQyxHQUFHLENBQUMsVUFBQSxDQUFDO1NBQUksQ0FBQyxHQUFHLFVBQVU7Q0FBQSxDQUFDLENBQUMiLCJmaWxlIjoic2NyaXB0Mi5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLElBQUksSUFBSSxVQUFBO1NBQUssSUFBSSIsImZpbGUiOiJzY3JpcHQyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFBTSxJQUFJLFlBQUosSUFBSTs7OztBQ0FWLEdBQUcsQ0FBQyxHQUFHLENBQUMsVUFBQSxDQUFDO1NBQUksQ0FBQyxHQUFHLFVBQVU7Q0FBQSxDQUFDLENBQUMiLCJmaWxlIjoic2NyaXB0My5qcyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59IiwiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztJQUFNLGdCQUFBO3dCQUFBOzs7OztBQ0FOLElBQUksSUFBSSxVQUFBO1NBQUssSUFBSSIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;IAAM,IAAI,YAAJ,IAAI;;;;ACAV,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,UAAU;CAAA,CAAC,CAAC","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;;;IAAM,gBAAA;wBAAA;;;;;ACAN,IAAI,IAAI,UAAA;SAAK,IAAI","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,CAAC;CAAA,CAAC,CAAC","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
|
||||
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,IAAI,IAAI,UAAA;SAAK,IAAI","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
|
||||
|
||||
@@ -4,4 +4,4 @@ arr.map(function (x) {
|
||||
return x * x;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBRyxDQUFDLEdBQUcsQ0FBQyxVQUFBLENBQUM7U0FBSSxDQUFDLEdBQUcsQ0FBQztDQUFBLENBQUMsQ0FBQyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIHgpOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBSSxJQUFJLFVBQUE7U0FBSyxJQUFJIiwiZmlsZSI6InN0ZG91dCIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogeCk7Il19
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
arr.map(x => x * x);
|
||||
};
|
||||
};
|
||||
@@ -4,8 +4,12 @@ var _asyncToGenerator = function (fn) { return function () { var gen = fn.apply(
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {}
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
_prototypeProperties(Foo, null, {
|
||||
foo: {
|
||||
|
||||
@@ -4,8 +4,12 @@ var _bluebird = require("bluebird");
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {}
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
_prototypeProperties(Foo, null, {
|
||||
foo: {
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
var _slice = Array.prototype.slice;
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
var _Foo$prototype$test, _Foo$prototype$test2;
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
woops["super"].test();
|
||||
Foo.call(this);
|
||||
Foo.prototype.test.call(this);
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
Foo.prototype.test;
|
||||
Foo.prototype.test.whatever;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
Foo.prototype.test.whatever();
|
||||
Foo.prototype.test.call(this);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
function BaseController() {
|
||||
_classCallCheck(this, BaseController);
|
||||
|
||||
if (_Chaplin$Controller != null) {
|
||||
_Chaplin$Controller.apply(this, arguments);
|
||||
}
|
||||
@@ -16,6 +20,8 @@ var BaseController = (function (_Chaplin$Controller) {
|
||||
|
||||
var BaseController2 = (function (_Chaplin$Controller$Another) {
|
||||
function BaseController2() {
|
||||
_classCallCheck(this, BaseController2);
|
||||
|
||||
if (_Chaplin$Controller$Another != null) {
|
||||
_Chaplin$Controller$Another.apply(this, arguments);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
if (Foo != null) {
|
||||
Foo.apply(this, arguments);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
Function.prototype.hasOwnProperty.call(this, "test");
|
||||
};
|
||||
};
|
||||
@@ -7,9 +7,13 @@ var _get = function get(object, property, receiver) { var desc = Object.getOwnPr
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
var _get2, _get3;
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
woops["super"].test();
|
||||
_get(Object.getPrototypeOf(Test.prototype), "constructor", this).call(this);
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
|
||||
|
||||
@@ -4,8 +4,12 @@ var _get = function get(object, property, receiver) { var desc = Object.getOwnPr
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this);
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ var _get = function get(object, property, receiver) { var desc = Object.getOwnPr
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever();
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,18 @@
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
var Foo = (function (Bar) {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
|
||||
this.state = "test";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {}
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
_prototypeProperties(Test, null, {
|
||||
test: {
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {}
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
_prototypeProperties(Test, null, {
|
||||
test: {
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {}
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
_prototypeProperties(Test, null, {
|
||||
test: {
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {}
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
_prototypeProperties(Test, null, {
|
||||
test: {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
@@ -2,16 +2,24 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var BaseView = function BaseView() {
|
||||
_classCallCheck(this, BaseView);
|
||||
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
var BaseView = function BaseView() {
|
||||
_classCallCheck(this, BaseView);
|
||||
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
var BaseView = (function () {
|
||||
function BaseView() {}
|
||||
function BaseView() {
|
||||
_classCallCheck(this, BaseView);
|
||||
}
|
||||
|
||||
_prototypeProperties(BaseView, null, {
|
||||
foo: {
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var A = (function () {
|
||||
function A() {}
|
||||
function A() {
|
||||
_classCallCheck(this, A);
|
||||
}
|
||||
|
||||
_prototypeProperties(A, {
|
||||
a: {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
function BaseController() {
|
||||
if (Object.getPrototypeOf(BaseController) !== null) {
|
||||
Object.getPrototypeOf(BaseController).apply(this, arguments);
|
||||
}
|
||||
_classCallCheck(this, BaseController);
|
||||
|
||||
_classSuperConstructorCall(this, BaseController);
|
||||
}
|
||||
|
||||
_inherits(BaseController, _Chaplin$Controller);
|
||||
@@ -16,9 +20,9 @@ var BaseController = (function (_Chaplin$Controller) {
|
||||
|
||||
var BaseController2 = (function (_Chaplin$Controller$Another) {
|
||||
function BaseController2() {
|
||||
if (Object.getPrototypeOf(BaseController2) !== null) {
|
||||
Object.getPrototypeOf(BaseController2).apply(this, arguments);
|
||||
}
|
||||
_classCallCheck(this, BaseController2);
|
||||
|
||||
_classSuperConstructorCall(this, BaseController2);
|
||||
}
|
||||
|
||||
_inherits(BaseController2, _Chaplin$Controller$Another);
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function (Foo) {
|
||||
function Test() {
|
||||
if (Object.getPrototypeOf(Test) !== null) {
|
||||
Object.getPrototypeOf(Test).apply(this, arguments);
|
||||
}
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
_classSuperConstructorCall(this, Test);
|
||||
}
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
_get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
||||
};
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "MULTIPLIER is read-only"
|
||||
"throws": "Duplicate declaration MULTIPLIER"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "MULTIPLIER is read-only"
|
||||
"throws": "Duplicate declaration MULTIPLIER"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "MULTIPLIER is read-only"
|
||||
"throws": "Duplicate declaration MULTIPLIER"
|
||||
}
|
||||
|
||||
2
test/fixtures/transformation/es6-constants/update-expression/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-constants/update-expression/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
const foo = 1;
|
||||
foo++;
|
||||
3
test/fixtures/transformation/es6-constants/update-expression/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-constants/update-expression/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "foo is read-only"
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
define(["exports", "module"], function (exports, module) {
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
module.exports = foo;
|
||||
module.exports = 42;
|
||||
module.exports = {};
|
||||
@@ -8,11 +10,15 @@ define(["exports", "module"], function (exports, module) {
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
var _default = function _default() {};
|
||||
var _default = function _default() {
|
||||
_classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
});
|
||||
@@ -1,6 +1,8 @@
|
||||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
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;
|
||||
@@ -11,7 +13,9 @@ define(["exports"], function (exports) {
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
function foo7() {}
|
||||
var foo8 = exports.foo8 = function foo8() {};
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
exports.__esModule = true;
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
module.exports = foo;
|
||||
module.exports = 42;
|
||||
module.exports = {};
|
||||
@@ -7,10 +9,14 @@ module.exports = [];
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
var _default = function _default() {};
|
||||
var _default = function _default() {
|
||||
_classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
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;
|
||||
@@ -10,6 +12,8 @@ var foo4 = exports.foo4 = 2;
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
function foo7() {}
|
||||
var foo8 = exports.foo8 = function foo8() {};
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.__esModule = true;
|
||||
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { __esModule };
|
||||
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
|
||||
}
|
||||
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export var __esModule = false;
|
||||
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _default = function _default() {};
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var _default = function _default() {
|
||||
_classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var foo = 1;
|
||||
var foo = 1,
|
||||
bar = 2;
|
||||
@@ -9,4 +11,6 @@ var foo4 = 2;
|
||||
var foo5 = undefined;
|
||||
var foo6 = 3;
|
||||
function foo7() {}
|
||||
var foo8 = function foo8() {};
|
||||
var foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
@@ -1,13 +1,15 @@
|
||||
System.register([], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var _default, Foo;
|
||||
var _classCallCheck, _default, Foo;
|
||||
_export("default", foo);
|
||||
|
||||
function foo() {}
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
_export("default", 42);
|
||||
|
||||
_export("default", {});
|
||||
@@ -18,11 +20,15 @@ System.register([], function (_export) {
|
||||
|
||||
_export("default", function () {});
|
||||
|
||||
_default = function _default() {};
|
||||
_default = function _default() {
|
||||
_classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
_export("default", _default);
|
||||
|
||||
Foo = function Foo() {};
|
||||
Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
_export("default", Foo);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
System.register([], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var foo, foo2, foo3, foo4, foo5, foo6, foo8;
|
||||
var _classCallCheck, foo, foo2, foo3, foo4, foo5, foo6, foo8;
|
||||
_export("foo7", foo7);
|
||||
|
||||
function foo7() {}
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_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 () {});
|
||||
foo3 = _export("foo3", undefined);
|
||||
foo4 = _export("foo4", 2);
|
||||
foo5 = _export("foo5", undefined);
|
||||
foo6 = _export("foo6", 3);
|
||||
foo8 = _export("foo8", function foo8() {});
|
||||
foo8 = _export("foo8", function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
});
|
||||
_export("foo3", foo3 = 5);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,8 @@
|
||||
})(function (exports, module) {
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
module.exports = foo;
|
||||
module.exports = 42;
|
||||
module.exports = {};
|
||||
@@ -14,11 +16,15 @@
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
var _default = function _default() {};
|
||||
var _default = function _default() {
|
||||
_classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
});
|
||||
@@ -7,6 +7,8 @@
|
||||
})(function (exports) {
|
||||
"use strict";
|
||||
|
||||
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;
|
||||
@@ -17,7 +19,9 @@
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
function foo7() {}
|
||||
var foo8 = exports.foo8 = function foo8() {};
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
exports.__esModule = true;
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var A = new WeakMap();
|
||||
var B = new WeakMap(),
|
||||
C = new WeakMap();
|
||||
@@ -7,7 +9,9 @@ var D = (function () {
|
||||
var F = new WeakMap(),
|
||||
G = new WeakMap();
|
||||
var E = new WeakMap();
|
||||
function D() {}
|
||||
function D() {
|
||||
_classCallCheck(this, D);
|
||||
}
|
||||
|
||||
return D;
|
||||
})();
|
||||
@@ -16,7 +20,9 @@ var H = (function () {
|
||||
var J = new WeakMap(),
|
||||
K = new WeakMap();
|
||||
var I = new WeakMap();
|
||||
function H() {}
|
||||
function H() {
|
||||
_classCallCheck(this, H);
|
||||
}
|
||||
|
||||
return H;
|
||||
})();
|
||||
})();
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); };
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {}
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
_prototypeProperties(Foo, null, _defineProperty({
|
||||
bar: {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user