@@ -510,62 +510,27 @@ index 49a8e254fd..99d233aed5 100644
510
510
throw new Error(`Cannot load URI: '${module}', must be of file-scheme`);
511
511
}
512
512
diff --git a/src/vs/workbench/api/worker/extHostExtensionService.ts b/src/vs/workbench/api/worker/extHostExtensionService.ts
513
- index afd82468c0..67d938e9ab 100644
513
+ index afd82468c0..289145be54 100644
514
514
--- a/src/vs/workbench/api/worker/extHostExtensionService.ts
515
515
+++ b/src/vs/workbench/api/worker/extHostExtensionService.ts
516
- @@ -9,6 +9,10 @@ import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHost
516
+ @@ -9,6 +9,9 @@ import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHost
517
517
import { endsWith } from 'vs/base/common/strings';
518
518
import { URI } from 'vs/base/common/uri';
519
519
import { RequireInterceptor } from 'vs/workbench/api/common/extHostRequireInterceptor';
520
520
+ import { joinPath } from 'vs/base/common/resources';
521
521
+ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
522
- + import { fromTar } from 'vs/server/node_modules/@coder/requirefs/out/requirefs';
523
- + import { Client } from 'vs/server/node_modules/@coder/node-browser/out/client/client';
522
+ + import { loadCommonJSModule } from 'vs/server/src/browser/worker';
524
523
525
524
class WorkerRequireInterceptor extends RequireInterceptor {
526
525
527
- @@ -41,7 +45,48 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
526
+ @@ -41,7 +44,14 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
528
527
await this._fakeModules.install();
529
528
}
530
529
531
530
- protected async _loadCommonJSModule<T>(module: URI, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise<T> {
532
531
+ protected async _loadCommonJSModule<T>(module: URI | IExtensionDescription, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise<T> {
533
532
+ if (!URI.isUri(module) && module.extensionKind !== 'web') {
534
- + const fetchUri = URI.from({
535
- + scheme: self.location.protocol.replace(':', ''),
536
- + authority: self.location.host,
537
- + path: `${self.location.pathname.replace(/\/static.*\/out\/vs\/workbench\/services\/extensions\/worker\/extensionHostWorkerMain.js$/, '')}/tar`,
538
- + query: `path=${encodeURIComponent(module.extensionLocation.path)}`,
539
- + });
540
- + const response = await fetch(fetchUri.toString(true));
541
- + if (response.status !== 200) {
542
- + throw new Error(`Failed to download extension '${module.extensionLocation.path}'`);
543
- + }
544
- + const client = new Client(this._nodeProxy, { logger: this._logService });
545
- + const init = await client.handshake();
546
- + const buffer = new Uint8Array(await response.arrayBuffer());
547
- + const rfs = fromTar(buffer);
548
- + (<any>self).global = self;
549
- + rfs.provide('vscode', this._fakeModules.getModule('vscode', module.extensionLocation));
550
- + Object.keys(client.modules).forEach((key) => {
551
- + const mod = (client.modules as any)[key];
552
- + if (key === 'process') {
553
- + (<any>self).process = mod;
554
- + (<any>self).process.env = init.env;
555
- + return;
556
- + }
557
- +
558
- + rfs.provide(key, mod);
559
- + switch (key) {
560
- + case 'buffer':
561
- + (<any>self).Buffer = mod.Buffer;
562
- + break;
563
- + case 'timers':
564
- + (<any>self).setImmediate = mod.setImmediate;
565
- + break;
566
- + }
567
- + });
568
- + return rfs.require('.');
533
+ + return loadCommonJSModule(module, activationTimesBuilder, this._nodeProxy, this._logService, this._fakeModules.getModule('vscode', module.extensionLocation));
569
534
+ }
570
535
+
571
536
+ if (!URI.isUri(module)) {
@@ -574,7 +539,7 @@ index afd82468c0..67d938e9ab 100644
574
539
575
540
module = module.with({ path: ensureSuffix(module.path, '.js') });
576
541
const response = await fetch(module.toString(true));
577
- @@ -57,7 +102 ,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
542
+ @@ -57,7 +67 ,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
578
543
const _exports = {};
579
544
const _module = { exports: _exports };
580
545
const _require = (request: string) => {
0 commit comments