Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ function prettifyMessage(m: EsbuildMessage, code: string): string {
let globalTSConfigResolutionCache: TsconfigCache | undefined
const tsconfigResolutionCacheMap = new WeakMap<ResolvedConfig, TsconfigCache>()

function getTSConfigResolutionCache(config?: ResolvedConfig) {
export function getTSConfigResolutionCache(
config?: ResolvedConfig,
): TsconfigCache {
if (!config) {
return (globalTSConfigResolutionCache ??= new TsconfigCache())
}
Expand Down
18 changes: 15 additions & 3 deletions packages/vite/src/node/plugins/oxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { type Environment, perEnvironmentPlugin } from '..'
import type { ViteDevServer } from '../server'
import { JS_TYPES_RE, VITE_PACKAGE_DIR } from '../constants'
import type { Logger } from '../logger'
import type { ESBuildOptions } from './esbuild'
import { type ESBuildOptions, getTSConfigResolutionCache } from './esbuild'

// IIFE content looks like `var MyLib = (function() {` or `this.nested.myLib = (function() {`.
export const IIFE_BEGIN_RE: RegExp =
Expand All @@ -31,7 +31,14 @@ const validExtensionRE = /\.\w+$/

export interface OxcOptions extends Omit<
OxcTransformOptions,
'cwd' | 'sourceType' | 'lang' | 'sourcemap' | 'helpers'
| 'cwd'
| 'sourceType'
| 'lang'
| 'sourcemap'
| 'helpers'
| 'inject'
| 'tsconfig'
| 'inputMap'
> {
include?: string | RegExp | ReadonlyArray<string | RegExp>
exclude?: string | RegExp | ReadonlyArray<string | RegExp>
Expand Down Expand Up @@ -143,7 +150,12 @@ export async function transformWithOxc(
lang,
}

const result = transformSync(filename, code, resolvedOptions)
const result = transformSync(
filename,
code,
resolvedOptions,
getTSConfigResolutionCache(config),
)
if (
watcher &&
config &&
Expand Down