From 2a118293268227c942d6f6995c10b8909cdf0c17 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Mon, 12 Nov 2018 11:03:19 +0900 Subject: [PATCH] give canUseDOM with a possibility to be a constant https://webpack.js.org/plugins/define-plugin/ Webpack's DefinePlugin has the ability to replace `typeof expr` to a constant in compile-time, which should lead to better dead-code-elimination. --- packages/shared/ExecutionEnvironment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared/ExecutionEnvironment.js b/packages/shared/ExecutionEnvironment.js index 9554c8d6464cf..2e7af6edd2d6c 100644 --- a/packages/shared/ExecutionEnvironment.js +++ b/packages/shared/ExecutionEnvironment.js @@ -9,6 +9,6 @@ export const canUseDOM: boolean = !!( typeof window !== 'undefined' && - window.document && - window.document.createElement + typeof window.document !== 'undefined' && + typeof window.document.createElement !== 'undefined' );