Skip to content

Commit c8d44e2

Browse files
committed
fix scope when falling back to original load function
1 parent 57379e0 commit c8d44e2

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/vs/workbench/api/common/extHostRequireInterceptor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { platform } from 'vs/base/common/process';
2121

2222

2323
interface LoadFunction {
24-
(request: string, parent: { filename: string; }, isMain: any): any;
24+
(request: string): any;
2525
}
2626

2727
interface INodeModuleFactory {
2828
readonly nodeModuleName: string | string[];
29-
load(request: string, parent: URI, isMain: any, original: LoadFunction): any;
29+
load(request: string, parent: URI, original: LoadFunction): any;
3030
alternativeModuleName?(name: string): string | undefined;
3131
}
3232

@@ -245,15 +245,15 @@ class OpenNodeModuleFactory implements INodeModuleFactory {
245245
};
246246
}
247247

248-
public load(request: string, parent: URI, isMain: any, original: LoadFunction): any {
248+
public load(request: string, parent: URI, original: LoadFunction): any {
249249
// get extension id from filename and api for extension
250250
const extension = this._extensionPaths.findSubstr(parent.fsPath);
251251
if (extension) {
252252
this._extensionId = extension.identifier.value;
253253
this.sendShimmingTelemetry();
254254
}
255255

256-
this._original = original(request, { filename: parent.fsPath }, isMain);
256+
this._original = original(request);
257257
return this._impl;
258258
}
259259

src/vs/workbench/api/node/extHostExtensionService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ class NodeModuleRequireInterceptor extends RequireInterceptor {
3131
if (!that._factories.has(request)) {
3232
return original.apply(this, arguments);
3333
}
34-
return that._factories.get(request)!.load(request, URI.file(parent.filename), isMain, original);
34+
return that._factories.get(request)!.load(
35+
request,
36+
URI.file(parent.filename),
37+
request => original.apply(this, [request, parent, isMain])
38+
);
3539
};
3640
}
3741
}

src/vs/workbench/api/worker/extHostExtensionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class WorkerRequireInterceptor extends RequireInterceptor {
8989
}
9090

9191
if (this._factories.has(request)) {
92-
return this._factories.get(request)!.load(request, parent, false, () => { throw new Error(); });
92+
return this._factories.get(request)!.load(request, parent, () => { throw new Error('CANNOT LOAD MODULE from here.'); });
9393
}
9494
return undefined;
9595
}

0 commit comments

Comments
 (0)