dillon1000/react

Commit

Constant propagation for globals

This PR updates ConstantPropagation to support propagating global references: 

```javascript 

// Before 

const x = Math; 

foo(x); 

// After 

foo(Math); 

``` 

This is a generally useful optimization but also helps with a subset of cases 
around JSX element tags, which are frequently globals.
Browse files
Changed paths4 files
First-parent comparison
M compiler/forget/src/HIR/HIR.ts ModifiedM compiler/forget/src/Optimization/ConstantPropagation.ts ModifiedM compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/useRef-rename-mutable.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…