[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectExpressions should be inlined across scopes. #337

Open
bardiharborow opened this issue Dec 11, 2016 · 0 comments
Open

ObjectExpressions should be inlined across scopes. #337

bardiharborow opened this issue Dec 11, 2016 · 0 comments

Comments

@bardiharborow
Copy link
Contributor
bardiharborow commented Dec 11, 2016

Input:

// numeric literal - same scope
function foo1() {
  const bar = 1;
  console.log(bar);
}

// numeric literal - different scope
function foo2() {
  const bar = 1;
  return function() {
    console.log(bar)
  }
}

// object literal - same scope
function foo3() {
  const bar = {
    a: 1,
    b: 2
  };
  console.log(bar.b);
}

// object literal - different scope
function foo4() {
  const bar = {
    a: 1,
    b: 2
  };
  return function() {
    console.log(bar.b)
  }
}

Output:

// numeric literal - same scope
function foo1(){console.log(1)}
// numeric literal - different scope
function foo2(){return function(){console.log(1)}}
// object literal - same scope
function foo3(){console.log({a:1,b:2}.b)}
// object literal - different scope
function foo4(){const a={a:1,b:2};return function(){console.log(a.b)}}

Numeric literals are inlined across scopes. ObjectExpressions aren't.

(Part of a series of issues that affect the optimal minification of twbs/bootstrap.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants