MCPcopy Create free account
hub / github.com/developit/microbundle / normalizeMinifyOptions

Function normalizeMinifyOptions

src/lib/terser.js:2–27  ·  view source on GitHub ↗
(minifyOptions)

Source from the content-addressed store, hash-verified

1// Normalize Terser options from microbundle's relaxed JSON format (mutates argument in-place)
2export 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}

Callers 1

createConfigFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…