#1652 added the Temporal, Duration, and DurationFormat class names to tools/domprops.js, which is great — but the field/option names that these (and Intl.DateTimeFormat) read off their argument objects aren't in the list, so mangle.properties silently breaks them.
Repro
// terser --mangle-props -- input.js
const units = { hours: 1, minutes: 30 };
new Intl.DurationFormat('en').format(units);
becomes
const e = { a: 1, b: 30 };
new Intl.DurationFormat("en").format(e);
// → TypeError: Did not provide any valid Duration fields.
Intl.DateTimeFormat and Intl.RelativeTimeFormat fail the same way, just more quietly:
new Intl.DateTimeFormat('en', { timeZoneName: 'short' }).formatToParts(new Date());
// after mangling: option is dropped, no timeZoneName part is emitted
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(-1, 'day');
// after mangling: numeric:'auto' is dropped, falls back to 'always'
Missing names
Intl.DurationFormat (Duration Record fields, per the spec):
years, months, weeks, days, hours, minutes, seconds,
milliseconds, microseconds, nanoseconds
Intl.DateTimeFormat options (per ecma-402):
weekday, era, year, month, day, dayPeriod,
hour, minute, second, fractionalSecondDigits,
hour12, hourCycle, dateStyle, timeStyle,
timeZone, timeZoneName, calendar, numberingSystem
(Several singulars — year, month, day, hour, etc. — also cover Temporal record fields used in object-literal arguments to Temporal.PlainDate.from(...) and friends.)
Intl.RelativeTimeFormat options:
Workaround
Currently every consumer has to spell these out themselves:
mangle: { properties: { reserved: ['years', 'months', /* ... */ 'timeZoneName'] } }
It would be much friendlier to have these in domprops.js alongside the class names that #1652 already added.
Happy to send a PR.
#1652 added the
Temporal,Duration, andDurationFormatclass names totools/domprops.js, which is great — but the field/option names that these (andIntl.DateTimeFormat) read off their argument objects aren't in the list, somangle.propertiessilently breaks them.Repro
becomes
Intl.DateTimeFormatandIntl.RelativeTimeFormatfail the same way, just more quietly:Missing names
Intl.DurationFormat(Duration Record fields, per the spec):Intl.DateTimeFormatoptions (per ecma-402):(Several singulars —
year,month,day,hour, etc. — also cover Temporal record fields used in object-literal arguments toTemporal.PlainDate.from(...)and friends.)Intl.RelativeTimeFormatoptions:Workaround
Currently every consumer has to spell these out themselves:
It would be much friendlier to have these in
domprops.jsalongside the class names that #1652 already added.Happy to send a PR.