Skip to content

Commit 13f57f5

Browse files
committed
fix(node): disable register module method when window is missing
1 parent 97c9972 commit 13f57f5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export const loadModules = (modulesList) => Promise.all(modulesList.map(({ id, u
8282
* @param {*} url
8383
*/
8484
export const loadModule = (id: string, url: string) => {
85+
if (typeof window !== 'object') {
86+
return Promise.reject(new Error('Load module is working only on browser env'));
87+
}
88+
8589
if (!id) {
8690
throw new Error('Module id is required')
8791
}
@@ -147,6 +151,11 @@ export const loadModule = (id: string, url: string) => {
147151
* @param {any} metadata - additional module metadata like version
148152
*/
149153
export const registerModule = (id: string, instance: any, metadata?: any) => {
154+
// loader not working on nodejs envs
155+
if (typeof window !== 'object') {
156+
return;
157+
}
158+
150159
if (!id) {
151160
throw new Error('Module id is required')
152161
}

0 commit comments

Comments
 (0)