Skip to content

Commit

Permalink
fix(node): disable register module method when window is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholuj committed Mar 25, 2020
1 parent 97c9972 commit 13f57f5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -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')
}
Expand Down

0 comments on commit 13f57f5

Please sign in to comment.