(minifyOptions)
| 1 | // Normalize Terser options from microbundle's relaxed JSON format (mutates argument in-place) |
| 2 | export function normalizeMinifyOptions(minifyOptions) { |
| 3 | // ignore normalization if "mangle" is a boolean: |
| 4 | if (typeof minifyOptions.mangle === 'boolean') return; |
| 5 | |
| 6 | const mangle = minifyOptions.mangle || (minifyOptions.mangle = {}); |
| 7 | let properties = mangle.properties; |
| 8 | |
| 9 | // allow top-level "properties" key to override mangle.properties (including {properties:false}): |
| 10 | if (minifyOptions.properties != null) { |
| 11 | properties = mangle.properties = |
| 12 | minifyOptions.properties && |
| 13 | Object.assign(properties, minifyOptions.properties); |
| 14 | } |
| 15 | |
| 16 | // allow previous format ({ mangle:{regex:'^_',reserved:[]} }): |
| 17 | if (minifyOptions.regex || minifyOptions.reserved) { |
| 18 | if (!properties) properties = mangle.properties = {}; |
| 19 | properties.regex = properties.regex || minifyOptions.regex; |
| 20 | properties.reserved = properties.reserved || minifyOptions.reserved; |
| 21 | } |
| 22 | |
| 23 | if (properties) { |
| 24 | if (properties.regex) properties.regex = new RegExp(properties.regex); |
| 25 | properties.reserved = [].concat(properties.reserved || []); |
| 26 | } |
| 27 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…