Compare commits

..

14 Commits

Author SHA1 Message Date
Sebastian McKenzie
21dcb6037a v3.0.5 2015-01-28 15:21:38 +11:00
Sebastian McKenzie
d10d96d19a fix unused iife declaration 2015-01-28 15:19:50 +11:00
Sebastian McKenzie
64766eea44 add more reliable iife detection for default parameter independent scope 2015-01-28 15:18:50 +11:00
Sebastian McKenzie
a9e682836b 3.0.4 2015-01-28 14:52:05 +11:00
Sebastian McKenzie
f504b8d529 v3.0.4 2015-01-28 14:49:55 +11:00
Sebastian McKenzie
30b2b55c86 remove badges from readme because noone cares 2015-01-28 14:48:13 +11:00
Sebastian McKenzie
836bc3a9a4 only check for duplicates for let variables 2015-01-28 14:47:09 +11:00
Sebastian McKenzie
630bfcc6cd add 3.0.x changelogs 2015-01-28 14:44:07 +11:00
Sebastian McKenzie
117203010a don't stop block variable scope finding on first hit 2015-01-28 14:39:46 +11:00
Sebastian McKenzie
f0986fe9c7 3.0.3 2015-01-28 14:39:01 +11:00
Sebastian McKenzie
4379441277 v3.0.3 2015-01-28 14:17:26 +11:00
Sebastian McKenzie
a955af06e0 remove opts from transform output 2015-01-28 14:14:55 +11:00
Sebastian McKenzie
8f69e59f29 ignore underscored options - fixes #29 2015-01-28 14:14:33 +11:00
Sebastian McKenzie
efda5ca897 3.0.2 2015-01-28 13:59:29 +11:00
7 changed files with 51 additions and 37 deletions

View File

@@ -11,6 +11,31 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 3.0.5
* **Internal**
* More reliable default parameter scope.
## 3.0.4
* **Bug Fix**
* Remove traversal stops from block scope tracking.
## 3.0.3
* **Internal**
* Ignore options starting with `_`.
## 3.0.2
* **Internal**
* Add common plugin options to valid options list.
## 3.0.1
* **Internal**
* Downgrade `kexec` as `1.1.0` throws compilation errors.
## 3.0.0
* **Polish**

View File

@@ -2,28 +2,6 @@
<img alt="6to5" src="https://raw.githubusercontent.com/6to5/logo/master/logo.png" width="546">
</p>
<p align="center">
<a href="https://gratipay.com/sebmck">
<img alt="Gratipay" src="https://img.shields.io/gratipay/sebmck.svg?style=flat">
</a>
<a href="https://travis-ci.org/6to5/6to5">
<img alt="Travis Status" src="http://img.shields.io/travis/6to5/6to5/master.svg?style=flat&amp;label=travis">
</a>
<a href="https://codeclimate.com/github/6to5/6to5">
<img alt="Code Climate Score" src="http://img.shields.io/codeclimate/github/6to5/6to5.svg?style=flat">
</a>
<a href="https://codeclimate.com/github/6to5/6to5">
<img alt="Coverage" src="http://img.shields.io/codeclimate/coverage/github/6to5/6to5.svg?style=flat">
</a>
<a href="https://david-dm.org/6to5/6to5">
<img alt="Dependency Status" src="http://img.shields.io/david/6to5/6to5.svg?style=flat">
</a>
</p>
<p align="center">
<strong>6to5</strong> turns ES6+ code into vanilla ES5, so you can use next generation features <strong>today.</strong>
</p>

View File

@@ -82,7 +82,7 @@ File.normaliseOptions = function (opts) {
opts = clone(opts);
for (var key in opts) {
if (File.validOptions.indexOf(key) < 0) {
if (key[0] !== "_" && File.validOptions.indexOf(key) < 0) {
throw new ReferenceError("Unknown option: " + key);
}
}
@@ -349,7 +349,6 @@ File.prototype.generate = function () {
var result = {
code: "",
opts: opts,
map: null,
ast: null
};

View File

@@ -1,7 +1,8 @@
"use strict";
var util = require("../../../util");
var t = require("../../../types");
var traverse = require("../../../traverse");
var util = require("../../../util");
var t = require("../../../types");
var hasDefaults = function (node) {
for (var i = 0; i < node.params.length; i++) {
@@ -10,12 +11,20 @@ var hasDefaults = function (node) {
return false;
};
var iifeVisitor = {
enter: function (node, parent, scope, context, state) {
if (t.isReferencedIdentifier(node, parent) && scope.hasOwn(node.name)) {
state.iife = true;
context.stop();
}
}
};
exports.Function = function (node, parent, scope) {
if (!hasDefaults(node)) return;
t.ensureBlock(node);
var iife = false;
var body = [];
var argsIdentifier = t.identifier("arguments");
@@ -23,6 +32,8 @@ exports.Function = function (node, parent, scope) {
var lastNonDefaultParam = 0;
var state = { iife: false, scope: scope };
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
@@ -36,10 +47,12 @@ exports.Function = function (node, parent, scope) {
node.params[i] = scope.generateUidIdentifier("x");
// we're accessing a variable that's already defined within this function
var localDeclar = scope.get(left.name, true);
if (localDeclar !== left) {
iife = true;
if (!state.iife) {
if (t.isIdentifier(right) && scope.hasOwn(right.name)) {
state.iife = true;
} else {
traverse(right, iifeVisitor, scope, state);
}
}
var defNode = util.template("default-parameter", {
@@ -55,7 +68,7 @@ exports.Function = function (node, parent, scope) {
// we need to cut off all trailing default parameters
node.params = node.params.slice(0, lastNonDefaultParam);
if (iife) {
if (state.iife) {
var container = t.functionExpression(null, [], node.body, node.generator);
container._aliasFunction = true;

View File

@@ -169,10 +169,9 @@ var programReferenceVisitor = {
var blockVariableVisitor = {
enter: function (node, parent, scope, context, add) {
if (t.isBlockScoped(node)) {
add(node, false, true);
context.stop();
add(node, false, t.isLet(node));
} else if (t.isScope(node)) {
context.skip();
context.stop();
}
}
};

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.0.2",
"version": "3.0.5",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://6to5.org/",
"repository": "6to5/6to5",

View File

@@ -1,6 +1,6 @@
{
"name": "6to5-runtime",
"description": "6to5 selfContained runtime",
"version": "3.0.1",
"version": "3.0.4",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}