Compare commits

...

56 Commits

Author SHA1 Message Date
Sebastian McKenzie
708cdfb993 v5.0.9 2015-04-06 06:28:58 -07:00
Sebastian McKenzie
8cb3aabefa add 5.0.9 changelog 2015-04-06 06:26:11 -07:00
Sebastian McKenzie
4a87b35d20 fix function name self referencing test 2015-04-06 06:23:46 -07:00
Sebastian McKenzie
543554b258 flow tests style nit 2015-04-06 06:20:09 -07:00
Sebastian McKenzie
afd95cf663 add #1168 regression test 2015-04-06 06:20:05 -07:00
Sebastian McKenzie
87ce4b9cd8 fix order of parameter type annotation parsing - fixes #1168 2015-04-06 06:19:13 -07:00
Sebastian McKenzie
6b76f26ed8 use module id if available for umd global name - fixes #1166 2015-04-06 06:14:09 -07:00
Sebastian McKenzie
c2776e63ae rename umd module variable name - fixes #1166 2015-04-06 06:13:43 -07:00
Sebastian McKenzie
3f2fe363d1 Merge pull request #1163 from chocolateboy/babel_node_print_fix
babel-node --print: don't mangle percent characters (%)
2015-04-06 06:06:21 -07:00
Sebastian McKenzie
8de28098f4 Merge pull request #1170 from alawatthe/master
Replaced FUNCTION_ID by FUNCTION_KEY - fixes #1164
2015-04-06 06:02:49 -07:00
alawatthe
9a28f3fdb1 Replaced FUNCTION_ID by FUNCTION_KEY - fixes #1164 2015-04-06 10:53:41 +02:00
chocolateboy
88941b3270 babel-node --print: don't mangle percent characters (%)
This applies the babel fix in #528 to babel-node.

before:

    $ babel-node --print --eval '"%%"'
    '%'

after:

    $ babel-node --print --eval '"%%"'
    '%%'
2015-04-05 06:26:29 +01:00
Sebastian McKenzie
3a768db2bf fix missing this in acorn parseExprAtom 2015-04-05 03:26:41 +10:00
Sebastian McKenzie
320a39f4c4 fix computed properties in es7 object rest/spread - thanks @AluisioASG! 2015-04-05 02:52:14 +10:00
Sebastian McKenzie
dc98ac7c93 5.0.8 2015-04-04 17:09:35 +11:00
Sebastian McKenzie
6e456f0ec1 v5.0.8 2015-04-04 17:05:47 +11:00
Sebastian McKenzie
793090628d fix #1157 regression test 2015-04-04 17:03:54 +11:00
Sebastian McKenzie
9ed251cb08 add 5.0.8 changelog 2015-04-04 17:02:50 +11:00
Sebastian McKenzie
480fa7f4e0 add regression test for #1157 2015-04-04 16:59:29 +11:00
Sebastian McKenzie
3e642dfa1b Merge pull request #1157 from jayphelps/patch-1
[BUGFIX] Check whether `value` key is in descriptor instead of checking truthy value
2015-04-04 16:57:57 +11:00
Jay Phelps
d9cbce1862 [BUGFIX] checking whether value key is in descriptor instead of checking if value is truthy since !!0 === false
class Foo {
  static bar = 0;
}

Foo.bar++;
// Cannot assign to read only property 'bar' of function
2015-04-03 22:49:34 -07:00
Sebastian McKenzie
4bd19da3c2 fix tests, better block scoped collisions 2015-04-04 14:17:26 +11:00
Sebastian McKenzie
7c710a0378 move var scope collector to before block - fixes #1153 2015-04-04 14:09:34 +11:00
Sebastian McKenzie
56335409d3 stop constructor verification traversal on FunctionDeclaration/FunctionExpression - fixes #1155 2015-04-04 14:01:26 +11:00
Sebastian McKenzie
91d78afc67 update 5.0.7 changelog 2015-04-04 05:32:32 +11:00
Sebastian McKenzie
54c6339f20 5.0.7 2015-04-04 04:51:24 +11:00
Sebastian McKenzie
fdcf64265e v5.0.7 2015-04-04 04:49:31 +11:00
Sebastian McKenzie
ffdfb491eb disable identifier resolution - fixes #1149 2015-04-04 04:46:49 +11:00
Sebastian McKenzie
eedd431f2b remove HOMEPATH from register cache home resolution 2015-04-04 04:40:10 +11:00
Sebastian McKenzie
db9ed0235f finally fix cli tests 2015-04-04 04:39:28 +11:00
Sebastian McKenzie
6c98d39937 grr, debugging travis builds is hard 2015-04-04 04:01:35 +11:00
Sebastian McKenzie
20651df3ce try and fix babel cli bootstrap 2015-04-04 03:47:47 +11:00
Sebastian McKenzie
f3155919fe shift USERPROFILE over in home resolution in babel/register - fixes #1148 2015-04-04 03:46:07 +11:00
Sebastian McKenzie
0ac8330899 remove bable-core in babel-cli bootstrap 2015-04-04 03:40:01 +11:00
Sebastian McKenzie
67201e9698 add ignore/only option to cli 2015-04-04 03:31:19 +11:00
Sebastian McKenzie
c715d96e46 wrap non-arrays/strings/falsys in an array in util.list - fixes babel/babelify#69 2015-04-04 02:40:09 +11:00
Sebastian McKenzie
b7a08100a6 add default live bindings to common module formatter 2015-04-04 01:56:58 +11:00
Sebastian McKenzie
5f91ee8a1a 5.0.6 2015-04-03 23:15:34 +11:00
Sebastian McKenzie
bc1abb5103 v5.0.6 2015-04-03 23:13:43 +11:00
Sebastian McKenzie
4b9207e5df add 5.0.6 changelog 2015-04-03 23:12:10 +11:00
Sebastian McKenzie
e847f3685f should only throw an error for colliding param bindings for let and const 2015-04-03 23:11:04 +11:00
Sebastian McKenzie
d64c2c0c45 turn internalRemap into a null inherited object, fixes a nasty bug where module import live bindings would return a function if they referenced a method on Object.prototype (eg. toString) 2015-04-03 23:10:09 +11:00
Sebastian McKenzie
76d0fb4ba6 5.0.5 2015-04-03 22:44:16 +11:00
Sebastian McKenzie
0f33b7bfbc v5.0.5 2015-04-03 22:42:50 +11:00
Sebastian McKenzie
630224e504 add 5.0.5 changelog 2015-04-03 22:41:06 +11:00
Sebastian McKenzie
62980ab6b4 Merge branch 'master' of github.com:babel/babel
t push
2015-04-03 22:38:28 +11:00
Sebastian McKenzie
d34480b42b add support for arrays to util.list - fixes #["foo", "bar"] 2015-04-03 22:38:08 +11:00
Sebastian McKenzie
306de2edbf Merge pull request #1144 from tricknotes/fix-for-browserify
Update core-js to ^0.8.1
2015-04-03 22:23:48 +11:00
Ryunosuke SATO
c33e84730d Update core-js to ^0.8.1
This version fixes the error for some environments that
has no `setTimeout`/`setInterval`.
2015-04-03 18:38:33 +09:00
Sebastian McKenzie
20f28aba64 5.0.4 2015-04-03 15:34:20 +11:00
Sebastian McKenzie
9c312607d1 Merge branch 'master' of github.com:babel/babel 2015-04-03 15:33:27 +11:00
Sebastian McKenzie
33659711c3 Merge pull request #1142 from cesarandreu/add-babel-readme
Add README.md to babel-cli
2015-04-03 15:33:00 +11:00
Sebastian McKenzie
b154af48a7 Merge branch 'master' of github.com:babel/babel 2015-04-03 15:32:52 +11:00
Cesar Andreu
bad877946f Add README.md to babel-cli 2015-04-02 21:31:47 -07:00
Sebastian McKenzie
23038dcfff Merge pull request #1141 from fkling/patch-1
Update SO link in README.md
2015-04-03 15:30:47 +11:00
Felix Kling
7c7a7ee17f Update README.md
The SO link currently points to https://github.com/babel/babel/blob/master/stackoverflow.com, which is incorrect. After this change it points to the list of babeljs questions.
2015-04-02 21:29:56 -07:00
85 changed files with 429 additions and 211 deletions

View File

@@ -13,6 +13,46 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 5.0.9
* **Polish**
* Use `moduleId` for UMD global name if available.
* **Bug Fix**
* Fix UMD global `module` variable shadowing the `amd`/`common` `module` variable.
* Fix Flow param type annotation regression.
* Fix function name collision `toString` wrapper. Thanks [@alawatthe](https://github.com/alawatthe)!
## 5.0.8
* **Bug Fix**
* Fix falsy static class properties not being writable.
* Fix block scoping collisions not properly detecting modules and function clashes.
* Skip `this` before `super` for derived constructors on functions.
## 5.0.7
* **New Feature**
* Add `--ignore` and `--only` support to the CLI.
* **Bug Fix**
* Remove `HOMEPATH` environment variable from home resolution in `babel/register` cache.
* **Internal**
* Disable WIP path resolution introducing infinite recursion in some code examples.
* **Polish**
* Add live binding to CommonJS default imports.
## 5.0.6
* **Bug Fix**
* Fix mangling of import references that collide with properties on `Object.prototype`.
* Fix duplicate declarations incorrectly being reported for `var`.
## 5.0.5
* **Internal**
* Upgrade `core-js`.
* **Bug Fix**
* Fix arrays not being supported in `util.list`.
## 5.0.4
* **Polish**

View File

@@ -111,7 +111,7 @@ publish-cli:
bootstrap:
npm install
npm link
cd packages/babel-cli && npm install && npm link
cd packages/babel-cli && npm install && npm link && npm link babel-core
git submodule update --init
cd vendor/regenerator && npm install
cd vendor/compat-table && npm install object-assign

View File

@@ -9,7 +9,7 @@
</p>
<p align="center">
For questions and support please visit the <a href="https://gitter.im/babel/babel">gitter room</a> or <a href="stackoverflow.com">StackOverflow</a>. The Babel issue tracker is <strong>exclusively</strong> for bug reports and future requests.
For questions and support please visit the <a href="https://gitter.im/babel/babel">gitter room</a> or <a href="http://stackoverflow.com/questions/tagged/babeljs">StackOverflow</a>. The Babel issue tracker is <strong>exclusively</strong> for bug reports and future requests.
</p>
<p align="center">

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.0.4",
"version": "5.0.9",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -30,7 +30,7 @@
"ast-types": "~0.7.0",
"chalk": "^1.0.0",
"convert-source-map": "^0.5.0",
"core-js": "^0.8.0",
"core-js": "^0.8.1",
"debug": "^2.1.1",
"detect-indent": "^3.0.0",
"estraverse": "^1.9.1",

View File

@@ -0,0 +1,5 @@
# babel-cli
Babel CLI
For more information please look at [babel](https://github.com/babel/babel).

View File

@@ -4,6 +4,7 @@ var pathIsAbsolute = require("path-is-absolute");
var commander = require("commander");
var Module = require("module");
var babel = require("babel-core");
var inspect = require("util").inspect;
var path = require("path");
var repl = require("repl");
var util = require("babel-core").util;
@@ -71,7 +72,10 @@ if (program.eval || program.print) {
global.require = module.require.bind(module);
var result = _eval(code, global.__filename);
if (program.print) console.log(result);
if (program.print) {
var output = _.isString(result) ? result : inspect(result);
process.stdout.write(output + "\n");
}
} else {
if (program.args.length) {
// slice all arguments up to the first filename since they're babel args that we handle

View File

@@ -28,6 +28,8 @@ module.exports = function (commander, filenames, opts) {
};
var handleFile = function (src, filename) {
if (util.shouldIgnore(src)) return;
if (util.canCompile(filename)) {
write(src, filename);
} else if (commander.copyFiles) {

View File

@@ -107,6 +107,8 @@ module.exports = function (commander, filenames, opts) {
});
_.each(_filenames, function (filename) {
if (util.shouldIgnore(filename)) return;
results.push(util.compile(filename));
});

View File

@@ -102,12 +102,15 @@ if (errors.length) {
//
exports.opts = {};
var opts = exports.opts = {};
each(options, function (opt, key) {
exports.opts[key] = commander[key];
opts[key] = commander[key];
});
opts.ignore = util.arrayify(opts.ignore, util.regexify);
opts.only = util.arrayify(opts.only, util.regexify);
var fn;
if (commander.outDir) {

View File

@@ -16,6 +16,10 @@ exports.readdir = readdir;
exports.canCompile = util.canCompile;
exports.shouldIgnore = function (loc) {
return util.shouldIgnore(loc, index.opts.ignore, index.opts.only);
};
exports.addSourceMappingUrl = function (code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
};
@@ -23,6 +27,8 @@ exports.addSourceMappingUrl = function (code, loc) {
exports.transform = function (filename, code, opts) {
opts = _.defaults(opts || {}, index.opts);
opts.filename = filename;
opts.ignore = null;
opts.only = null;
var result = babel.transform(code, opts);
result.filename = filename;

View File

@@ -1,14 +1,14 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.0.3",
"version": "5.0.8",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
"preferGlobal": true,
"dependencies": {
"chokidar": "^0.12.6",
"babel-core": "^5.0.3",
"babel-core": "^5.0.8",
"commander": "^2.6.0",
"fs-readdir-recursive": "^0.1.0",
"output-file-sync": "^1.1.0",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "5.0.3",
"version": "5.0.8",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {

View File

@@ -250,7 +250,7 @@ pp.parseExprAtom = function(refShorthandDefaultPos) {
return this.finishNode(node, type)
case tt._yield:
if (this.inGenerator) unexpected()
if (this.inGenerator) this.unexpected()
case tt._do:
if (this.options.features["es7.doExpressions"]) {

View File

@@ -125,7 +125,9 @@ pp.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
this.expect(close)
break
} else {
elts.push(this.parseAssignableListItemTypes(this.parseMaybeDefault()))
var left = this.parseMaybeDefault()
this.parseAssignableListItemTypes(left)
elts.push(this.parseMaybeDefault(null, left))
}
}
return elts

View File

@@ -3,7 +3,7 @@ import os from "os";
import fs from "fs";
function getUserHome() {
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
return process.env.HOME || process.env.USERPROFILE;
}
const FILENAME = process.env.BABEL_CACHE_PATH || path.join(getUserHome() || os.tmpdir(), ".babel.json");

View File

@@ -422,23 +422,7 @@ export default class File {
shouldIgnore() {
var opts = this.opts;
var filename = opts.filename;
var ignore = opts.ignore;
var only = opts.only;
if (only.length) {
for (var i = 0; i < only.length; i++) {
if (only[i].test(filename)) return false;
}
return true;
} else if (ignore.length) {
for (var i = 0; i < ignore.length; i++) {
if (ignore[i].test(filename)) return true;
}
}
return false;
return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
}
parse(code: string) {

View File

@@ -61,7 +61,6 @@ var importsVisitor = {
enter(node, parent, scope, formatter) {
formatter.hasLocalImports = true;
extend(formatter.localImports, this.getBindingIdentifiers());
formatter.bumpImportOccurences(node);
}
}
};
@@ -69,7 +68,7 @@ var importsVisitor = {
var exportsVisitor = traverse.explode({
ExportDeclaration: {
enter(node, parent, scope, formatter) {
formatter.hasLocalImports = true;
formatter.hasLocalExports = true;
var declar = this.get("declaration");
if (declar.isStatement()) {
@@ -96,29 +95,23 @@ var exportsVisitor = traverse.explode({
formatter.hasNonDefaultExports = true;
}
}
if (node.source) {
formatter.bumpImportOccurences(node);
}
}
}
});
export default class DefaultFormatter {
constructor(file) {
this.internalRemap = {};
this.defaultIds = object();
this.scope = file.scope;
this.file = file;
this.ids = object();
this.internalRemap = object();
this.defaultIds = object();
this.scope = file.scope;
this.file = file;
this.ids = object();
this.hasNonDefaultExports = false;
this.hasLocalExports = false;
this.hasLocalImports = false;
this.localImportOccurences = object();
this.localExports = object();
this.localImports = object();
@@ -134,15 +127,6 @@ export default class DefaultFormatter {
return (t.isExportDefaultDeclaration(node) || t.isSpecifierDefault(node)) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
}
bumpImportOccurences(node) {
var source = node.source.value;
var occurs = this.localImportOccurences;
occurs[source] ||= 0;
if (node.specifiers) {
occurs[source] += node.specifiers.length;
}
}
getLocalExports() {
this.file.path.traverse(exportsVisitor, this);
}
@@ -152,7 +136,7 @@ export default class DefaultFormatter {
}
remapAssignments() {
if (this.hasLocalImports) {
if (this.hasLocalExports || this.hasLocalImports) {
this.file.path.traverse(remapVisitor, this);
}
}

View File

@@ -6,7 +6,9 @@ import * as util from "../../util";
import * as t from "../../types";
export default class AMDFormatter extends DefaultFormatter {
init = CommonFormatter.prototype.init;
init() {
CommonFormatter.prototype._init.call(this, this.hasNonDefaultExports);
}
buildDependencyLiterals() {
var names = [];
@@ -100,15 +102,34 @@ export default class AMDFormatter extends DefaultFormatter {
this.internalRemap[specifier.local.name] = ref;
}
exportSpecifier() {
CommonFormatter.prototype.exportSpecifier.apply(this, arguments);
exportSpecifier(specifier, node, nodes) {
if (this.doDefaultExportInterop(specifier)) {
nodes.push(util.template("exports-default-assign", {
VALUE: specifier.local
}, true));
} else {
CommonFormatter.prototype.exportSpecifier.apply(this, arguments);
}
}
exportDeclaration(node) {
exportDeclaration(node, nodes) {
if (this.doDefaultExportInterop(node)) {
this.passModuleArg = true;
var declar = node.declaration;
var assign = util.template("exports-default-assign", {
VALUE: this._pushStatement(declar, nodes)
}, true);
if (t.isFunctionDeclaration(declar)) {
// we can hoist this assignment to the top of the file
assign._blockHoist = 3;
}
nodes.push(assign);
return;
}
CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
}
}

View File

@@ -5,13 +5,17 @@ import * as t from "../../types";
export default class CommonJSFormatter extends DefaultFormatter {
init() {
this._init(this.hasLocalExports);
}
_init(conditional) {
var file = this.file;
var scope = file.scope;
scope.rename("module");
scope.rename("exports");
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
if (!this.noInteropRequireImport && conditional) {
var templateName = "exports-module-declaration";
if (this.file.isLoose("es6.modules")) templateName += "-loose";
var declar = util.template(templateName, true);
@@ -20,6 +24,20 @@ export default class CommonJSFormatter extends DefaultFormatter {
}
}
transform(program) {
DefaultFormatter.prototype.transform.apply(this, arguments);
if (this.hasDefaultOnlyExport) {
program.body.push(
t.expressionStatement(t.assignmentExpression(
"=",
t.memberExpression(t.identifier("module"), t.identifier("exports")),
t.memberExpression(t.identifier("exports"), t.identifier("default"))
))
);
}
}
importSpecifier(specifier, node, nodes) {
var variableName = specifier.local;
@@ -31,11 +49,15 @@ export default class CommonJSFormatter extends DefaultFormatter {
this.internalRemap[variableName.name] = ref;
} else {
if (this.noInteropRequireImport) {
this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"))
this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"));
} else if (!includes(this.file.dynamicImported, node)) {
var uid = this.scope.generateUidBasedOnNode(node, "import");
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(variableName, t.callExpression(this.file.addHelper("interop-require"), [ref]))
t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]))
]));
this.internalRemap[variableName.name] = t.memberExpression(uid, t.identifier("default"));
}
}
} else {
@@ -64,29 +86,15 @@ export default class CommonJSFormatter extends DefaultFormatter {
exportSpecifier(specifier, node, nodes) {
if (this.doDefaultExportInterop(specifier)) {
nodes.push(util.template("exports-default-assign", {
VALUE: specifier.local
}, true));
return;
} else {
DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
this.hasDefaultOnlyExport = true;
}
DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
}
exportDeclaration(node, nodes) {
if (this.doDefaultExportInterop(node)) {
var declar = node.declaration;
var assign = util.template("exports-default-assign", {
VALUE: this._pushStatement(declar, nodes)
}, true);
if (t.isFunctionDeclaration(declar)) {
// we can hoist this assignment to the top of the file
assign._blockHoist = 3;
}
nodes.push(assign);
return;
this.hasDefaultOnlyExport = true;
}
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);

View File

@@ -47,8 +47,8 @@ export default class UMDFormatter extends AMDFormatter {
// globals
var browserArgs = [t.memberExpression(t.identifier("module"), t.identifier("exports"))];
if (this.passModuleArg) browserArgs.push(t.identifier("module"));
var browserArgs = [];
if (this.passModuleArg) browserArgs.push(t.identifier("mod"));
for (let name in this.ids) {
var id = this.defaultIds[name] || t.identifier(t.toIdentifier(name));
@@ -60,12 +60,17 @@ export default class UMDFormatter extends AMDFormatter {
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));
//
var globalArg = this.file.opts.basename;
if (moduleName) globalArg = moduleName;
globalArg = t.identifier(t.toIdentifier(globalArg));
var runner = util.template("umd-runner-body", {
AMD_ARGUMENTS: defineArgs,
COMMON_TEST: commonTests,
COMMON_ARGUMENTS: commonArgs,
BROWSER_ARGUMENTS: browserArgs,
GLOBAL_ARG: t.identifier(t.toIdentifier(this.file.opts.basename))
GLOBAL_ARG: globalArg
});
//

View File

@@ -4,7 +4,7 @@
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if (descriptor.value) descriptor.writable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

View File

@@ -4,7 +4,7 @@
}
FUNCTION_ID.toString = function () {
return FUNCTION_ID.toString();
return FUNCTION_KEY.toString();
};
return FUNCTION_ID;

View File

@@ -4,7 +4,7 @@
}
FUNCTION_ID.toString = function () {
return FUNCTION_ID.toString();
return FUNCTION_KEY.toString();
}
return FUNCTION_ID;

View File

@@ -4,8 +4,8 @@
} else if (COMMON_TEST) {
factory(COMMON_ARGUMENTS);
} else {
var module = { exports: {} };
factory(BROWSER_ARGUMENTS);
global.GLOBAL_ARG = module.exports;
var mod = { exports: {} };
factory(mod.exports, BROWSER_ARGUMENTS);
global.GLOBAL_ARG = mod.exports;
}
});

View File

@@ -62,6 +62,18 @@ var verifyConstructorVisitor = traverse.explode({
}
},
FunctionDeclaration: {
enter() {
this.skip();
}
},
FunctionExpression: {
enter() {
this.skip();
}
},
ThisExpression: {
enter(node, parent, scope, state) {
if (state.hasSuper && !state.hasBareSuper) {
@@ -440,7 +452,7 @@ class ClassTransformer {
file: this.file
};
path.traverse(verifyConstructorVisitor, state);
path.get("value").traverse(verifyConstructorVisitor, state);
this.bareSuper = state.bareSuper;

View File

@@ -332,7 +332,7 @@ class DestructuringTransformer {
if (t.isSpreadProperty(prop)) continue;
var key = prop.key;
if (t.isIdentifier(key)) key = t.literal(prop.key.name);
if (t.isIdentifier(key) && !prop.computed) key = t.literal(prop.key.name);
keys.push(key);
}

View File

@@ -547,6 +547,9 @@ export default class TraversalPath {
var binding = this.scope.getBinding(this.node.name);
if (!binding || !binding.constant) return;
// todo: take into consideration infinite recursion #1149
return;
if (binding.path === this) {
return this;
} else {

View File

@@ -237,10 +237,15 @@ export default class Scope {
var local = this.getOwnBindingInfo(name);
if (!local) return;
if (kind === "param") return;
if (kind === "hoisted" && local.kind === "let") return;
if (local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param") {
var duplicate = false;
duplicate ||= kind === "let" || kind === "const" || local.kind === "let" || local.kind === "const" || local.kind === "module";
duplicate ||= local.kind === "param" && (kind === "let" || kind === "const");
if (duplicate) {
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
}
}
@@ -472,6 +477,15 @@ export default class Scope {
this.traverse(path.get("body").node, blockVariableVisitor, this);
}
// Program, Function - var variables
if (path.isProgram() || path.isFunction()) {
this.traverse(path.node, functionVariableVisitor, {
blockId: path.get("id").node,
scope: this
});
}
// Program, BlockStatement, Function - let variables
if (path.isBlockStatement() || path.isProgram()) {
@@ -490,15 +504,6 @@ export default class Scope {
this.registerBinding("let", path);
}
// Program, Function - var variables
if (path.isProgram() || path.isFunction()) {
this.traverse(path.node, functionVariableVisitor, {
blockId: path.get("id").node,
scope: this
});
}
// Program
if (path.isProgram()) {

View File

@@ -55,7 +55,15 @@ export function resolveRelative(loc: string) {
}
export function list(val: string): Array<string> {
return val ? val.split(",") : [];
if (!val) {
return [];
} else if (Array.isArray(val)) {
return val;
} else if (typeof val === "string") {
return val.split(",");
} else {
return [val];
}
}
export function regexify(val: any): RegExp {
@@ -85,6 +93,21 @@ export function booleanify(val: any): boolean {
return val;
}
export function shouldIgnore(filename, ignore, only) {
if (only.length) {
for (var i = 0; i < only.length; i++) {
if (only[i].test(filename)) return false;
}
return true;
} else if (ignore.length) {
for (var i = 0; i < ignore.length; i++) {
if (ignore[i].test(filename)) return true;
}
}
return false;
}
var templateVisitor = {
enter(node, parent, scope, nodes) {
if (t.isExpressionStatement(node)) {

View File

@@ -10959,7 +10959,7 @@ var fbTestFixture = {
}
},
},
'Bounded Polymorphism': {
'Bounded Polymorphism': {
'class A<T: Foo> {}': {
type: 'ClassDeclaration',
id: {

View File

@@ -70,6 +70,7 @@ var buildTest = function (binName, testName, opts) {
return function (callback) {
this.timeout(5000);
clear();
saveInFiles(opts.inFiles);
var args = [binLoc].concat(opts.args);
@@ -109,11 +110,11 @@ var buildTest = function (binName, testName, opts) {
};
};
before(function () {
var clear = function () {
if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
fs.mkdirSync(tmpLoc);
process.chdir(tmpLoc);
});
};
_.each(fs.readdirSync(fixtureLoc), function (binName) {
if (binName[0] === ".") return;

View File

@@ -12,10 +12,7 @@ suite("browserify", function() {
assert.ok(bundle.length, "bundle output code");
// ensure that the code runs without throwing an exception
vm.runInNewContext("var global = this;\n" + bundle, {
setInterval: function () {},
setTimeout: function () {}
});
vm.runInNewContext("var global = this;\n" + bundle, {});
done();
})
})

View File

@@ -0,0 +1 @@
bar;

View File

@@ -0,0 +1,3 @@
{
"args": ["src", "--out-dir", "lib", "--ignore", "src/foo/*"]
}

View File

@@ -0,0 +1 @@
src/bar/index.js -> lib/bar/index.js

View File

@@ -0,0 +1 @@
bar;

View File

@@ -0,0 +1,3 @@
{
"args": ["src", "--out-dir", "lib", "--only", "src/bar/*"]
}

View File

@@ -0,0 +1 @@
src/bar/index.js -> lib/bar/index.js

View File

@@ -1,4 +1,5 @@
var z = {};
var { ...x } = z;
var { x, ...y } = z;
var { [x]: x, ...y } = z;
(function({ x, ...y }) { })

View File

@@ -4,6 +4,8 @@ var z = {};
var x = babelHelpers.objectWithoutProperties(z, []);
var x = z.x;
var y = babelHelpers.objectWithoutProperties(z, ["x"]);
var x = z[x];
var y = babelHelpers.objectWithoutProperties(z, [x]);
(function (_ref) {
var x = _ref.x;

View File

@@ -2,13 +2,16 @@
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 = {};
module.exports = [];
module.exports = foo;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = foo;
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
exports["default"] = foo;
module.exports = function () {};
exports["default"] = function () {};
var _default = (function () {
var _class = function _default() {
@@ -18,7 +21,7 @@ var _default = (function () {
return _class;
})();
module.exports = _default;
exports["default"] = _default;
function foo() {}
@@ -26,5 +29,6 @@ var Foo = function Foo() {
_classCallCheck(this, Foo);
};
module.exports = Foo;
module.exports = foo;
exports["default"] = Foo;
exports["default"] = foo;
module.exports = exports["default"];

View File

@@ -1,12 +1,12 @@
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
var _foo = require("foo");
var foo = _interopRequire(_foo);
var _foo2 = _interopRequireWildcard(_foo);
var foo2 = _interopRequire(_foo);
var _foo22 = _interopRequireWildcard(_foo);
foo;
foo2;
_foo2["default"];
_foo22["default"];

View File

@@ -1,10 +1,10 @@
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
var _foo$xyz = require("foo");
var foo = _interopRequire(_foo$xyz);
var _foo$xyz2 = _interopRequireWildcard(_foo$xyz);
foo;
_foo$xyz.baz;
_foo$xyz2["default"];
_foo$xyz.baz;

View File

@@ -2,8 +2,6 @@
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
Object.defineProperty(exports, "__esModule", {
value: true
});
@@ -16,7 +14,7 @@ require("./directory/foo-bar");
var _foo = require("foo2");
var foo = _interopRequire(_foo);
var _foo2 = _interopRequireWildcard(_foo);
var _import = require("foo3");
@@ -32,4 +30,4 @@ var test = 5;
exports.test = test;
_bar.bar;
_bar2.foo;
foo;
_foo2["default"];

View File

@@ -39,4 +39,4 @@ System.register([], function (_export) {
_export("f", _export("e", d = 4));
}
};
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined" && typeof module !== "undefined") {
factory(exports, module);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, module);
global.actual = module.exports;
factory(mod.exports, mod);
global.actual = mod.exports;
}
})(this, function (exports, module) {
"use strict";
@@ -41,4 +41,4 @@
module.exports = Foo;
module.exports = foo;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo);
global.actual = module.exports;
factory(mod.exports, global.foo);
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports);
global.actual = module.exports;
factory(mod.exports);
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
@@ -23,4 +23,4 @@
exports["default"] = foo;
exports["default"] = foo;
exports.bar = bar;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports);
global.actual = module.exports;
factory(mod.exports);
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
@@ -43,4 +43,4 @@
};
exports.foo8 = foo8;
});
});

View File

@@ -4,12 +4,12 @@
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports);
global.actual = module.exports;
factory(mod.exports);
global.myCustomModuleName = mod.exports;
}
})(this, function (exports) {
"use strict";
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("./evens"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.evens);
global.actual = module.exports;
factory(mod.exports, global.evens);
global.actual = mod.exports;
}
})(this, function (exports, _evens) {
"use strict";
@@ -28,4 +28,4 @@
};
})(_evens.isEven);
exports.isOdd = isOdd;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo);
global.actual = module.exports;
factory(mod.exports, global.foo);
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
@@ -21,4 +21,4 @@
_foo2;
_foo22;
});
});

View File

@@ -4,14 +4,14 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo);
global.actual = module.exports;
factory(mod.exports, global.foo);
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
_foo;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo);
global.actual = module.exports;
factory(mod.exports, global.foo);
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
@@ -18,4 +18,4 @@
var _foo2 = _interopRequire(_foo);
_foo.baz;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo);
global.actual = module.exports;
factory(mod.exports, global.foo);
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
@@ -19,4 +19,4 @@
_foo.bar;
_foo.bar;
_foo.xyz;
});
});

View File

@@ -4,12 +4,12 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo, global.fooBar, global.directoryFooBar);
global.actual = module.exports;
factory(mod.exports, global.foo, global.fooBar, global.directoryFooBar);
global.actual = mod.exports;
}
})(this, function (exports, _foo, _fooBar, _directoryFooBar) {
"use strict";
});
});

View File

@@ -0,0 +1 @@
foobar();

View File

@@ -0,0 +1,17 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("MyLib", ["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.MyLib = mod.exports;
}
})(this, function (exports) {
"use strict";
foobar();
});

View File

@@ -0,0 +1,3 @@
{
"moduleId": "MyLib"
}

View File

@@ -4,14 +4,14 @@
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports);
global.actual = module.exports;
factory(mod.exports);
global.es6ModulesUmdModuleNameExpected = mod.exports;
}
})(this, function (exports) {
"use strict";
foobar();
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo2, global.fooBar, global.directoryFooBar);
global.actual = module.exports;
factory(mod.exports, global.foo2, global.fooBar, global.directoryFooBar);
global.actual = mod.exports;
}
})(this, function (exports, _foo, _fooBar, _directoryFooBar) {
"use strict";
@@ -29,4 +29,4 @@
_foo.bar;
_foo.foo;
});
});

View File

@@ -4,11 +4,11 @@
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports);
global.actual = module.exports;
factory(mod.exports);
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
@@ -42,4 +42,4 @@
exports.f = d;
exports.f = exports.e = d = 4;
});
});

View File

@@ -0,0 +1,9 @@
class Foo {
static num = 0;
static str = "foo";
}
assert.equal(Foo.num, 0);
assert.equal(Foo.num = 1, 1);
assert.equal(Foo.str, "foo");
assert.equal(Foo.str = "bar", "bar");

View File

@@ -1,7 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _foo2 = require("bar");
var _foo = babelHelpers.interopRequire(_foo2);
var _foo3 = babelHelpers.interopRequireWildcard(_foo2);
exports.foo = _foo;
exports.foo = _foo3["default"];

View File

@@ -89,7 +89,7 @@ var a: Promise<bool>[]
var a:(...rest:Array<number>) => number
var identity: <T>(x: T) => T
var identity: <T>(x: T, ...y:T[]) => T
import type foo from "bar";
import type foo4 from "bar";
import type { foo2, bar } from "baz";
import type { foo as bar2 } from "baz";
import type from "foo";

View File

@@ -0,0 +1,3 @@
{
"externalHelpers": true
}

View File

@@ -0,0 +1,3 @@
function foo(bar) {
var bar = bar[0];
}

View File

@@ -0,0 +1,5 @@
"use strict";
function foo(bar) {
var bar = bar[0];
}

View File

@@ -0,0 +1,9 @@
class Foo extends Bar {
constructor (options) {
let parentOptions = {};
parentOptions.init = function () {
this;
};
super(parentOptions);
}
}

View File

@@ -0,0 +1,16 @@
"use strict";
var Foo = (function (_Bar) {
function Foo(options) {
babelHelpers.classCallCheck(this, Foo);
var parentOptions = {};
parentOptions.init = function () {
this;
};
babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this, parentOptions);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
})(Bar);

View File

@@ -0,0 +1,3 @@
function test(x: string = "hi"): string {
return x;
}

View File

@@ -0,0 +1,7 @@
"use strict";
function test() {
var x = arguments[0] === undefined ? "hi" : arguments[0];
return x;
}

View File

@@ -0,0 +1,2 @@
import toString from "foo";
toString;

View File

@@ -0,0 +1,7 @@
"use strict";
var _toString = require("foo");
var _toString2 = babelHelpers.interopRequireWildcard(_toString);
_toString2["default"];

View File

@@ -1,7 +1,11 @@
module.exports = React.createClass({
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = React.createClass({
displayName: "actual",
render: function render() {
return null;
}
});
module.exports = exports["default"];

View File

@@ -4,8 +4,6 @@ var _core = require("babel-runtime/core-js")["default"];
var _regeneratorRuntime = require("babel-runtime/regenerator")["default"];
var _interopRequire = require("babel-runtime/helpers/interop-require")["default"];
var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"];
_core.Object.defineProperty(exports, "__esModule", {
@@ -30,12 +28,12 @@ exports.giveWord = giveWord;
var _foo = require("someModule");
var foo = _interopRequire(_foo);
var _foo2 = _interopRequireWildcard(_foo);
var bar = _interopRequireWildcard(_foo);
var myWord = _core.Symbol("abc");
exports.myWord = myWord;
foo;
bar;
_foo2["default"];
bar;

View File

@@ -1,9 +1,9 @@
"use strict";
var _interopRequire = require("babel-runtime/helpers/interop-require")["default"];
var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"];
var _foo = require("foo");
var foo = _interopRequire(_foo);
var _foo2 = _interopRequireWildcard(_foo);
foo;
_foo2["default"];

View File

@@ -4,14 +4,14 @@
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"), require("babel-runtime/helpers/interop-require"));
} else {
var module = {
var mod = {
exports: {}
};
factory(module.exports, global.foo, global._interopRequire);
global.actual = module.exports;
factory(mod.exports, global.foo, global._interopRequire);
global.actual = mod.exports;
}
})(this, function (exports, _foo, _babelRuntimeHelpersInteropRequire) {
"use strict";
var _foo2 = _babelRuntimeHelpersInteropRequire["default"](_foo);
});
});

View File

@@ -6,7 +6,7 @@ var i = (function (_i) {
}
i.toString = function () {
return i.toString();
return _i.toString();
};
return i;
@@ -17,4 +17,4 @@ var i = (function (_i) {
var j = function j() {
var _ = 5;
j = _.j;
};
};

View File

@@ -13,7 +13,7 @@ var obj = {
}
h.toString = function () {
return h.toString();
return _h.toString();
};
return h;
@@ -24,4 +24,4 @@ var obj = {
m: function m() {
doSmth();
}
};
};

View File

@@ -10,7 +10,7 @@ var f = (function (_f) {
}
f.toString = function () {
return f.toString();
return _f.toString();
};
return f;
@@ -23,9 +23,9 @@ var obj = {
}
f.toString = function () {
return f.toString();
return _f2.toString();
};
return f;
})(function (f) {})
};
};

View File

@@ -6,10 +6,10 @@ var f = (function (_f) {
}
f.toString = function () {
return f.toString();
return _f.toString();
};
return f;
})(function () {
console.log(f, g);
});
});

View File

@@ -57,6 +57,11 @@ suite("util", function () {
assert.deepEqual(util.list(""), []);
assert.deepEqual(util.list("foo"), ["foo"]);
assert.deepEqual(util.list("foo,bar"), ["foo", "bar"]);
assert.deepEqual(util.list(["foo", "bar"]), ["foo", "bar"]);
assert.deepEqual(util.list(/foo/), [/foo/]);
var date = new Date;
assert.deepEqual(util.list(date), [date]);
});
test("arrayify", function () {