Add sideEffects to package.json in /shared - #605
Conversation
|
I can't guarantee that we're not using it in something that lives outside our GitHub org (e.g. EVQ or something at cu-mkp?) but it appears that we're only using this component in FairCopy Activate, which AFAIK is no longer being used (tagging @NickLaiacona to confirm). https://github.com/search?q=org%3Aperformant-software+withGoogleAnalytics&type=code Archnet rolls its own and it's a lot closer to how GA typically suggests setting it up: https://github.com/performant-software/archnet3/blob/6db713b296081ad89f25d7da119bbe2e8211ddb9/packages/web/components/GoogleAnalyics.js#L8 That is to say, I wonder if we need to keep the GA component here at all. |
Yeah, that is a great question. I was going off the framing in Issue #595 but I can definitely imagine that the cleanest solution to this particular issue would be just getting rid of the component. Probably should wait for @jamiefolsom's thoughts on it. |
|
I'd also vote for getting rid of the component if it's easy enough to make that change across any repos using it. Otherwise this also seems fine.
If we do decide to go this route—can you test with |
|
I can confirm that FairCopy Activate is no longer in production |
In this PR
Addresses Issue #595 by adding an explicit list of
sideEffectsto theshared-componentspackage to allow more aggressive tree-shaking by consuming applications. This avoids the issue of bundling a component built onreact-ga4(from theAnalyticscomponent of the packagethat includes a gtag injector. Adding thesideEffectsfield inpackage.jsonallows theAnalytics` component to be shaken out of the bundle if unused.Notes and questions
npm link; I built theshared-componentsbundle and then imported it into FDS and rannetlify build, and verified that a) the gtag script is not included in the output and b) the imports from theshared-componentsmodule still function in the built site (e.g. the fuzzy date utils, which seems to be the main thing FDS uses from this package).shared-componentsit's not uncommon for it to be imported into the site just to use the date utils or whatever and we don't want to introduce bloat into the built site, but still something to be aware of.