From 1d5adf7efc2fd01e452e8d90e009b2170c721e15 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 21 Feb 2025 17:48:09 +0900 Subject: [PATCH] fix(css): temporary add `?.` after `this.getModuleInfo` in `vite:css-post` --- packages/vite/src/node/plugins/css.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 3834788611fc2e..0f3ba9c2b2c304 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -645,11 +645,15 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { // build CSS handling ---------------------------------------------------- - const cssScopeTo = ( - this.getModuleInfo(id)?.meta?.vite as - | CustomPluginOptionsVite - | undefined - )?.cssScopeTo + const cssScopeTo = + // NOTE: `this.getModuleInfo` can be undefined when the plugin is called directly + // adding `?.` temporary to avoid unocss from breaking + // TODO: remove `?.` after `this.getModuleInfo` in Vite 7 + ( + this.getModuleInfo?.(id)?.meta?.vite as + | CustomPluginOptionsVite + | undefined + )?.cssScopeTo // record css if (!inlined) {