Skip to content

Better destructuring

username-removed-383729 requested to merge destructuring into master

Quite a large MR... bear with me. For the most part it's just moving logic around, but it does so in a way that's a little bit DRYer and paves the way for us to support compound destructuring. It fixes the bug identified in https://gitlab.com/Rich-Harris/buble/issues/43#note_11974937, and adds support for intelligent destructuring in variable declarations:

// input
var { foo, bar } = obj;
console.log( foo );
console.log( bar );
console.log( bar );

// old output
var foo = obj.foo;
var bar = obj.bar;
console.log( foo );
console.log( bar );
console.log( bar );

// new output
var bar = obj.bar;
console.log( obj.foo );
console.log( bar );
console.log( bar );

(This can create non-negligible savings, even post-minification.)

Merge request reports