fix(compiler-sfc): support ${configDir} in paths for TypeScript 5.5+#13491
fix(compiler-sfc): support ${configDir} in paths for TypeScript 5.5+#13491edison1105 merged 5 commits intomainfrom
Conversation
WalkthroughA test was added validating TypeScript ${configDir} resolution with extended tsconfigs and project references. The resolver now conditionally substitutes ${configDir} in include/exclude and path patterns when TypeScript version is 5.5+ during multi-config resolution. Changes
Sequence Diagram(s)sequenceDiagram
participant TestRunner
participant SFCCompiler
participant TSResolver
participant FS
TestRunner->>SFCCompiler: compile SFC with extended tsconfigs + ${configDir}
SFCCompiler->>TSResolver: load tsconfig(s), request ts.versionMajorMinor
TSResolver-->>SFCCompiler: ts version (major.minor) and merged config
alt TS >= 5.5
SFCCompiler->>FS: resolve patterns by substituting ${configDir} with config dir
else TS < 5.5
SFCCompiler->>FS: resolve patterns via joinPaths(base, pattern) (no ${configDir} substitution)
end
FS-->>SFCCompiler: resolved include/exclude file list
SFCCompiler-->>TestRunner: resolved types and dependency list
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Out-of-scope changesNo out-of-scope functional changes detected. Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/compiler-sfc/src/script/resolveType.ts (1)
1048-1054: Minor style improvement – use optional chainingStatic-analysis already hints at it. The manual
excluded && …can be trimmed:- if ( - excluded && - excluded.some(p => isMatch(containingFile, getPattern(base, p))) - ) { + if ( + excluded?.some(p => isMatch(containingFile, getPattern(base, p))) + ) { continue }Touches no logic, just terser & consistent with the
included?.someabove.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts(1 hunks)packages/compiler-sfc/src/script/resolveType.ts(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/compiler-sfc/src/script/resolveType.ts
[error] 1052-1053: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
🔇 Additional comments (1)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts (1)
1158-1195: 👍 Robust regression testThe new case accurately reproduces #13484 and guards the compiler against future regressions in
${configDir}handling. No concerns.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1024d53 to
7588b4d
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/compiler-sfc/src/script/resolveType.ts (2)
1032-1039: Minor refactor opportunity: lift helper + version parsing out of the loop
const [major, minor] = …andfunction getPattern…are recreated every timeresolveWithTSis invoked. They only depend onts.versionMajorMinorandconfigPath, both of which are invariant during a single compiler run. Hoisting them to the outer scope ofresolveWithTS(or caching the parsed tuple) would avoid unnecessary re-allocation and keep the loop body slimmer.Not critical, just a readability / micro-perf improvement.
1050-1055: Use optional chaining to streamlineexcludedcheckSmall readability tweak: the explicit null check can be replaced with optional chaining.
- if ( - excluded && - excluded.some(p => isMatch(containingFile, getPattern(base, p))) - ) { + if ( + excluded?.some(p => isMatch(containingFile, getPattern(base, p))) + ) {No behavioural change; simply reduces nesting.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/compiler-sfc/src/script/resolveType.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/compiler-sfc/src/script/resolveType.ts (1)
packages/compiler-sfc/src/script/utils.ts (2)
normalizePath(107-109)joinPaths(111-112)
🪛 Biome (1.9.4)
packages/compiler-sfc/src/script/resolveType.ts
[error] 1053-1054: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (1)
packages/compiler-sfc/src/script/resolveType.ts (1)
1032-1038: Version-guard correctly future-proofed — looks goodThe new
supportsConfigDircheck (major > 5 || (major === 5 && minor >= 5)) removes the earlier logical gap for TS 6.x+ and resolves the concern raised in the previous review.
Implementation is clear and side-effect-free.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/compiler-sfc/src/script/resolveType.ts (2)
1032-1039: Protect against pre-release version strings & compute onceGood call switching to
major > 5 || (major === 5 && minor >= 5)– it future-proofs the guard.
Two minor nits:
Number('5.5-beta')becomesNaN, disabling the feature for nightly/beta drops.
UseparseInt(or a regex) to strip non-digits first.
supportsConfigDiris recalculated on everygetPatterninvocation although it’s invariant – lift it outside the arrow for micro clarity.-const [major, minor] = ts.versionMajorMinor.split('.').map(Number) +const [majorRaw, minorRaw] = ts.versionMajorMinor.split('.') +const major = parseInt(majorRaw, 10) +const minor = parseInt(minorRaw, 10) -const getPattern = (base: string, p: string) => { - // ts 5.5+ supports ${configDir} in paths - const supportsConfigDir = major > 5 || (major === 5 && minor >= 5) +// ts 5.5+ supports ${configDir} in paths +const supportsConfigDir = major > 5 || (major === 5 && minor >= 5) + +const getPattern = (base: string, p: string) => {
1049-1055: Use optional chaining to quiet lint & improve readabilityBiome flags this pattern check; a terse optional-chain keeps the meaning while removing an explicit null-guard:
- if ( - (!included && (!base || containingFile.startsWith(base))) || - included?.some(p => isMatch(containingFile, getPattern(base, p))) - ) { + if ( + (!included && (!base || containingFile.startsWith(base))) || + included?.some(p => isMatch(containingFile, getPattern(base, p))) + ) { if ( - excluded && - excluded.some(p => isMatch(containingFile, getPattern(base, p))) + excluded?.some(p => + isMatch(containingFile, getPattern(base, p)), + ) ) {This is purely stylistic – feel free to keep the existing guard if you prefer explicit checks.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/compiler-sfc/src/script/resolveType.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/compiler-sfc/src/script/resolveType.ts (1)
packages/compiler-sfc/src/script/utils.ts (2)
normalizePath(107-109)joinPaths(111-112)
🪛 Biome (1.9.4)
packages/compiler-sfc/src/script/resolveType.ts
[error] 1053-1054: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: continuous-release
- GitHub Check: test / e2e-test
- GitHub Check: test / unit-test-windows
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
close #13484
Summary by CodeRabbit
New Features
Tests