Skip to content

refactor(i18n): align analysis with Vite environment graphs - #42656

Merged
hyoban merged 24 commits into
mainfrom
refactor/vite-i18n-analysis
Sep 21, 2026
Merged

hyoban merged 24 commits into
mainfrom
refactor/vite-i18n-analysis

Conversation

@hyoban

@hyoban hyoban commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #42655

The i18n analyzer could read disk modules that differed from Vite’s runtime imports. Analyze completed client, SSR and RSC graphs using environment-specific resolution, preserve query/JSON module identities, and block stale disk fallback after changed or untraceable imports. Connect environments only through explicit RSC client references.

Keep namespace inference limited to literals, inline arrays and immutable string constants. Runtime parameters, function results and bound arrays remain unknown. Expose an adapters option for custom translation APIs (source module, export name, namespace/selector argument indexes and optional private forwarding functions). Keep Dify registrations in vite.config.ts; the plugin only hardcodes official API names. Analyze registered calls through aliases/re-exports and verify Dify forwarding contracts against the actual wrappers. Dynamic adapter arguments remain unknown. Retain TypeScript selector/key matching and conservative dynamic-key protection; external dependencies and generated resource helpers are analysis boundaries rather than individual warnings.

Print a compact build summary and write full route groups, source evidence and shared dependency paths to i18n-routes.json. Signin validates detected namespace usage; rejecting unknown namespaces remains opt-in. This is a static estimate, not proof of complete runtime coverage, and does not change translation loading.

Make 12 finite business translation calls statically visible and remove five obsolete explore keys from all 25 locales. Reuse catalog indexes and identical multi-format analysis only within the current build.

Screenshots

No visual changes. Console output now shows counts and the report path instead of listing every route.

Validation

  • 105 analyzer tests, 5 adapter contract tests and 23 server translation tests pass. The preceding final review also passed 119 related component/hook tests. Coverage includes environment isolation, repeated builds, multi-format reuse, rewritten/virtual/external imports, query/JSON modules, strict validation and compact console output with detailed JSON retained.
  • Repository-wide pnpm exec vp run -w check and pnpm exec vp staged pass.
  • Full pnpm run build:vinext passes, including standalone packaging; no additional unused keys.
  • Production report: 110 routes, 2 unknown-namespace records from the runtime route Provider, 6 dynamic-key records protecting permissionKeys, and 0 unresolved application import warnings. The shared runtime Provider remains an unknown source on all routes; opaque dependencies are intentionally outside warning scope.

Checklist

  • This change requires a documentation update, included: Dify Document (not required; internal plugin README updated)
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran vp staged (frontend); backend checks are not applicable.

@github-actions github-actions Bot added the web This relates to changes on the web. label Sep 21, 2026
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.65211% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.61%. Comparing base (1dfa873) to head (928bc73).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
web/plugins/vite/i18n-analysis/compiler.ts 95.75% 9 Missing ⚠️
web/app/components/workflow/hooks/use-checklist.ts 54.54% 5 Missing ⚠️
web/plugins/vite/i18n-analysis/graph.ts 96.85% 4 Missing ⚠️
web/plugins/vite/i18n-analysis.ts 96.87% 3 Missing ⚠️
...in-detail-panel/subscription-list/create/index.tsx 80.00% 1 Missing ⚠️
web/plugins/vite/i18n-analysis/catalog.ts 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #42656      +/-   ##
==========================================
+ Coverage   87.58%   87.61%   +0.02%     
==========================================
  Files        5471     5475       +4     
  Lines      318394   319027     +633     
  Branches    63818    64074     +256     
==========================================
+ Hits       278874   279518     +644     
+ Misses      34129    34118      -11     
  Partials     5391     5391              
Flag Coverage Δ
dify-ui 91.70% <ø> (ø)
web 88.03% <96.65%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hyoban
hyoban marked this pull request as ready for review September 21, 2026 13:05
@hyoban
hyoban added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 11be533 Sep 21, 2026
92 of 94 checks passed
@hyoban
hyoban deleted the refactor/vite-i18n-analysis branch September 21, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Vite i18n analysis resolution and diagnostic reports

2 participants