From 9ac935ecf1093c559497ef5d449bf6e28ab6ed51 Mon Sep 17 00:00:00 2001 From: pcholuj Date: Wed, 25 Mar 2020 11:49:08 +0100 Subject: [PATCH] fix(nodejs): fix problems with window object in node --- lib/index.ts | 9 ++++----- tsconfig.tsbuildinfo | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 5d7ee5c..4299c7d 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -18,7 +18,7 @@ const initializeGlobalNamespace = () => { let holder:any; // if there is no window obj use nodejs global lib variable - if (window && typeof window !== 'object') { + if (typeof window === 'undefined') { holder = globalHolder; } else { holder = window @@ -32,8 +32,7 @@ const initializeGlobalNamespace = () => { modules: {}, }; - // @ts-ignore - window.filestackInternals = namespace; + holder.filestackInternals = namespace; } if (!namespace.modules) { @@ -84,7 +83,7 @@ export const loadModules = (modulesList) => Promise.all(modulesList.map(({ id, u * @param {*} url */ export const loadModule = (id: string, url: string) => { - if (window && typeof window !== 'object') { + if (typeof window === 'undefined') { return Promise.reject(new Error('Load module is working only on browser env')); } @@ -154,7 +153,7 @@ export const loadModule = (id: string, url: string) => { */ export const registerModule = (id: string, instance: any, metadata?: any) => { // loader not working on nodejs envs - if (window && typeof window !== 'object') { + if (typeof window === 'undefined') { return; } diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo index 13a8b2d..482ea15 100644 --- a/tsconfig.tsbuildinfo +++ b/tsconfig.tsbuildinfo @@ -50,7 +50,7 @@ "signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303" }, "./lib/index.ts": { - "version": "6f148b056e32cf4454bfe5693f8e2e4215505267c74dd370487eca1358189696", + "version": "9530d95f85e67a1685ace4f60c1225229212a820e1b05928e701dfb0fa160947", "signature": "1224cc0a40563110dbb362a71077cd2ce99a33195fc6b9fdb4d999cc6cad8ee6" }, "./node_modules/@types/color-name/index.d.ts": {