MCPcopy
hub / github.com/microsoft/vscode / _nodeJSLoadScript

Method _nodeJSLoadScript

src/vs/amdX.ts:178–194  ·  view source on GitHub ↗
(scriptSrc: string)

Source from the content-addressed store, hash-verified

176 }
177
178 private async _nodeJSLoadScript(scriptSrc: string): Promise<DefineCall | undefined> {
179 try {
180 const fs = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'fs'}`)).default;
181 const vm = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'vm'}`)).default;
182 const module = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'module'}`)).default;
183
184 const filePath = URI.parse(scriptSrc).fsPath;
185 const content = fs.readFileSync(filePath).toString();
186 const scriptSource = module.wrap(content.replace(/^#!.*/, ''));
187 const script = new vm.Script(scriptSource);
188 const compileWrapper = script.runInThisContext();
189 compileWrapper.apply();
190 return this._defineCalls.pop();
191 } catch (error) {
192 throw error;
193 }
194 }
195}
196
197const cache = new Map<string, Promise<any>>();

Callers 1

loadMethod · 0.95

Calls 6

parseMethod · 0.65
toStringMethod · 0.65
wrapMethod · 0.65
replaceMethod · 0.65
applyMethod · 0.65
popMethod · 0.45

Tested by

no test coverage detected