Skip to content

Commit 7cbcafc

Browse files
authored
esm - remove loader.js dependency fully (microsoft#226414)
* esm - remove `loader.js` dependency fully * .
1 parent a002d15 commit 7cbcafc

File tree

10 files changed

+8
-15
lines changed

10 files changed

+8
-15
lines changed

src/vs/base/common/performance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
} else if (typeof process === 'object') {
8383
// node.js: use the normal polyfill but add the timeOrigin
8484
// from the node perf_hooks API as very first mark
85-
const timeOrigin = performance?.timeOrigin ?? Math.round((require.__$__nodeRequire ?? require /* TODO@esm drop the first */)('perf_hooks').performance.timeOrigin);
85+
const timeOrigin = performance?.timeOrigin;// ?? Math.round((require.__$__nodeRequire ?? require /* TODO@esm this is fishy */)('perf_hooks').performance.timeOrigin);
8686
return _definePolyfillMarks(timeOrigin);
8787

8888
} else {

src/vs/base/node/unc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
/// <reference path="../../../typings/require.d.ts" />
7-
86
//@ts-check
97
'use strict';
108

src/vs/code/electron-sandbox/processExplorer/processExplorer-dev.esm.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
</body>
3838

3939
<!-- Startup (do not modify order of script tags!) -->
40-
<script src="../../../../vs/loader.js"></script>
4140
<script src="../../../../bootstrap-window.js"></script>
4241
<script src="./processExplorer.js"></script>
4342
</html>

src/vs/code/electron-sandbox/processExplorer/processExplorer-dev.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
</body>
3636

3737
<!-- Startup (do not modify order of script tags!) -->
38-
<script src="../../../../vs/loader.js"></script>
3938
<script src="../../../../bootstrap-window.js"></script>
4039
<script src="./processExplorer.js"></script>
4140
</html>

src/vs/code/electron-sandbox/workbench/workbench-dev.esm.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
</body>
7171

7272
<!-- Startup (do not modify order of script tags!) -->
73-
<script src="../../../../vs/loader.js"></script>
7473
<script src="../../../../bootstrap-window.js"></script>
7574
<script src="./workbench.js"></script>
7675
</html>

src/vs/code/electron-sandbox/workbench/workbench.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
/// <reference path="../../../../typings/require.d.ts" />
7-
86
//@ts-check
97
'use strict';
108

src/vs/workbench/contrib/issue/electron-sandbox/issueReporter-dev.esm.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
</body>
4242

4343
<!-- Startup (do not modify order of script tags!) -->
44-
<script src="../../../../../vs/loader.js"></script>
4544
<script src="../../../../../bootstrap-window.js"></script>
4645
<script src="./issueReporter.js"></script>
4746
</html>

src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
569569
}
570570

571571
return [
572-
dirname(FileAccess.asFileUri('vs/loader.js')),
572+
dirname(FileAccess.asFileUri('vs/loader.js')), // TODO@esm this file will not exist in the future
573573
];
574574
}
575575

src/vs/workbench/contrib/performance/browser/perfviewEditor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ class PerfModelContentProvider implements ITextModelContentProvider {
200200
const table: Array<Array<string | number | undefined>> = [];
201201
table.push(['start => app.isReady', metrics.timers.ellapsedAppReady, '[main]', `initial startup: ${metrics.initialStartup}`]);
202202
table.push(['nls:start => nls:end', metrics.timers.ellapsedNlsGeneration, '[main]', `initial startup: ${metrics.initialStartup}`]);
203-
table.push(['require(main.bundle.js)', metrics.timers.ellapsedLoadMainBundle, '[main]', `initial startup: ${metrics.initialStartup}`]);
203+
table.push(['import(main.bundle.js)', metrics.timers.ellapsedLoadMainBundle, '[main]', `initial startup: ${metrics.initialStartup}`]);
204204
table.push(['start crash reporter', metrics.timers.ellapsedCrashReporter, '[main]', `initial startup: ${metrics.initialStartup}`]);
205205
table.push(['serve main IPC handle', metrics.timers.ellapsedMainServer, '[main]', `initial startup: ${metrics.initialStartup}`]);
206206
table.push(['create window', metrics.timers.ellapsedWindowCreate, '[main]', `initial startup: ${metrics.initialStartup}, ${metrics.initialStartup ? `state: ${metrics.timers.ellapsedWindowRestoreState}ms, widget: ${metrics.timers.ellapsedBrowserWindowCreate}ms, show: ${metrics.timers.ellapsedWindowMaximize}ms` : ''}`]);
207207
table.push(['app.isReady => window.loadUrl()', metrics.timers.ellapsedWindowLoad, '[main]', `initial startup: ${metrics.initialStartup}`]);
208-
table.push(['window.loadUrl() => begin to require(workbench.desktop.main.js)', metrics.timers.ellapsedWindowLoadToRequire, '[main->renderer]', StartupKindToString(metrics.windowKind)]);
209-
table.push(['require(workbench.desktop.main.js)', metrics.timers.ellapsedRequire, '[renderer]', `cached data: ${(metrics.didUseCachedData ? 'YES' : 'NO')}${stats ? `, node_modules took ${stats.nodeRequireTotal}ms` : ''}`]);
208+
table.push(['window.loadUrl() => begin to import(workbench.desktop.main.js)', metrics.timers.ellapsedWindowLoadToRequire, '[main->renderer]', StartupKindToString(metrics.windowKind)]);
209+
table.push(['import(workbench.desktop.main.js)', metrics.timers.ellapsedRequire, '[renderer]', `cached data: ${(metrics.didUseCachedData ? 'YES' : 'NO')}${stats ? `, node_modules took ${stats.nodeRequireTotal}ms` : ''}`]);
210210
table.push(['wait for window config', metrics.timers.ellapsedWaitForWindowConfig, '[renderer]', undefined]);
211211
table.push(['init storage (global & workspace)', metrics.timers.ellapsedStorageInit, '[renderer]', undefined]);
212212
table.push(['init workspace service', metrics.timers.ellapsedWorkspaceServiceInit, '[renderer]', undefined]);
@@ -332,7 +332,7 @@ class PerfModelContentProvider implements ITextModelContentProvider {
332332
map.set(LoaderEventType.CachedDataFound, []);
333333
map.set(LoaderEventType.CachedDataMissed, []);
334334
map.set(LoaderEventType.CachedDataRejected, []);
335-
if (typeof require.getStats === 'function') {
335+
if (!isESM && typeof require.getStats === 'function') {
336336
for (const stat of require.getStats()) {
337337
if (map.has(stat.type)) {
338338
map.get(stat.type)!.push(stat.detail);

src/vs/workbench/electron-sandbox/window.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { ThemeIcon } from 'vs/base/common/themables';
8080
import { getWorkbenchContribution } from 'vs/workbench/common/contributions';
8181
import { DynamicWorkbenchSecurityConfiguration } from 'vs/workbench/common/configuration';
8282
import { nativeHoverDelegate } from 'vs/platform/hover/browser/hover';
83+
import { isESM } from 'vs/base/common/amd';
8384

8485
export class NativeWindow extends BaseWindow {
8586

@@ -708,7 +709,7 @@ export class NativeWindow extends BaseWindow {
708709
private async handleWarnings(): Promise<void> {
709710

710711
// Check for cyclic dependencies
711-
if (typeof require.hasDependencyCycle === 'function' && require.hasDependencyCycle()) {
712+
if (!isESM && typeof require.hasDependencyCycle === 'function' && require.hasDependencyCycle()) {
712713
if (isCI) {
713714
this.logService.error('Error: There is a dependency cycle in the AMD modules that needs to be resolved!');
714715
this.nativeHostService.exit(37); // running on a build machine, just exit without showing a dialog

0 commit comments

Comments
 (0)