Skip to content

Commit

Permalink
fix(nodejs): fix problems with window object in node
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholuj committed Mar 25, 2020
1 parent 6b0537a commit 9ac935e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,8 +32,7 @@ const initializeGlobalNamespace = () => {
modules: {},
};

// @ts-ignore
window.filestackInternals = namespace;
holder.filestackInternals = namespace;
}

if (!namespace.modules) {
Expand Down Expand Up @@ -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'));
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
},
"./lib/index.ts": {
"version": "6f148b056e32cf4454bfe5693f8e2e4215505267c74dd370487eca1358189696",
"version": "9530d95f85e67a1685ace4f60c1225229212a820e1b05928e701dfb0fa160947",
"signature": "1224cc0a40563110dbb362a71077cd2ce99a33195fc6b9fdb4d999cc6cad8ee6"
},
"./node_modules/@types/color-name/index.d.ts": {
Expand Down

0 comments on commit 9ac935e

Please sign in to comment.