diff --git a/CHANGELOG.md b/CHANGELOG.md index c96dbae186..b928bb7d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,29 @@ _Note: Gaps between patch versions are faulty/broken releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 4.7.11 + + * **Bug Fix** + * Fix unicode regexes stripping their unicode flag before being passed on two `regexpu`. + +## 4.7.10 + + * **Internal** + * Deprecate `playground.methodBinding` and `playground.objectGetterMemoization`. + * **Bug Fix** + * Fix `inputSourceMap` option. Thanks [@Rich-Harris](https://github.com/Rich-Harris)! + +## 4.7.9 + + * **Polish** + * Allow `inputSourceMap` to be set to `false` to skip the source map inference. + * Infer computed literal property names. + * **Bug Fix** + * Fix nested labeled for-ofs. + * Fix block scoping `break` colliding with the parent switch case. + * **Internal** + * Upgrade `acorn-babel`. + ## 4.7.8 * **Bug Fix** diff --git a/package.json b/package.json index 9240d6f6f6..c56e261740 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "babel", "description": "Turn ES6 code into readable vanilla ES5 with source maps", - "version": "4.7.8", + "version": "4.7.11", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", "repository": "babel/babel", @@ -36,7 +36,7 @@ "test": "make test" }, "dependencies": { - "acorn-babel": "0.11.1-37", + "acorn-babel": "0.11.1-38", "ast-types": "~0.7.0", "chalk": "^1.0.0", "chokidar": "^0.12.6", diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index 2722b91e34..6575b439af 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -1,7 +1,7 @@ { "name": "babel-runtime", "description": "babel selfContained runtime", - "version": "4.7.8", + "version": "4.7.11", "repository": "babel/babel", "author": "Sebastian McKenzie ", "dependencies": { diff --git a/src/babel/transformation/file.js b/src/babel/transformation/file.js index 0cd16c2aa5..3d1c5b1766 100644 --- a/src/babel/transformation/file.js +++ b/src/babel/transformation/file.js @@ -148,7 +148,7 @@ export default class File { returnUsedHelpers: false, externalHelpers: false, auxilaryComment: "", - inputSourceMap: false, + inputSourceMap: null, experimental: false, reactCompat: false, playground: false, @@ -288,10 +288,12 @@ export default class File { parseInputSourceMap(code: string) { var opts = this.opts; - var inputMap = convertSourceMap.fromSource(code); - if (inputMap) { - opts.inputSourceMap = inputMap.toObject(); - code = convertSourceMap.removeComments(code); + if (opts.inputSourceMap !== false) { + var inputMap = convertSourceMap.fromSource(code); + if (inputMap) { + opts.inputSourceMap = inputMap.toObject(); + code = convertSourceMap.removeComments(code); + } } return code; diff --git a/src/babel/transformation/helpers/regex.js b/src/babel/transformation/helpers/regex.js index 9251fdb823..1d3d4c2a4c 100644 --- a/src/babel/transformation/helpers/regex.js +++ b/src/babel/transformation/helpers/regex.js @@ -7,7 +7,7 @@ export function is(node, flag) { export function pullFlag(node, flag) { var flags = node.regex.flags.split(""); - if (node.regex.flags.indexOf("u") < 0) return; - pull(flags, "u"); + if (node.regex.flags.indexOf(flag) < 0) return; + pull(flags, flag); node.regex.flags = flags.join(""); } diff --git a/src/babel/transformation/transformers/es6/for-of.js b/src/babel/transformation/transformers/es6/for-of.js index 42c57d5859..5d6e380dc0 100644 --- a/src/babel/transformation/transformers/es6/for-of.js +++ b/src/babel/transformation/transformers/es6/for-of.js @@ -33,11 +33,8 @@ export function ForOfStatement(node, parent, scope, file) { t.inherits(loop, node); - if (build.replaceParent) { - this.parentPath.node = build.node; - } else { - return build.node; - } + if (build.replaceParent) this.parentPath.node = build.node; + return build.node; } export function _ForOfStatementArray(node, scope, file) { diff --git a/src/babel/transformation/transformers/es6/regex.unicode.js b/src/babel/transformation/transformers/es6/regex.unicode.js index 2cf7717c7e..1f82388cbe 100644 --- a/src/babel/transformation/transformers/es6/regex.unicode.js +++ b/src/babel/transformation/transformers/es6/regex.unicode.js @@ -7,6 +7,6 @@ export function check(node) { export function Literal(node) { if (!regex.is(node, "u")) return; - regex.pullFlag(node, "y"); node.regex.pattern = rewritePattern(node.regex.pattern, node.regex.flags); + regex.pullFlag(node, "u"); } diff --git a/src/babel/transformation/transformers/playground/memoization-operator.js b/src/babel/transformation/transformers/playground/memoization-operator.js index 7c63ad102a..f8d55d854c 100644 --- a/src/babel/transformation/transformers/playground/memoization-operator.js +++ b/src/babel/transformation/transformers/playground/memoization-operator.js @@ -11,6 +11,7 @@ build(exports, { }, build(node, file) { + console.error("The memoization operator is deprecated and will be removed in 5.0.0"); return t.unaryExpression( "!", t.callExpression( diff --git a/src/babel/transformation/transformers/playground/object-getter-memoization.js b/src/babel/transformation/transformers/playground/object-getter-memoization.js index 5cfaf9c61a..dbbd3a065e 100644 --- a/src/babel/transformation/transformers/playground/object-getter-memoization.js +++ b/src/babel/transformation/transformers/playground/object-getter-memoization.js @@ -20,6 +20,8 @@ export function MethodDefinition(node, parent, scope, file) { if (node.kind !== "memo") return; node.kind = "get"; + console.error("Object getter memoization is deprecated and will be removed in 5.0.0"); + t.ensureBlock(node.value); var key = node.key; diff --git a/test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js b/test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js new file mode 100644 index 0000000000..73c8203449 --- /dev/null +++ b/test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js @@ -0,0 +1,5 @@ +b: for (let c of d()) { + for (let e of f()) { + continue b; + } +} diff --git a/test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js b/test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js new file mode 100644 index 0000000000..fd63d9c8f5 --- /dev/null +++ b/test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js @@ -0,0 +1,48 @@ +"use strict"; + +var _iteratorNormalCompletion = true; +var _didIteratorError = false; +var _iteratorError = undefined; + +try { + b: for (var _iterator = d()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var c = _step.value; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = f()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var e = _step2.value; + + continue b; + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2["return"]) { + _iterator2["return"](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + } +} catch (err) { + _didIteratorError = true; + _iteratorError = err; +} finally { + try { + if (!_iteratorNormalCompletion && _iterator["return"]) { + _iterator["return"](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } +} diff --git a/test/fixtures/transformation/es6-regex.unicode/basic/expected.js b/test/fixtures/transformation/es6-regex.unicode/basic/expected.js index 9e4e69cf20..670ac43a38 100644 --- a/test/fixtures/transformation/es6-regex.unicode/basic/expected.js +++ b/test/fixtures/transformation/es6-regex.unicode/basic/expected.js @@ -1,4 +1,4 @@ "use strict"; var string = "foo💩bar"; -var match = string.match(/foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/); +var match = string.match(/foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);