mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
fix scope when falling back to original load function
This commit is contained in:
@@ -21,12 +21,12 @@ import { platform } from 'vs/base/common/process';
|
||||
|
||||
|
||||
interface LoadFunction {
|
||||
(request: string, parent: { filename: string; }, isMain: any): any;
|
||||
(request: string): any;
|
||||
}
|
||||
|
||||
interface INodeModuleFactory {
|
||||
readonly nodeModuleName: string | string[];
|
||||
load(request: string, parent: URI, isMain: any, original: LoadFunction): any;
|
||||
load(request: string, parent: URI, original: LoadFunction): any;
|
||||
alternativeModuleName?(name: string): string | undefined;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ class OpenNodeModuleFactory implements INodeModuleFactory {
|
||||
};
|
||||
}
|
||||
|
||||
public load(request: string, parent: URI, isMain: any, original: LoadFunction): any {
|
||||
public load(request: string, parent: URI, original: LoadFunction): any {
|
||||
// get extension id from filename and api for extension
|
||||
const extension = this._extensionPaths.findSubstr(parent.fsPath);
|
||||
if (extension) {
|
||||
@@ -253,7 +253,7 @@ class OpenNodeModuleFactory implements INodeModuleFactory {
|
||||
this.sendShimmingTelemetry();
|
||||
}
|
||||
|
||||
this._original = original(request, { filename: parent.fsPath }, isMain);
|
||||
this._original = original(request);
|
||||
return this._impl;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ class NodeModuleRequireInterceptor extends RequireInterceptor {
|
||||
if (!that._factories.has(request)) {
|
||||
return original.apply(this, arguments);
|
||||
}
|
||||
return that._factories.get(request)!.load(request, URI.file(parent.filename), isMain, original);
|
||||
return that._factories.get(request)!.load(
|
||||
request,
|
||||
URI.file(parent.filename),
|
||||
request => original.apply(this, [request, parent, isMain])
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class WorkerRequireInterceptor extends RequireInterceptor {
|
||||
}
|
||||
|
||||
if (this._factories.has(request)) {
|
||||
return this._factories.get(request)!.load(request, parent, false, () => { throw new Error(); });
|
||||
return this._factories.get(request)!.load(request, parent, () => { throw new Error('CANNOT LOAD MODULE from here.'); });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user