Skip to content

Commit 40985f1

Browse files
authored
fix(resolve): provide onWarn for viteResolvePlugin in JS plugin containers (#22509)
1 parent c917f1e commit 40985f1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/vite/src/node/idResolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export function createIdResolver(
7474
idOnly: true,
7575
},
7676
environment.config,
77+
true,
7778
),
7879
],
7980
undefined,

packages/vite/src/node/plugins/resolve.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ const perEnvironmentOrWorkerPlugin = (
223223
export function oxcResolvePlugin(
224224
resolveOptions: ResolvePluginOptionsWithOverrides,
225225
overrideEnvConfig: (ResolvedConfig & ResolvedEnvironmentOptions) | undefined,
226+
isJsPluginContainer = false,
226227
): Plugin[] {
227228
return [
228229
...(resolveOptions.optimizeDeps && !resolveOptions.isBuild
@@ -358,10 +359,12 @@ export function oxcResolvePlugin(
358359
})
359360
},
360361

361-
...(partialEnv.config.command === 'serve'
362+
...(partialEnv.config.command === 'serve' || isJsPluginContainer
362363
? {
363364
async onWarn(msg) {
364-
getEnv().logger.warn(`warning: ${msg}`, {
365+
// use `partialEnv` instead of `getEnv()` because `buildStart` is
366+
// not called for plugin container used by `createIdResolver`
367+
partialEnv.config.logger.warn(`warning: ${msg}`, {
365368
clear: true,
366369
timestamp: true,
367370
})

0 commit comments

Comments
 (0)