From 13f57f5da2f12cad91e92e3375bd356262e667ff Mon Sep 17 00:00:00 2001 From: pcholuj Date: Wed, 25 Mar 2020 11:27:10 +0100 Subject: [PATCH] fix(node): disable register module method when window is missing --- lib/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/index.ts b/lib/index.ts index 8f88105..dcb73de 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -82,6 +82,10 @@ export const loadModules = (modulesList) => Promise.all(modulesList.map(({ id, u * @param {*} url */ export const loadModule = (id: string, url: string) => { + if (typeof window !== 'object') { + return Promise.reject(new Error('Load module is working only on browser env')); + } + if (!id) { throw new Error('Module id is required') } @@ -147,6 +151,11 @@ export const loadModule = (id: string, url: string) => { * @param {any} metadata - additional module metadata like version */ export const registerModule = (id: string, instance: any, metadata?: any) => { + // loader not working on nodejs envs + if (typeof window !== 'object') { + return; + } + if (!id) { throw new Error('Module id is required') }