Skip to content

fix(config): prioritize explicit aliases over tsconfig paths - #3347

Merged
james-elicx merged 2 commits into
cloudflare:mainfrom
hyoban:fix/explicit-alias-precedence
Sep 21, 2026
Merged

james-elicx merged 2 commits into
cloudflare:mainfrom
hyoban:fix/explicit-alias-precedence

Conversation

@hyoban

@hyoban hyoban commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Explicit resolve.alias entries currently lose to Vinext's generated tsconfig aliases. Because those generated entries skip stylesheet resolution, CSS such as url("~@/icon.svg") can remain unresolved even when the app explicitly configures ~@. Dify worked around this with a post-order config plugin: langgenius/dify#42654.

Keep explicit Vite aliases ahead of generated aliases while preserving their order, regular expressions, and custom resolvers. Identify explicit Next config aliases by their source instead of comparing replacement values, so an explicit alias matching the tsconfig target still applies to CSS. Copy the resolve configuration before rearranging aliases so Vite can reuse the original inline aliases on server restart. Inferred tsconfig aliases continue to skip stylesheet resolution, preserving package CSS exports.

Next.js reference: its CSS loader resolves CSS imports and asset URLs through the bundler resolver. This change makes explicit Vite configuration usable without broadening inferred tsconfig aliases to CSS.

Validation

  • Added dev and production-build regressions for object aliases, regular expression aliases, custom resolvers, and explicit Next aliases matching tsconfig targets. Build checks verify that CSS URLs resolve to emitted files; dev checks repeat resolution after server.restart() to catch inline-config mutation.
  • 199 targeted tests passed; 2 platform-specific tests skipped across alias resolution, Vite 8 config, alias builds, build optimization, and Sass coverage.
  • pnpm run check passed, including repository-wide format, lint, type, Next.js type-sync, and shim checks.
  • PLAYWRIGHT_PROJECT=cloudflare-workers pnpm run test:e2e: 87 passed, 3 skipped after the restart fix.
  • Full test suite and other browser E2E projects were not run locally.

@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@3347

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@3347

@vinext/types

npm i https://pkg.pr.new/@vinext/types@3347

vinext

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

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@3347

commit: 4d3083c

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 4d3083c against base 94c5adc using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.3 KB 142.3 KB ⚫ -0.0%
Client entry size (gzip) vinext 129.7 KB 129.7 KB ⚫ +0.0%
Dev server cold start vinext 3.35 s 3.32 s ⚫ -1.0%
Production build time vinext 3.82 s 3.81 s ⚫ -0.4%
RSC entry closure size (gzip) vinext 127.5 KB 127.5 KB ⚫ +0.0%
Server bundle size (gzip) vinext 225.5 KB 225.5 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@hyoban
hyoban marked this pull request as ready for review September 21, 2026 14:15
@james-elicx

Copy link
Copy Markdown
Member

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx
james-elicx merged commit 83b507f into cloudflare:main Sep 21, 2026
66 checks passed
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.

2 participants