Consider keeping class properties in loose mode
See original GitHub issueI was against https://github.com/facebook/create-react-app/pull/4248 but thought a bit more about it and now I’m not sure.
We already deviate from the spec. That’s not great, but that’s an existing problem. We can choose to address it now or we can choose to address it later.
React apps rely on class properties for defining methods and state. However Object.defineProperty
is known to be relatively expensive (at least it used to be). That doesn’t mean browser’s native implementation would necessarily be expensive (I don’t think anyone measured). But that switching from existing output to new output will likely introduce performance regressions.
How severe will this regression be? I don’t know. But we need to further explore this tradeoff. In particular we might want to measure the regression on a large React project that relies a lot on class properties. If it’s significant we might want to enable loose behavior, and postpone changing it to be spec-compliant until we have some plan for addressing this.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
👍 I’m cool with this.
Yeah 👍 to changing. I was hesitant to make it default but overall that seems like the best decision as a compiler even if it means “config” for users. I guess it’s what people expect already, hard to decide