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

When packaging, copy the code and inline __DEV__ #1572

Closed
wants to merge 1 commit into from

Commits on May 20, 2014

  1. When packaging, copy the code and inline __DEV__

    Fixes facebook#812.
    
    Previously, this code
    
        module.exports = moo();
        function moo() { return __DEV__; }
    
    would be transformed to
    
        module.exports = moo();
        function moo() { return "production" !== process.env.NODE_ENV; }
    
    Now, it's transformed to:
    
        if ("production" !== process.env.NODE_ENV) {
          var moo = function() { return true; };
          module.exports = moo();
        } else {
          var moo = function() { return false; };
          module.exports = moo();
        }
    
    which reduces the getter cost to one test at require time instead of inline for every `__DEV__` check, warning, and invariant.
    
    The unminified build is about twice as large now (but it's about the same after gzipping) and the minified build is the same size.
    sophiebits committed May 20, 2014
    Configuration menu
    Copy the full SHA
    4029378 View commit details
    Browse the repository at this point in the history