Skip to content

Commit f6bfbf0

Browse files
committed
esm - convert bootstrap files to TS (part 3)
1 parent 0496e9c commit f6bfbf0

8 files changed

+97
-155
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@
11331133
"restrictions": []
11341134
},
11351135
{
1136-
"target": "src/{bootstrap-cli.ts,bootstrap-esm.ts,bootstrap-fork.ts,bootstrap-node.ts,bootstrap-import.ts,bootstrap-meta.ts,bootstrap-window.js,cli.js,main.js,server-cli.js,server-main.js,bootstrap-cli.js,bootstrap-server.js}",
1136+
"target": "src/{bootstrap-cli.ts,bootstrap-esm.ts,bootstrap-fork.ts,bootstrap-node.ts,bootstrap-import.ts,bootstrap-meta.ts,bootstrap-window.js,cli.ts,main.js,server-cli.ts,server-main.ts,bootstrap-server.ts}",
11371137
"restrictions": []
11381138
}
11391139
]

src/bootstrap-fork.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
/* eslint-disable local/code-import-patterns */
77

88
import * as performance from './vs/base/common/performance.js';
9-
import * as bootstrapNode from './bootstrap-node.js';
10-
import * as bootstrapESM from './bootstrap-esm.js';
9+
import { removeGlobalNodeJsModuleLookupPaths, devInjectNodeModuleLookupPath } from './bootstrap-node.js';
10+
import { load } from './bootstrap-esm.js';
1111

1212
performance.mark('code/fork/start');
1313

1414
// Crash reporter
1515
configureCrashReporter();
1616

1717
// Remove global paths from the node module lookup (node.js only)
18-
bootstrapNode.removeGlobalNodeJsModuleLookupPaths();
18+
removeGlobalNodeJsModuleLookupPaths();
1919

2020
if (process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']) {
21-
bootstrapNode.devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
21+
devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
2222
}
2323

2424
// Configure: pipe logging to parent process
@@ -37,7 +37,7 @@ if (process.env['VSCODE_PARENT_PID']) {
3737
}
3838

3939
// Load ESM entry point
40-
bootstrapESM.load(process.env['VSCODE_ESM_ENTRYPOINT']);
40+
load(process.env['VSCODE_ESM_ENTRYPOINT']);
4141

4242

4343
//#region Helpers

src/bootstrap-server.js renamed to src/bootstrap-server.ts

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
//@ts-check
7-
'use strict';
8-
96
// Keep bootstrap-esm.js from redefining 'fs'.
107
delete process.env['ELECTRON_RUN_AS_NODE'];

src/cli.js renamed to src/cli.ts

+12-19
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,27 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
//@ts-check
7-
'use strict';
6+
/* eslint-disable local/code-import-patterns */
87

98
import './bootstrap-cli.js'; // this MUST come before other imports as it changes global state
109
import * as path from 'path';
1110
import { fileURLToPath } from 'url';
12-
import * as bootstrapNode from './bootstrap-node.js';
13-
import * as bootstrapESM from './bootstrap-esm.js';
11+
import { configurePortable } from './bootstrap-node.js';
12+
import { load } from './bootstrap-esm.js';
1413
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
1514
import { product } from './bootstrap-meta.js';
1615

1716
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1817

19-
async function start() {
18+
// NLS
19+
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
20+
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages
2021

21-
// NLS
22-
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
23-
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages
22+
// Enable portable support
23+
configurePortable(product);
2424

25-
// Enable portable support
26-
// @ts-ignore
27-
bootstrapNode.configurePortable(product);
25+
// Signal processes that we got launched as CLI
26+
process.env['VSCODE_CLI'] = '1';
2827

29-
// Signal processes that we got launched as CLI
30-
process.env['VSCODE_CLI'] = '1';
31-
32-
// Load CLI
33-
bootstrapESM.load('vs/code/node/cli');
34-
}
35-
36-
start();
28+
// Load CLI
29+
load('vs/code/node/cli');

src/server-cli.js

-38
This file was deleted.

src/server-cli.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* eslint-disable local/code-import-patterns */
7+
8+
import './bootstrap-server.js'; // this MUST come before other imports as it changes global state
9+
import * as path from 'path';
10+
import { fileURLToPath } from 'url';
11+
import { devInjectNodeModuleLookupPath } from './bootstrap-node.js';
12+
import { load } from './bootstrap-esm.js';
13+
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
14+
import { product } from './bootstrap-meta.js';
15+
16+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
17+
18+
// NLS
19+
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
20+
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages
21+
22+
if (process.env['VSCODE_DEV']) {
23+
// When running out of sources, we need to load node modules from remote/node_modules,
24+
// which are compiled against nodejs, not electron
25+
process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
26+
devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
27+
} else {
28+
delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'];
29+
}
30+
31+
// Load Server CLI
32+
load('vs/server/node/server.cli');

0 commit comments

Comments
 (0)