mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +00:00
feat(core): Lazy-load nodes and credentials to reduce baseline memory usage (#4577)
This commit is contained in:
committed by
GitHub
parent
f63cd3b89e
commit
b6c57e19fc
10
packages/core/src/ClassLoader.ts
Normal file
10
packages/core/src/ClassLoader.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createContext, Script } from 'vm';
|
||||
|
||||
const context = createContext({ require });
|
||||
export const loadClassInIsolation = <T>(filePath: string, className: string) => {
|
||||
if (process.platform === 'win32') {
|
||||
filePath = filePath.replace(/\\/g, '/');
|
||||
}
|
||||
const script = new Script(`new (require('${filePath}').${className})()`);
|
||||
return script.runInContext(context) as T;
|
||||
};
|
||||
Reference in New Issue
Block a user