Skip to content

Commit

Permalink
Added dynamic import support to enable the loading of esm dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
v4lentin1879 committed May 27, 2024
1 parent 634f761 commit e76a7cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/scriptLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ namespace AMDLoader {
interface INodeVMScriptOptions {
filename: string;
cachedData?: Buffer;
importModuleDynamically?: (specifier: string) => Promise<any>;
}

interface INodeVMScript {
Expand Down Expand Up @@ -452,7 +453,9 @@ namespace AMDLoader {
}

scriptSource = nodeInstrumenter(scriptSource, normalizedScriptSrc);
const scriptOpts: INodeVMScriptOptions = { filename: vmScriptPathOrUri, cachedData };
const scriptOpts: INodeVMScriptOptions = { filename: vmScriptPathOrUri, cachedData, importModuleDynamically: (specifier) => {
return import(specifier);
} };
const script = this._createAndEvalScript(moduleManager, scriptSource, scriptOpts, callback, errorback);

this._handleCachedData(script, scriptSource, cachedDataPath!, wantsCachedData && !cachedData, moduleManager);
Expand Down

0 comments on commit e76a7cb

Please sign in to comment.