Fix spdlog and node-pty in binary
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
"express": "^4.16.4",
|
||||
"google-protobuf": "^3.6.1",
|
||||
"node-pty": "^0.8.1",
|
||||
"spdlog": "^0.7.2",
|
||||
"tslib": "^1.9.3",
|
||||
"ws": "^6.1.2"
|
||||
},
|
||||
|
@ -1,3 +1,4 @@
|
||||
/// <reference path="../../../../lib/vscode/src/typings/spdlog.d.ts" />
|
||||
import { ChildProcess, SpawnOptions, ForkOptions } from "child_process";
|
||||
import { EventEmitter } from "events";
|
||||
import { Socket } from "net";
|
||||
@ -7,9 +8,6 @@ import { logger } from "@coder/logger";
|
||||
|
||||
// tslint:disable no-any
|
||||
|
||||
declare var __non_webpack_require__: typeof require;
|
||||
declare var __webpack_require__: typeof require;
|
||||
|
||||
export type ForkProvider = (modulePath: string, args: string[], options: ForkOptions) => ChildProcess;
|
||||
|
||||
export interface Disposer extends IDisposable {
|
||||
@ -26,6 +24,19 @@ interface ActiveEvalEmitter {
|
||||
* Helper class for server-side evaluations.
|
||||
*/
|
||||
export class EvalHelper {
|
||||
// For any non-external modules that are not built in, we need to require and
|
||||
// access them here. A require on the client-side won't work since that code
|
||||
// won't exist on the server (and bloat the client with an unused import), and
|
||||
// we can't manually import on the server-side and then call
|
||||
// `__webpack_require__` on the client-side because Webpack stores modules by
|
||||
// their paths which would require us to hard-code the path. These aren't
|
||||
// required immediately so we have a chance to unpack the .node files and set
|
||||
// their locations.
|
||||
public modules = {
|
||||
spdlog: require("spdlog") as typeof import("spdlog"),
|
||||
pty: require("node-pty") as typeof import("node-pty"),
|
||||
};
|
||||
|
||||
/**
|
||||
* Some spawn code tries to preserve the env (the debug adapter for instance)
|
||||
* but the env is mostly blank (since we're in the browser), so we'll just
|
||||
@ -38,29 +49,6 @@ export class EvalHelper {
|
||||
options.env = { ...process.env, ...options.env };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try a non-webpack require, then a webpack require if that fails.
|
||||
*/
|
||||
public require(modulePath: string): any {
|
||||
logger.info(`Attempting to require ${modulePath}`);
|
||||
try {
|
||||
return __non_webpack_require__(modulePath);
|
||||
} catch (error) { /* Nothing. */ }
|
||||
|
||||
logger.warn(`Non-webpack require failed for ${modulePath}`);
|
||||
try {
|
||||
return __webpack_require__(modulePath);
|
||||
} catch (error) { /* Nothing. */ }
|
||||
|
||||
logger.warn(`Webpack require failed for ${modulePath}`);
|
||||
try {
|
||||
return require(modulePath);
|
||||
} catch (error) {
|
||||
logger.error(`Failed to require ${modulePath}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,20 +113,17 @@ export class ActiveEvalHelper implements ActiveEvalEmitter {
|
||||
* Helper class for server-side active evaluations.
|
||||
*/
|
||||
export class ServerActiveEvalHelper extends ActiveEvalHelper implements EvalHelper {
|
||||
private readonly evalHelper: EvalHelper;
|
||||
private readonly evalHelper = new EvalHelper();
|
||||
public modules = this.evalHelper.modules;
|
||||
|
||||
public constructor(emitter: ActiveEvalEmitter, public readonly fork: ForkProvider) {
|
||||
super(emitter);
|
||||
this.evalHelper = new EvalHelper();
|
||||
}
|
||||
|
||||
public preserveEnv(options: SpawnOptions | ForkOptions): void {
|
||||
this.evalHelper.preserveEnv(options);
|
||||
}
|
||||
|
||||
public require(modulePath: string): any {
|
||||
return this.evalHelper.require(modulePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is a callback ID, return a function that emits the callback event
|
||||
* on the active evaluation with that ID and all arguments passed to it.
|
||||
|
@ -30,6 +30,13 @@ async-limiter@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
|
||||
integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==
|
||||
|
||||
bindings@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.4.0.tgz#909efa49f2ebe07ecd3cb136778f665052040127"
|
||||
integrity sha512-7znEVX22Djn+nYjxCWKDne0RRloa9XfYa84yk3s+HkE3LpDYZmhArYr9O9huBoHY3/oXispx5LorIX7Sl2CgSQ==
|
||||
dependencies:
|
||||
file-uri-to-path "1.0.0"
|
||||
|
||||
body-parser@1.18.3:
|
||||
version "1.18.3"
|
||||
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4"
|
||||
@ -144,6 +151,11 @@ express@^4.16.4:
|
||||
utils-merge "1.0.1"
|
||||
vary "~1.1.2"
|
||||
|
||||
file-uri-to-path@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
||||
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
|
||||
|
||||
finalhandler@1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.1.tgz#eebf4ed840079c83f4249038c9d703008301b105"
|
||||
@ -231,12 +243,24 @@ mime@1.4.1:
|
||||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6"
|
||||
integrity sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==
|
||||
|
||||
minimist@0.0.8:
|
||||
version "0.0.8"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
|
||||
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
|
||||
|
||||
mkdirp@^0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
|
||||
dependencies:
|
||||
minimist "0.0.8"
|
||||
|
||||
ms@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
||||
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
|
||||
|
||||
nan@2.12.1:
|
||||
nan@2.12.1, nan@^2.8.0:
|
||||
version "2.12.1"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
|
||||
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
|
||||
@ -342,6 +366,15 @@ setprototypeof@1.1.0:
|
||||
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656"
|
||||
integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==
|
||||
|
||||
spdlog@^0.7.2:
|
||||
version "0.7.2"
|
||||
resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.7.2.tgz#9298753d7694b9ee9bbfd7e01ea1e4c6ace1e64d"
|
||||
integrity sha512-rHfWCaWMD4NindDnql6rc6kn7Bs8JR92jhiUpCl3D6v+jYcQ6GozMLig0RliOOR8st5mU+IHLZnr15fBys5x/Q==
|
||||
dependencies:
|
||||
bindings "^1.3.0"
|
||||
mkdirp "^0.5.1"
|
||||
nan "^2.8.0"
|
||||
|
||||
"statuses@>= 1.4.0 < 2":
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
|
||||
|
Reference in New Issue
Block a user