diff --git a/.eslintrc.json b/.eslintrc.json index e9ddc4689a5..65e29fc3f85 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -681,9 +681,7 @@ // - browser // - electron-sandbox "when": "hasBrowser", - "allow": [ - "vs/css!./**/*" - ] + "allow": [] }, { // imports that are allowed in all files of layers: diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index a62213deb78..f922cb4aa6b 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -26,7 +26,7 @@ Error.stackTraceLimit = 100; /** - * @param {string[]} modulePaths + * @param {string} esModule * @param {(result: unknown, configuration: ISandboxConfiguration) => Promise | undefined} resultCallback * @param {{ * configureDeveloperSettings?: (config: ISandboxConfiguration) => { @@ -39,7 +39,7 @@ * beforeImport?: (config: ISandboxConfiguration) => void * }} [options] */ - async function load(modulePaths, resultCallback, options) { + async function load(esModule, resultCallback, options) { // Await window configuration from preload const timeout = setTimeout(() => { console.error(`[resolve window config] Could not resolve window configuration within 10 seconds, but will continue to wait...`); }, 10000); @@ -66,10 +66,7 @@ }; const isDev = !!safeProcess.env['VSCODE_DEV']; const enableDeveloperKeybindings = isDev || forceEnableDeveloperKeybindings; - /** - * @type {() => void | undefined} - */ - let developerDeveloperKeybindingsDisposable; + let developerDeveloperKeybindingsDisposable = undefined; if (enableDeveloperKeybindings) { developerDeveloperKeybindingsDisposable = registerDeveloperKeybindings(disallowReloadKeybinding); } @@ -136,42 +133,20 @@ performance.mark('code/didAddCssLoader'); } - const result = Promise.all(modulePaths.map(modulePath => { - if (modulePath.includes('vs/css!')) { - // ESM/CSS when seeing the old `vs/css!` prefix we use that as a signal to - // load CSS via a tag - const cssModule = modulePath.replace('vs/css!', ''); - const link = document.createElement('link'); - link.rel = 'stylesheet'; - link.href = new URL(`${cssModule}.css`, baseUrl).href; - document.head.appendChild(link); - return Promise.resolve(); - } else { - // ESM/JS module loading - return import(new URL(`${modulePath}.js`, baseUrl).href); - } - })); + // ESM Import + try { + const result = await import(new URL(`${esModule}.js`, baseUrl).href); - result.then(res => invokeResult(res[0]), onUnexpectedError); + const callbackResult = resultCallback(result, configuration); + if (callbackResult instanceof Promise) { + await callbackResult; - /** - * @param {any} firstModule - */ - async function invokeResult(firstModule) { - try { - - // Callback only after process environment is resolved - const callbackResult = resultCallback(firstModule, configuration); - if (callbackResult instanceof Promise) { - await callbackResult; - - if (developerDeveloperKeybindingsDisposable && removeDeveloperKeybindingsAfterLoad) { - developerDeveloperKeybindingsDisposable(); - } + if (developerDeveloperKeybindingsDisposable && removeDeveloperKeybindingsAfterLoad) { + developerDeveloperKeybindingsDisposable(); } - } catch (error) { - onUnexpectedError(error, enableDeveloperKeybindings); } + } catch (error) { + onUnexpectedError(error, enableDeveloperKeybindings); } } diff --git a/src/vs/code/electron-sandbox/processExplorer/processExplorer.js b/src/vs/code/electron-sandbox/processExplorer/processExplorer.js index 98e67e7c25c..a13045464b6 100644 --- a/src/vs/code/electron-sandbox/processExplorer/processExplorer.js +++ b/src/vs/code/electron-sandbox/processExplorer/processExplorer.js @@ -15,7 +15,7 @@ const bootstrapWindow = bootstrapWindowLib(); // Load process explorer into window - bootstrapWindow.load(['vs/code/electron-sandbox/processExplorer/processExplorerMain'], function (processExplorer, configuration) { + bootstrapWindow.load('vs/code/electron-sandbox/processExplorer/processExplorerMain', function (processExplorer, configuration) { return processExplorer.startup(configuration); }, { configureDeveloperSettings: function () { @@ -28,7 +28,7 @@ /** * @returns {{ * load: ( - * modules: string[], + * esModule: string, * resultCallback: (result: any, configuration: ISandboxConfiguration) => unknown, * options?: { * configureDeveloperSettings?: (config: ISandboxConfiguration) => { diff --git a/src/vs/code/electron-sandbox/workbench/workbench.js b/src/vs/code/electron-sandbox/workbench/workbench.js index 80b74b70b37..e8bb6c4ba4b 100644 --- a/src/vs/code/electron-sandbox/workbench/workbench.js +++ b/src/vs/code/electron-sandbox/workbench/workbench.js @@ -23,10 +23,7 @@ // optimization to prevent a waterfall of loading to happen, because // we know for a fact that workbench.desktop.main will depend on // the related CSS counterpart. - bootstrapWindow.load([ - 'vs/workbench/workbench.desktop.main', - 'vs/css!vs/workbench/workbench.desktop.main' - ], + bootstrapWindow.load('vs/workbench/workbench.desktop.main', function (desktopMain, configuration) { // Mark start of workbench @@ -77,7 +74,7 @@ /** * @returns {{ * load: ( - * modules: string[], + * esModule: string, * resultCallback: (result: any, configuration: INativeWindowConfiguration & NativeParsedArgs) => unknown, * options?: { * configureDeveloperSettings?: (config: INativeWindowConfiguration & NativeParsedArgs) => { diff --git a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.js b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.js index 15a7f2a211d..7a1164c6fb2 100644 --- a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.js +++ b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.js @@ -15,7 +15,7 @@ const bootstrapWindow = bootstrapWindowLib(); // Load issue reporter into window - bootstrapWindow.load(['vs/workbench/contrib/issue/electron-sandbox/issueReporterMain'], function (issueReporter, configuration) { + bootstrapWindow.load('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain', function (issueReporter, configuration) { return issueReporter.startup(configuration); }, { @@ -31,7 +31,7 @@ /** * @returns {{ * load: ( - * modules: string[], + * esModule: string, * resultCallback: (result: any, configuration: ISandboxConfiguration) => unknown, * options?: { * configureDeveloperSettings?: (config: ISandboxConfiguration) => {