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

optimized function changes behavour #73

Closed
roblan opened this issue Feb 26, 2019 · 6 comments
Closed

optimized function changes behavour #73

roblan opened this issue Feb 26, 2019 · 6 comments

Comments

@roblan
Copy link

roblan commented Feb 26, 2019

  • Operating System: Mac OS
  • Node Version: 11.9.0
  • NPM Version: 6.8.0
  • webpack Version: 4.29.5
  • terser-webpack-plugin Version: 1.2.3

Expected Behavior

function should behave like non minimized one.

Actual Behavior

Terser plugin overoptimize function and changes it return params.

Code

module.exports = (function(constructor) {
  return constructor();
})(function() {
  return function(input) {
    var keyToMap = input.key;
    return {
      mappedKey: (function(value) {
        return value || "CONDITIONAL_DEFAULT_VALUE";
      })(keyToMap)
    };
  };
});

How Do We Reproduce?

https://github.com/roblan/webpack_terser_bug/tree/master

@roblan roblan changed the title overoptimize in certain condition optimized function changes behavour Feb 26, 2019
@alexander-akait
Copy link
Member

We just wrapper around terser, please post issue in terser repo

@roblan
Copy link
Author

roblan commented Feb 26, 2019

@evilebottnawi - but code parsed through terser works just fine

@alexander-akait
Copy link
Member

@roblan we don't change code, only send to terser and return, maybe other plugin do this

@roblan
Copy link
Author

roblan commented Feb 26, 2019

@evilebottnawi have you looked into provided example? only difference is minimizer: [new TerserPlugin()] in webpack config

@alexander-akait
Copy link
Member

alexander-akait commented Feb 26, 2019

@roblan yes, and as i said above we don't change you code, all optimizations do terser, if some optimizations break code or do something wrong please post issue in terser repo https://github.com/terser-js/terser

@roblan
Copy link
Author

roblan commented Feb 26, 2019

ok, thanks. just realised that flags --compress --mangle makes all the difference here

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

No branches or pull requests

2 participants