From 73bfd64328524722f0bf00d4e4ccad5042f7c24f Mon Sep 17 00:00:00 2001 From: taylorliu Date: Tue, 15 Jun 2021 02:46:54 +0800 Subject: [PATCH 1/2] fix: fix error on directly use transformRequest api --- packages/vite/src/node/plugins/css.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 85a8b6daaf037c..1cddfb2d207cda 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -246,7 +246,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return } - const modules = cssModulesCache.get(config)!.get(id) + const modules = cssModulesCache.get(config) && cssModulesCache.get(config)!.get(id) const modulesCode = modules && dataToEsm(modules, { namedExports: true, preferConst: true }) From 50c192d1194e687b4fafa9dc078557551bcb65a2 Mon Sep 17 00:00:00 2001 From: taylorliu Date: Tue, 15 Jun 2021 15:36:22 +0800 Subject: [PATCH 2/2] simplify null check --- packages/vite/src/node/plugins/css.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 1cddfb2d207cda..48d19b14873aee 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -246,7 +246,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return } - const modules = cssModulesCache.get(config) && cssModulesCache.get(config)!.get(id) + const modules = cssModulesCache.get(config)?.get(id) const modulesCode = modules && dataToEsm(modules, { namedExports: true, preferConst: true })