(core) Speed up and upgrade build.

Summary:
- Upgrades to build-related packages:
  - Upgrade typescript, related libraries and typings.
  - Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.

- Build organization changes:
  - Build webpack from original typescript, transpiling only; with errors still
    reported by a background tsc watching process.

- Typescript-related changes:
  - Reduce imports of AWS dependencies (very noticeable speedup)
  - Avoid auto-loading global @types
  - Client code is now built with isolatedModules flag (for safe transpilation)
  - Use allowJs to avoid copying JS files manually.

- Linting changes
  - Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
  - Update eslint config, and include .eslintignore to avoid linting generated files.
  - Include a bunch of eslint-prompted and eslint-generated fixes
  - Add no-unused-expression rule to eslint, and fix a few warnings about it

- Other items:
  - Refactor cssInput to avoid circular dependency
  - Remove a bit of unused code, libraries, dependencies

Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3498
This commit is contained in:
Dmitry S
2022-06-27 16:09:41 -04:00
parent 64ff9ccd0a
commit dd2eadc86e
45 changed files with 948 additions and 2442 deletions

View File

@@ -16,7 +16,7 @@ import {Client, ClientMethod} from 'app/server/lib/Client';
import {CommClientConnect} from 'app/common/CommTypes';
import {delay} from 'app/common/delay';
import {isLongerThan} from 'app/common/gutil';
import {fromCallback, getAvailablePort} from 'app/server/lib/serverUtils';
import {connect as connectSock, fromCallback, getAvailablePort, listenPromise} from 'app/server/lib/serverUtils';
import {Sessions} from 'app/server/lib/Sessions';
import * as testUtils from 'test/server/testUtils';
import * as session from '@gristlabs/express-session';
@@ -52,7 +52,7 @@ describe('Comm', function() {
server = http.createServer();
comm = new Comm(server, {sessions});
comm.registerMethods(methods);
return fromCallback(cb => server.listen(0, 'localhost', cb));
return listenPromise(server.listen(0, 'localhost'));
}
async function stopComm() {
@@ -500,8 +500,7 @@ export class TcpForwarder {
public async connect() {
await this.disconnect();
this._server = new Server((sock) => this._onConnect(sock));
await new Promise((resolve, reject) =>
this._server!.on('error', reject).listen(this.port, resolve));
await listenPromise(this._server.listen(this.port));
}
public async disconnectClientSide() {
await Promise.all(Array.from(this._connections.keys(), destroySock));
@@ -528,9 +527,7 @@ export class TcpForwarder {
}
}
private async _onConnect(clientSock: Socket) {
const serverSock = new Socket();
await new Promise((resolve, reject) =>
serverSock.on('error', reject).connect(this._serverPort, resolve));
const serverSock = await connectSock(this._serverPort);
clientSock.pipe(serverSock);
serverSock.pipe(clientSock);
clientSock.on('error', (err) => serverSock.destroy(err));

View File

@@ -1,5 +1,5 @@
import {getAppRoot} from 'app/server/lib/places';
import {fromCallback} from 'app/server/lib/serverUtils';
import {fromCallback, listenPromise} from 'app/server/lib/serverUtils';
import * as express from 'express';
import * as http from 'http';
import {AddressInfo, Socket} from 'net';
@@ -45,7 +45,7 @@ export function serveCustomViews(): Promise<Serving> {
export async function serveSomething(setup: (app: express.Express) => void, port= 0): Promise<Serving> {
const app = express();
const server = http.createServer(app);
await fromCallback(cb => server.listen(port, cb));
await listenPromise(server.listen(port));
const connections = new Set<Socket>();
server.on('connection', (conn) => {