Skip to content

Commit

Permalink
Move to latest compiler, NodeJS 20.9.0, es2022 and exports statements. (
Browse files Browse the repository at this point in the history
#1502)

* WIP

* More version updates

* More code cleanup

* Convert client to export property

* Fix imports

* Get test oto work again

* Update Readme.md

* Revert timeout
  • Loading branch information
dbaeumer committed Jul 2, 2024
1 parent 6d2a392 commit 5393301
Show file tree
Hide file tree
Showing 109 changed files with 461 additions and 519 deletions.
18 changes: 10 additions & 8 deletions .tsconfigrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const general = {
* rely on webpack to package everything correctly.
*/
compilerOptions: {
module: 'commonjs',
moduleResolution: 'node'
module: 'node16',
moduleResolution: 'node16'
}
};

Expand Down Expand Up @@ -367,8 +367,8 @@ const compileCompilerOptions = CompilerOptions.assign(defaultCompilerOptions, {
declarationMap: true,
noUnusedLocals: true,
noUnusedParameters: true,
target: 'es2020',
lib: [ 'es2020' ],
target: 'es2022',
lib: [ 'es2022' ],
});

/** @type ProjectOptions */
Expand All @@ -386,8 +386,8 @@ const watchCompilerOptions = CompilerOptions.assign(defaultCompilerOptions, {
noUnusedLocals: false,
noUnusedParameters: false,
assumeChangesOnlyAffectDirectDependencies: true,
target: 'es2020',
lib: [ 'es2020' ],
target: 'es2022',
lib: [ 'es2022' ],
});

/** @type ProjectOptions */
Expand All @@ -404,8 +404,8 @@ const publishCompilerOptions = CompilerOptions.assign(defaultCompilerOptions, {
declarationMap: false,
noUnusedLocals: true,
noUnusedParameters: true,
target: 'es2020',
lib: [ 'es2020' ]
target: 'es2022',
lib: [ 'es2022' ]

});

Expand All @@ -425,6 +425,7 @@ const umdCompilerOptions = CompilerOptions.assign(defaultCompilerOptions, {
noUnusedParameters: true,
target: 'es5',
module: 'umd',
moduleResolution: 'node',
lib: [ 'es2015' ],
});

Expand Down Expand Up @@ -471,6 +472,7 @@ const esmPublishCompilerOptions = CompilerOptions.assign(defaultCompilerOptions,
sourceMap: false,
target: 'es6',
module: 'es6',
moduleResolution: 'node',
lib: [ 'es2015' ]
});

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ After cloning the repository, run `npm install` to install dependencies and `npm

## Next (10.0.0-next.* Client and 10.0.0-next.* Server)

- Upgraded to newer libraries, compilers and package.json exports rules:
- Compiler upgraded to `5.5.x`.
- Libs now depend on NodeJS `20.9.0` and `es2022`.
- `vscode-jsonrpc`, `vscode-languageserver-protocol`, `vscode-languageclient` and `vscode-languageserver` now use the `exports` property instead of having a `main` and `typings` property. This might need adoption in tsconfig.json files around the `module` and `moduleResolution`. The LSP libraries currently use `node16` for both values.
- added proposed CodeActionKind.RefactorMove
- snippet support in Workspace edits
- support to control the parallelism of the dispatch requests and notification. This is a breaking change since it allows notification handlers to return a promise to control this.
Expand Down
63 changes: 34 additions & 29 deletions build/bin/runBrowserTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,42 @@ async function runTests(location) {
}
});
server.listen(8080, '127.0.0.1', async () => {
let failCount = 0;
const browser = await playwright['chromium'].launch({ headless: true, devtools: false });
const context = await browser.newContext();
const page = await context.newPage();
const emitter = new events.EventEmitter();
emitter.on('fail', () => {
failCount++;
});
emitter.on('end', async () => {
process.exitCode = failCount === 0 ? 0 : 1;
await browser.close();
server.close((err) => {
if (err) {
reject(err);
} else {
resolve();
}
try {
let failCount = 0;
const browser = await playwright['chromium'].launch({ headless: true, devtools: false });
const context = await browser.newContext();
const page = await context.newPage();
// page.setDefaultTimeout(1000000);
const emitter = new events.EventEmitter();
emitter.on('fail', () => {
failCount++;
});
emitter.on('end', async () => {
process.exitCode = failCount === 0 ? 0 : 1;
await browser.close();
server.close((err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
const echoRunner = new EchoRunner(emitter, 'Chromium');
if (process.platform === 'win32') {
new mocha.reporters.List(echoRunner);
} else {
new mocha.reporters.Spec(echoRunner);
}
await page.exposeFunction('mocha_report', (type, data1, data2) => {
emitter.emit(type, data1, data2);
});
});
const echoRunner = new EchoRunner(emitter, 'Chromium');
if (process.platform === 'win32') {
new mocha.reporters.List(echoRunner);
} else {
new mocha.reporters.Spec(echoRunner);
}
await page.exposeFunction('mocha_report', (type, data1, data2) => {
emitter.emit(type, data1, data2);
});

const target = new url.URL(location);
page.goto(target.href);
const target = new url.URL(location);
page.goto(target.href);
} catch (error) {
console.error(error);
}
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion build/bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
require('../../node_modules/webpack/bin/webpack.js')
require('../../node_modules/webpack/bin/webpack.js');
10 changes: 5 additions & 5 deletions client-node-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"main": "./extension.js",
"contributes": {},
"scripts": {
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"clean": "rimraf lib",
"compile": "tsc -b ./tsconfig.json",
"watch": "tsc -b ./tsconfig.watch.json -w",
"lint": "eslint --ext ts src",
"test": "node ../build/bin/symlink-tests.js && node lib/runTests.js",
"all": "npm run clean && npm run compile && npm run lint && npm run test",
"symlink:publish": "node ../build/bin/symlink-client-tests-publish.js",
"compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json",
"compile:publish": "tsc -b ./tsconfig.publish.json",
"test:publish": "node lib/runTests.js",
"all:publish": "git clean -xfd . && npm install && npm run symlink:publish && npm run compile:publish && npm run test:publish"
},
Expand Down
14 changes: 7 additions & 7 deletions client-node-tests/src/converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import { strictEqual, deepEqual, ok } from 'assert';

import * as proto from 'vscode-languageclient';
import * as codeConverter from 'vscode-languageclient/lib/common/codeConverter';
import * as protocolConverter from 'vscode-languageclient/lib/common/protocolConverter';
import ProtocolCompletionItem from 'vscode-languageclient/lib/common/protocolCompletionItem';
import ProtocolInlayHint from 'vscode-languageclient/lib/common/protocolInlayHint';
import { DiagnosticCode, ProtocolDiagnostic } from 'vscode-languageclient/lib/common/protocolDiagnostic';
import * as Is from 'vscode-languageclient/lib/common/utils/is';
import * as async from 'vscode-languageclient/lib/common/utils/async';
import * as codeConverter from 'vscode-languageclient/$test/common/codeConverter';
import * as protocolConverter from 'vscode-languageclient/$test/common/protocolConverter';
import ProtocolCompletionItem from 'vscode-languageclient/$test/common/protocolCompletionItem';
import ProtocolInlayHint from 'vscode-languageclient/$test/common/protocolInlayHint';
import { DiagnosticCode, ProtocolDiagnostic } from 'vscode-languageclient/$test/common/protocolDiagnostic';
import * as Is from 'vscode-languageclient/$test/common/utils/is';
import * as async from 'vscode-languageclient/$test/common/utils/async';

import * as vscode from 'vscode';

Expand Down
2 changes: 1 addition & 1 deletion client-node-tests/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import Mocha from 'mocha';
import { glob } from 'glob';

export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
Expand Down
2 changes: 1 addition & 1 deletion client-node-tests/src/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as vscode from 'vscode';
import * as lsclient from 'vscode-languageclient/node';
import * as proto from 'vscode-languageserver-protocol';
import { MemoryFileSystemProvider } from './memoryFileSystemProvider';
import { vsdiag, DiagnosticProviderMiddleware } from 'vscode-languageclient/lib/common/diagnostic';
import { vsdiag, DiagnosticProviderMiddleware } from 'vscode-languageclient';

namespace GotNotifiedRequest {
export const method: 'testing/gotNotified' = 'testing/gotNotified';
Expand Down
8 changes: 4 additions & 4 deletions client-node-tests/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"module": "node16",
"moduleResolution": "node16",
"rootDir": ".",
"types": [
"node",
"vscode",
"mocha"
],
"lib": [
"es2020",
"es2022",
"webworker"
],
"strict": true,
Expand All @@ -22,7 +22,7 @@
"declarationMap": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"target": "es2020",
"target": "es2022",
"outDir": "../lib",
"tsBuildInfoFile": "../lib/compile.tsbuildInfo",
"incremental": true
Expand Down
8 changes: 4 additions & 4 deletions client-node-tests/src/tsconfig.publish.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"module": "node16",
"moduleResolution": "node16",
"rootDir": ".",
"types": [
"node",
"vscode",
"mocha"
],
"lib": [
"es2020",
"es2022",
"webworker"
],
"strict": true,
Expand All @@ -22,7 +22,7 @@
"declarationMap": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"target": "es2020",
"target": "es2022",
"outDir": "../lib",
"tsBuildInfoFile": "../lib/publish.tsbuildInfo",
"incremental": true
Expand Down
8 changes: 4 additions & 4 deletions client-node-tests/src/tsconfig.watch.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"module": "node16",
"moduleResolution": "node16",
"rootDir": ".",
"types": [
"node",
"vscode",
"mocha"
],
"lib": [
"es2020",
"es2022",
"webworker"
],
"strict": true,
Expand All @@ -23,7 +23,7 @@
"noUnusedLocals": false,
"noUnusedParameters": false,
"assumeChangesOnlyAffectDirectDependencies": true,
"target": "es2020",
"target": "es2022",
"outDir": "../lib",
"tsBuildInfoFile": "../lib/watch.tsbuildInfo",
"incremental": true
Expand Down
6 changes: 5 additions & 1 deletion client-node-tests/src/workspaceFolder.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import * as assert from 'assert';
import * as vscode from 'vscode';
import * as sinon from 'sinon';

import { WorkspaceFoldersFeature } from 'vscode-languageclient/lib/common/workspaceFolder';
import { WorkspaceFoldersFeature } from 'vscode-languageclient/$test/common/workspaceFolder';
import { BaseLanguageClient, MessageTransports, DidChangeWorkspaceFoldersParams, Disposable } from 'vscode-languageclient';
import * as proto from 'vscode-languageclient';

Expand Down
6 changes: 0 additions & 6 deletions client/browser.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions client/browser.js

This file was deleted.

5 changes: 0 additions & 5 deletions client/node.cmd

This file was deleted.

6 changes: 0 additions & 6 deletions client/node.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions client/node.js

This file was deleted.

31 changes: 22 additions & 9 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"enabledApiProposals": [],
"main": "./lib/node/main.js",
"browser": {
"./lib/node/main.js": "./lib/browser/main.js"
"exports": {
".": {
"types": "./lib/common/api.d.ts",
"default": "./lib/common/api.js"
},
"./node": {
"types": "./lib/node/main.d.ts",
"node": "./lib/node/main.js"
},
"./browser": {
"types": "./lib/browser/main.d.ts",
"browser": "./lib/browser/main.js"
},
"./$test/common/*": {
"types": "./lib/common/*.d.ts",
"node": "./lib/common/*.js"
}
},
"typings": "./lib/common/api.d.ts",
"devDependencies": {
"@types/minimatch": "^5.1.2",
"@types/semver": "^7.5.8",
Expand All @@ -35,14 +48,14 @@
"scripts": {
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",
"prepack": "npm run all:publish",
"compile": "node ../build/bin/tsc -b ./tsconfig.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh",
"compile": "tsc -b ./tsconfig.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh",
"compile:clean": "git clean -xfd . && npm install && npm run clean && npm run compile",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"watch": "tsc -b ./tsconfig.watch.json -w",
"lint": "eslint --ext ts src",
"test": "cd ../client-node-tests && npm test && cd ../client",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"clean": "rimraf lib",
"all": "npm run clean && npm run compile && npm run lint && npm test",
"compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh",
"compile:publish": "tsc -b ./tsconfig.publish.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh",
"all:publish": "git clean -xfd . && npm install && npm run updateVSCodeVersion && npm run compile:publish && npm run lint && cd ../client-node-tests && npm run all:publish && cd ..",
"preversion": "npm test",
"updateVSCodeVersion": "node ./bin/updateVSCode.js"
Expand Down
Loading

0 comments on commit 5393301

Please sign in to comment.