Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"babel-jest": "^20.0.3",
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
"babel-traverse": "^6.25.0",
"butternut": "^0.4.6",
"bytes": "^2.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function hasViolation(declarator, scope, start) {
const scopeParent = declarator.getFunctionParent();

const violation = binding.constantViolations.some(v => {
// https://github.com/babel/babili/issues/630
if (!v.node) {
return false;
}
// return 'true' if we cannot guarantee the violation references
// the initialized identifier after
const violationStart = v.node.start;
Expand Down
29 changes: 29 additions & 0 deletions packages/babel-preset-babili/__tests__/babili-es2015-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
jest.autoMockOff();

const es2015 = require("babel-preset-es2015");
const babili = require("../src/index");

const thePlugin = require("../../../utils/test-transform")(null, {
plugins: [],
minified: false,
presets: [babili, es2015]
});

describe("preset along with es2015", () => {
thePlugin(
"should fix issue #630",
`
const obj = {cat: 'dog'};
let cat;
({cat} = obj);
`,
`
'use strict';

var cat,
obj = { cat: 'dog' },
_obj = obj;
cat = _obj.cat, _obj;
`
);
});
4 changes: 1 addition & 3 deletions packages/babel-preset-babili/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"author": "amasad",
"license": "MIT",
"main": "lib/index.js",
"keywords": [
"babel-preset"
],
"keywords": ["babel-preset"],
"dependencies": {
"babel-plugin-minify-builtins": "^0.1.3",
"babel-plugin-minify-constant-folding": "^0.1.3",
Expand Down
Loading