Skip to content

refactor: remove dead code identified by static analysis#573

Draft
Divkix wants to merge 2 commits intocloudflare:mainfrom
Divkix:refactor/remove-dead-code
Draft

refactor: remove dead code identified by static analysis#573
Divkix wants to merge 2 commits intocloudflare:mainfrom
Divkix:refactor/remove-dead-code

Conversation

@Divkix
Copy link
Contributor

@Divkix Divkix commented Mar 17, 2026

This PR removes dead code identified through comprehensive static analysis across the codebase.

Dead Code Removed

1. cloudflare/index.ts

  • Removed unused type exports TPROptions and TPRResult (never imported from public API)

2. entries/app-ssr-entry.ts

  • Removed unused collectStreamChunks function (defined but never called)

3. entries/pages-server-entry.ts

  • Removed 3 unused i18n helper functions:
    • extractLocale - duplicate of functionality in pages-i18n.ts
    • detectLocaleFromHeaders - never called
    • parseCookieLocaleFromHeader - never called

4. routing/file-matcher.ts

  • Removed export from DEFAULT_PAGE_EXTENSIONS (internal constant)
  • Removed export from buildExtensionGlob (internal function)

5. routing/utils.ts

  • Removed export from routePrecedence (only used internally by compareRoutes)
  • Removed export from decodeRouteSegmentStrict (only used internally)

6. shims/internal/utils.ts

  • Removed unused constants SP and ST (defined but never referenced)

Methodology

The dead code was identified by:

  1. Searching for exported functions/constants/types that have no imports across the codebase
  2. Identifying private functions that are defined but never called within their files
  3. Cross-referencing each export against test files, entry points, and other source files

Impact

  • 75 lines of dead code removed
  • No functional changes - all removed code was genuinely unused
  • Reduces bundle size and maintenance surface area

Remove unused exports and private functions that were never called:

- cloudflare/index.ts: Remove unused type exports TPROptions, TPRResult
- app-ssr-entry.ts: Remove unused collectStreamChunks function
- pages-server-entry.ts: Remove unused i18n helpers (extractLocale,
  detectLocaleFromHeaders, parseCookieLocaleFromHeader)
- routing/file-matcher.ts: Remove export from internal-only
  DEFAULT_PAGE_EXTENSIONS and buildExtensionGlob
- routing/utils.ts: Remove export from internal-only routePrecedence
  and decodeRouteSegmentStrict
- shims/internal/utils.ts: Remove unused SP and ST constants

These were identified as dead code through cross-referencing exports
against imports across the entire codebase.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@573

commit: d8fc66d

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