Closed kohlmannj closed 2 years ago
I took a moment to test this in the Monorepo. I found that nytimes/news#517 unconditionally sets useProductionTransforms: false
for all Monorepo libraries that use babel-preset-kyt-react
. I don't know why this was, and thus, I no longer want to tie babel-plugin-pure-static-props
to it.
Therefore, I am going to revise this PR to unconditionally enable babel-plugin-pure-static-props
, as previously hinted at in the original PR description.
Meanwhile, I feel confident that, in addition to more local testing, a corresponding Monorepo PR after merging and releasing this PR will be enough to tell us whether it's safe to unconditionally enable this plugin.
TL;DR — One change coming!
Turns out I'm closing this PR. These test failures are representative of an issue I encountered with at least one source file in the Monorepo. I have no idea what to do about it, as the issue seems to lie within the plugin itself. And diagnosing that issue, while potentially valuable in the long term, moves this from a "quick fix" (just add plugin) to "potentially more involved fix."
Anyway, closing for now since unconditionally enabling babel-plugin-pure-static-props
could cause build errors.
relates to DSYS-10
Description
This PR adds
babel-plugin-pure-static-props
tobabel-preset-kyt-react
's set of production transforms (enabled when the preset'sproductionTransforms
option is set totrue
).Motivation / Background
Static properties on [React] components break tree-shaking: https://github.com/styled-components/babel-plugin-styled-components/issues/245#issuecomment-525844957
This same commenter created
babel-plugin-pure-static-props
to address this. From its README:This is an especially important optimization for
babel-preset-kyt-react
because we add the static propertydisplayName
to every React component viababel-plugin-add-react-displayname
. That is, this plugin is always enabled. (For that reason, we may consider always enablingbabel-plugin-pure-static-props
as well.)