[Moment.js, Angular, es2015] Strange daysInMonth function transformation
Bug report or feature request? Bug
ES5 or ES6+ input? ES6
Uglify version (uglifyjs -V)
npm list uglify-es
└─┬ @angular/[email protected]
└─┬ [email protected]
└── [email protected]
JavaScript input The Moment.js has the function daysInMonth.
export function daysInMonth(year, month) {
if (isNaN(year) || isNaN(month)) {
return NaN;
}
var modMonth = mod(month, 12);
year += (month - modMonth) / 12;
return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
}
The uglifyjs CLI command executed or minify() options used.
JavaScript output or error produced.
When Angular builded project with tsconfig.json target = es2015, then the function is transformed to:
function je(e, t) {
if (isNaN(e) || isNaN(t))
return NaN;
return e += (t - NaN) / 12,
NaN
}
@mantyz could you facilitate what options uglifyjs was called with? I can't seem to reproduce
@fabiosantoscode, If I understand correctly, then these options are used: https://github.com/angular/angular-cli/blob/e48d54558f3640920a6adf6793bcf5eb1b9e4070/packages/%40angular/cli/models/webpack-configs/production.ts#L164
@filipesilva, Correct me, please, if I'm wrong. And maybe this problem does not Uglify?
A code fragment out of context is not a bug reproduction. Please follow the issue template.
**JavaScript input**
A complete parsable JS program exhibiting the issue with
UglifyJS alone - without third party tools or libraries.
Ideally the input should be as small as possible.
Post a link to a gist if necessary.
Issues without a reproducible test case will be closed.
It seems to be related to the Angular Build Optimizer. Excuse for troubling.