Function swc_ecma_transforms_optimization::json_parse

source ·
pub fn json_parse(min_cost: usize) -> impl Fold
Expand description

Transform to optimize performance of literals.

This transform converts pure object literals like

{a: 1, b: 2}

to

JSON.parse('{"a":1, "b"}')

§Conditions

If any of the conditions below is matched, pure object literal is converter to JSON.parse

  • Object literal is deeply nested (threshold: )

See https://github.com/swc-project/swc/issues/409