Closed steveluscher closed 1 week ago
Latest commit: 88d5b025ccdb2375c1bbcb9fe9e27f805fd3a1fe
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
This stack of pull requests is managed by Graphite. Learn more about stacking.
Join @steveluscher and the rest of your teammates on Graphite
@steveluscher Just catching up on that. Does that mean I need to replicate that change to the program repos? Since we also use a __DEV__
variable on the generated code to avoid bundling error messages.
Definitely! It basically doesn't work with the env-shim
method. This method results in actual DCE.
How would you feel about process.env.NODE_ENV === 'development'
being generated directly by Kinobi instead of using a __DEV__
variable that needs to be replaced at build time? The issue with the latter is that anyone the generates code using Kinobi now needs to implement the same pre-processing build step which is a concern we've already received from the community.
:tada: This PR is included in version 1.93.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@steveluscher Just bumping that in case the GitHub bot made you mark this as done. 😇
How would you feel about process.env.NODE_ENV === 'development' being generated directly by Kinobi instead of using a DEV variable that needs to be replaced at build time?
Much better. This is what web3.js does now, essentially. Nobody except for us developers ever see __DEV__
; it's just a shorthand for us that gets replaced with { development flag expression du jour }.
Summary
Previously, we were using the hair-brained
inject
feature of ESBuild to try to replace all instances of__DEV__
with something resemblingprocess.env.NODE_ENV === 'development'
. This just didn't work.In this PR we replace it with the literal
process.env.NODE_ENV === 'development'
, pre-sourcemaps, and only inline the actual value ofNODE_ENV
in iife bundles.Test Plan
Consider the application in #2817.
pnpm build
it.Before
After (5% reduction in total application bundle size)