Skip to content

Commit 9ac935e

Browse files
committed
fix(nodejs): fix problems with window object in node
1 parent 6b0537a commit 9ac935e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const initializeGlobalNamespace = () => {
1818
let holder:any;
1919

2020
// if there is no window obj use nodejs global lib variable
21-
if (window && typeof window !== 'object') {
21+
if (typeof window === 'undefined') {
2222
holder = globalHolder;
2323
} else {
2424
holder = window
@@ -32,8 +32,7 @@ const initializeGlobalNamespace = () => {
3232
modules: {},
3333
};
3434

35-
// @ts-ignore
36-
window.filestackInternals = namespace;
35+
holder.filestackInternals = namespace;
3736
}
3837

3938
if (!namespace.modules) {
@@ -84,7 +83,7 @@ export const loadModules = (modulesList) => Promise.all(modulesList.map(({ id, u
8483
* @param {*} url
8584
*/
8685
export const loadModule = (id: string, url: string) => {
87-
if (window && typeof window !== 'object') {
86+
if (typeof window === 'undefined') {
8887
return Promise.reject(new Error('Load module is working only on browser env'));
8988
}
9089

@@ -154,7 +153,7 @@ export const loadModule = (id: string, url: string) => {
154153
*/
155154
export const registerModule = (id: string, instance: any, metadata?: any) => {
156155
// loader not working on nodejs envs
157-
if (window && typeof window !== 'object') {
156+
if (typeof window === 'undefined') {
158157
return;
159158
}
160159

tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
5151
},
5252
"./lib/index.ts": {
53-
"version": "6f148b056e32cf4454bfe5693f8e2e4215505267c74dd370487eca1358189696",
53+
"version": "9530d95f85e67a1685ace4f60c1225229212a820e1b05928e701dfb0fa160947",
5454
"signature": "1224cc0a40563110dbb362a71077cd2ce99a33195fc6b9fdb4d999cc6cad8ee6"
5555
},
5656
"./node_modules/@types/color-name/index.d.ts": {

0 commit comments

Comments
 (0)