fix(core): update
This commit is contained in:
		@@ -30,13 +30,17 @@ export class Smartenv {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async getSafeNodeModule<T = any>(moduleNameArg: string): Promise<T> {
 | 
			
		||||
  public async getSafeNodeModule<T = any>(moduleNameArg: string, runAfterFunc: (moduleArg: T) => Promise<any>): Promise<T> {
 | 
			
		||||
    if (!this.isNode) {
 | 
			
		||||
      console.error(`You tried to load a node module in a wrong context: ${moduleNameArg}`);
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    // tslint:disable-next-line: function-constructor
 | 
			
		||||
    return new Function(`return import('${moduleNameArg}')`)() as Promise<T>;
 | 
			
		||||
    const returnValue: T = await (new Function(`return import('${moduleNameArg}')`)() as Promise<T>);
 | 
			
		||||
    if (runAfterFunc) {
 | 
			
		||||
      await runAfterFunc(returnValue);
 | 
			
		||||
    }
 | 
			
		||||
    return returnValue;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public loadedScripts: string[] = [];
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user