From 620f746e03ba57c98314573d13a654eb7545467c Mon Sep 17 00:00:00 2001 From: Daniil Suvorov Date: Sat, 9 Sep 2023 19:28:51 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20bad=20env=20NODE=5FENVIRONMENT=20=D0=A1?= =?UTF-8?q?=D0=BB=D0=BE=D0=BC=D0=B0=D0=BB=D0=B0=D1=81=D1=8C=20=D1=81=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D0=B0=20=D0=B2=20vite=20=D0=B8=D0=B7-=D0=B7?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9.=20=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20`NODE=5FENVIRONMEN?= =?UTF-8?q?T`=20=D0=B2=20`NODE=5FENV`=20=D0=B8=20=D1=84=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D0=BC=20=D0=B2=20=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdaptivityProvider/AdaptivityProvider.tsx | 2 +- packages/vkui/src/components/AppRoot/AppRoot.tsx | 2 +- .../components/ConfigProvider/ConfigProvider.tsx | 2 +- packages/vkui/types/env.d.ts | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/vkui/src/components/AdaptivityProvider/AdaptivityProvider.tsx b/packages/vkui/src/components/AdaptivityProvider/AdaptivityProvider.tsx index 24e53d8e39..421d6b78dc 100644 --- a/packages/vkui/src/components/AdaptivityProvider/AdaptivityProvider.tsx +++ b/packages/vkui/src/components/AdaptivityProvider/AdaptivityProvider.tsx @@ -33,7 +33,7 @@ export const AdaptivityProvider = ({ const LEGACY_bridge = useBridgeAdaptivity(LEGACY_disableInternalUseBridgeAdaptivity); /* eslint-enable @typescript-eslint/naming-convention */ - if (process.env.NODE_ENVIRONMENT === 'development') { + if (process.env.NODE_ENV === 'development') { // TODO [>=6]: удалить warn if (!LEGACY_disableInternalUseBridgeAdaptivity) { warn("[@vkontakte/vk-bridge] Интеграция VKUI с @vkontakte/vk-bridge устарела и будет удалена в v6. Используйте хук `useAdaptivity()` из @vkontakte/vk-bridge-react и результат передайте в компонент (см. https://github.com/VKCOM/VKUI/issues/5049)"); // prettier-ignore diff --git a/packages/vkui/src/components/AppRoot/AppRoot.tsx b/packages/vkui/src/components/AppRoot/AppRoot.tsx index 4455687416..7e61c2c0a8 100644 --- a/packages/vkui/src/components/AppRoot/AppRoot.tsx +++ b/packages/vkui/src/components/AppRoot/AppRoot.tsx @@ -100,7 +100,7 @@ export const AppRoot = ({ const { hasPointer, sizeX = 'none' } = useAdaptivity(); - if (process.env.NODE_ENVIRONMENT === 'development') { + if (process.env.NODE_ENV === 'development') { if (!safeAreaInsets) { // TODO [>=6]: удалить warn warn("[@vkontakte/vk-bridge] Интеграция VKUI с @vkontakte/vk-bridge устарела и будет удалена в v6. Используйте хук `useInsets()` из @vkontakte/vk-bridge-react и результат передайте в параметр `safeAreaInsets` (см. https://github.com/VKCOM/VKUI/issues/5049)"); // prettier-ignore diff --git a/packages/vkui/src/components/ConfigProvider/ConfigProvider.tsx b/packages/vkui/src/components/ConfigProvider/ConfigProvider.tsx index 198f68a773..bc96a6d6a9 100644 --- a/packages/vkui/src/components/ConfigProvider/ConfigProvider.tsx +++ b/packages/vkui/src/components/ConfigProvider/ConfigProvider.tsx @@ -57,7 +57,7 @@ export const ConfigProvider = (props: ConfigProviderProps) => { ? props.webviewType === WebviewType.VKAPPS : hasCustomPanelHeaderAfterMerged; - if (process.env.NODE_ENVIRONMENT === 'development') { + if (process.env.NODE_ENV === 'development') { // TODO [>=6]: удалить warn let webviewTypeRule = ''; if (props.webviewType) { diff --git a/packages/vkui/types/env.d.ts b/packages/vkui/types/env.d.ts index 528116ee7a..db9de90a51 100644 --- a/packages/vkui/types/env.d.ts +++ b/packages/vkui/types/env.d.ts @@ -5,3 +5,16 @@ declare module '*.module.css' { } declare module '*.svg'; + +// Фиксируем process.env, так как vite передает только NODE_ENV +declare module 'process' { + declare global { + namespace NodeJS { + interface Process { + env: { + NODE_ENV: 'development' | 'production' | 'test'; + }; + } + } + } +}