Skip to content

Conversation

babu-ch
Copy link
Contributor

@babu-ch babu-ch commented Sep 7, 2025

fix #2253

Summary by CodeRabbit

  • Bug Fixes
    • Production DevTools now default to disabled when the related feature flag is missing or misconfigured, preventing accidental exposure in production builds. Behavior is aligned with existing i18n DevTools handling. No API changes.
  • Chores
    • Standardized feature-flag initialization for consistent behavior across environments, improving predictability and reducing configuration errors.
fix: Set default value for __FEATURE_PROD_VUE_DEVTOOLS__ flag
Copy link

coderabbitai bot commented Sep 7, 2025

Walkthrough

Adds a guard in initFeatureFlags to define a global VUE_PROD_DEVTOOLS as false when the corresponding feature flag is not a boolean, mirroring existing handling for INTLIFY_PROD_DEVTOOLS. No public APIs or signatures changed.

Changes

Cohort / File(s) Summary
Feature-flag initialization
packages/vue-i18n-core/src/misc.ts
Extend initFeatureFlags: if __FEATURE_PROD_VUE_DEVTOOLS__ is not boolean, initialize global __VUE_PROD_DEVTOOLS__ = false; keep existing logic intact.

Sequence Diagram(s)

sequenceDiagram participant Importer as Consumer (SSR/App) participant Module as vue-i18n-core/misc participant Global as Global Scope Importer->>Module: import/init activate Module Module->>Module: initFeatureFlags() alt __FEATURE_PROD_VUE_DEVTOOLS__ not boolean Module->>Global: set __VUE_PROD_DEVTOOLS__ = false else already boolean Module->>Global: leave as-is end Note over Module,Global: Mirrors existing __INTLIFY_PROD_DEVTOOLS__ guard deactivate Module 
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Prevent ReferenceError by ensuring VUE_PROD_DEVTOOLS is defined when externalized (#[2253])

Poem

Thump-thump, I flip a feature flag switch,
No more errors hopping from a glitch!
In SSR fields where imports roam,
Devtools booleans find a home.
Carrot-shaped guards stand bold and fine—
Now i18n compiles just divine. 🥕✨

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/vue-i18n-core/src/misc.ts (1)

32-34: Confirm early invocation order to avoid residual ReferenceError.

This guard only helps if initFeatureFlags() runs before any bare uses of __VUE_PROD_DEVTOOLS__.

Run to confirm it’s invoked in ESM-bundler entrypoints:

#!/bin/bash # Where is initFeatureFlags imported/called? rg -nP '\binitFeatureFlags\s*\(' -C3 --type=ts # Also check for unsafe bare reads that could execute before the guard rg -nP '(?<!typeof\s)\b__VUE_PROD_DEVTOOLS__\b' -C2 --type=ts -g '!*dist/**'

If unsafe reads are found, I can propose minimal patches to wrap them with typeof checks or use getGlobalThis().__VUE_PROD_DEVTOOLS__.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdc9541 and 70666ea.

📒 Files selected for processing (1)
  • packages/vue-i18n-core/src/misc.ts (1 hunks)
🔇 Additional comments (2)
packages/vue-i18n-core/src/misc.ts (2)

32-34: Good guard; mirrors existing INTLIFY flag default.

Setting __VUE_PROD_DEVTOOLS__ to false when the feature macro isn’t defined should prevent the SSR ReferenceError in externalized builds. Placement aligns with the existing pattern above.


32-34: Ensure macro typings and build defines exist.

TypeScript will error if __FEATURE_PROD_VUE_DEVTOOLS__ isn’t declared, and the build should optionally define it when enabling prod devtools.

Run to verify typings and defines:

#!/bin/bash # 1) Macro typings (should exist alongside other feature-flag declarations) rg -nP '__FEATURE_PROD_VUE_DEVTOOLS__|__VUE_PROD_DEVTOOLS__' -g '*.{d.ts,ts}' # 2) Build-time defines (rollup/vite/esbuild configs or scripts) rg -nP '__FEATURE_PROD_VUE_DEVTOOLS__|__VUE_PROD_DEVTOOLS__' -g '*.{js,cjs,mjs,ts}' -S \ -C3 -g '!*node_modules/**'
@kazupon
Copy link
Member

kazupon commented Sep 7, 2025

@babu-ch
Thank you for your contribution!
And I must apologize to you. 🙇

This is not a bug, and it is already fixable.
I applied an inappropriate label in 2253, causing you to misunderstand.
I’m so sorry for you.

__FEATURE_PROD_VUE_DEVTOOLS__ of nich topic, it has already handled on vue/core, but why I don't know this error occured it.
https://github.com/vuejs/core/blob/75220c7995a13a483ae9599a739075be1c8e17f8/packages/runtime-core/src/featureFlags.ts#L16-L18

@kazupon kazupon closed this Sep 7, 2025
@babu-ch
Copy link
Contributor Author

babu-ch commented Sep 7, 2025

@kazupon
Thank you for checking. No problem!

@babu-ch babu-ch deleted the fix/env_devtool branch September 7, 2025 14:00
@babu-ch
Copy link
Contributor Author

babu-ch commented Sep 7, 2025

So that flag is set by Vue. I learned something 👍

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

Labels

None yet

2 participants