diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 49617b16de9ac2..ee8993a9457118 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -893,6 +893,15 @@ export function onRollupWarning( return } + // Rollup tracks the build phase slightly earlier before `buildEnd` is called, + // so there's a chance we can call `this.addWatchFile` in the invalid phase. Skip for now. + if ( + warning.plugin === 'vite:worker-import-meta-url' && + warning.pluginCode === 'INVALID_ROLLUP_PHASE' + ) { + return + } + if (warningIgnoreList.includes(warning.code!)) { return }