Commit 6351004
authored
chore(build): strip console.* from production bundles (#257)
Resolves: #256
## PR Objective
Make logging a dev-only affair: every `console.*` call (including
`console.error`) is stripped from production bundles at build time,
while development and test behavior stays exactly as it is today. The
app has no crash reporting that would consume production logs, so in
release builds they only added bundle weight and leaked internal error
messages into system logs (`adb logcat` / os_log).
## What changed?
* **`babel-plugin-transform-remove-console`** added as a devDependency.
* **`babel.config.js`:** new `env.production` block enabling the plugin.
Metro sets `BABEL_ENV=production` for release bundles, so the transform
applies only there — dev bundles and Jest (`test` env) are untouched.
* **No `exclude` list on purpose:** `console.error` is stripped too. If
we ever add crash reporting, the follow-up should route errors through a
logger instead of re-keeping raw `console.error`.
* **Zero call-site changes:** all ~37 existing `console.warn` /
`console.error` calls across stores, hooks, and components stay as they
are — the transform removes them from the release output.
## Verification
* Ran a sample module through the project's real Babel config in both
env modes:
* `development` → all of `log` / `warn` / `error` / `info` / `debug`
kept,
* `production` → all stripped.
* Full Jest suite and ESLint pass.
> **Note for local release builds:** reset the Metro cache once (`yarn
start --reset-cache`) so the new transform takes effect.1 parent 7ed1e5a commit 6351004
3 files changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4290 | 4290 | | |
4291 | 4291 | | |
4292 | 4292 | | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
4293 | 4300 | | |
4294 | 4301 | | |
4295 | 4302 | | |
| |||
10287 | 10294 | | |
10288 | 10295 | | |
10289 | 10296 | | |
| 10297 | + | |
10290 | 10298 | | |
10291 | 10299 | | |
10292 | 10300 | | |
| |||
0 commit comments