Skip to content

WIP: Strip debug logs in production builds#138

Open
Kombustor wants to merge 1 commit intomainfrom
feature/strip-debug-logs
Open

WIP: Strip debug logs in production builds#138
Kombustor wants to merge 1 commit intomainfrom
feature/strip-debug-logs

Conversation

@Kombustor
Copy link
Contributor

Summary

What does this change do?

Motivation

Why is this change needed?

Testing

  • pnpm lint
  • pnpm test
  • Tested on: Android TV / Android / tvOS (specify)

Screenshots / Video (if UI)

Attach if relevant.

Comment on lines +10 to +14
const isProduction = process.env.NODE_ENV === 'production';

if (isProduction && stripDebugLogs) {
console.log("Babel: Stripping debug calls from production build");
plugins.push('./plugins/babel-plugin-strip-debug-calls.js');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The Babel config requires both STRIP_DEBUG_LOGS and NODE_ENV === 'production', but NODE_ENV is not set during local EAS production builds, preventing log stripping.
Severity: MEDIUM

Suggested Fix

Rely on a single source of truth for enabling the plugin. Either use api.caller() as suggested by the code comment to detect the build mode, or only check process.env.STRIP_DEBUG_LOGS, which is correctly configured in eas.json for different build profiles. This will ensure consistent behavior across local and CI/CD builds.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: babel.config.js#L10-L14

Potential issue: In `babel.config.js`, the `transform-remove-console` plugin is only
enabled if both `stripDebugLogs` and `isProduction` are true. The `isProduction` flag
relies on `process.env.NODE_ENV === 'production'`. During a local EAS production build
(e.g., `eas build --local --profile production`), `eas.json` correctly sets
`STRIP_DEBUG_LOGS`, but `NODE_ENV` is not set and may default to `'development'`. This
causes the `isProduction` check to fail, preventing the plugin from running and leaving
debug logs in production builds created locally. This does not affect CI/CD builds where
`NODE_ENV` is explicitly set.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant