From 70a92d2fc3cff9715399d00158f047588ab78218 Mon Sep 17 00:00:00 2001 From: Patrick Remy Date: Sun, 12 Apr 2020 17:20:28 +0200 Subject: [PATCH] grpc-js: resolve node/no-unpublished-require --- packages/grpc-js/src/index.ts | 3 ++- packages/grpc-js/src/subchannel.ts | 2 +- packages/grpc-js/tsconfig.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/grpc-js/src/index.ts b/packages/grpc-js/src/index.ts index 661e0efd..e4bb3658 100644 --- a/packages/grpc-js/src/index.ts +++ b/packages/grpc-js/src/index.ts @@ -62,7 +62,8 @@ import { ServerDuplexStream, } from './server-call'; -const supportedNodeVersions = require('../../package.json').engines.node; +import { engines as supportedEngines } from '../package.json'; +const supportedNodeVersions = supportedEngines.node; if (!semver.satisfies(process.version, supportedNodeVersions)) { throw new Error(`@grpc/grpc-js only works on Node ${supportedNodeVersions}`); } diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index 3f6cfd52..3f71720e 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -29,7 +29,7 @@ import { LogVerbosity } from './constants'; import { shouldUseProxy, getProxiedConnection } from './http_proxy'; import * as net from 'net'; -const { version: clientVersion } = require('../../package.json'); +import { version as clientVersion } from '../package.json'; const TRACER_NAME = 'subchannel'; diff --git a/packages/grpc-js/tsconfig.json b/packages/grpc-js/tsconfig.json index f60cbdc0..ba675db7 100644 --- a/packages/grpc-js/tsconfig.json +++ b/packages/grpc-js/tsconfig.json @@ -5,6 +5,7 @@ "outDir": "build", "target": "es2017", "module": "commonjs", + "resolveJsonModule": true, "incremental": true }, "include": [