From f3393022032356ed48ef68f7031c3c7d41d4823d Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 30 Nov 2021 10:46:37 +0800 Subject: [PATCH] chore: fix type problem and add npm script for analysis --- shared/hooks/useWhyDidYouUpdate.ts | 3 ++- web/package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/hooks/useWhyDidYouUpdate.ts b/shared/hooks/useWhyDidYouUpdate.ts index de6db5c9..098adf9f 100644 --- a/shared/hooks/useWhyDidYouUpdate.ts +++ b/shared/hooks/useWhyDidYouUpdate.ts @@ -7,6 +7,7 @@ import { parse, stringify } from 'flatted'; import _get from 'lodash/get'; import _isEqual from 'lodash/isEqual'; import { useEffect, useRef } from 'react'; +import { isDevelopment } from '../utils/environment'; interface UseWhyDidYouUpdateCallback { onChangeFound?: (data: { @@ -49,7 +50,7 @@ export function useWhyDidYouUpdate( const latestProps = useRef(props); useEffect(() => { - if (!__DEV__) return; + if (!isDevelopment) return; const allKeys = Object.keys({ ...latestProps.current, ...props }); diff --git a/web/package.json b/web/package.json index 4233eb2b..55c2dfb5 100644 --- a/web/package.json +++ b/web/package.json @@ -10,6 +10,7 @@ "build": "yarn plugins:all && cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack --config ./build/webpack.config.ts", "dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve --config ./build/webpack.config.ts", "serve": "npx http-server ./dist", + "analysis": "cross-env ANALYSIS=true yarn build", "check:type": "tsc --noEmit --skipLibCheck", "postinstall": "yarn plugins:install", "plugins:new": "ministar createPlugin",