Skip to content

Commit 8d9a09e

Browse files
authored
Hardcode grpc-js version (#5771)
1 parent a777385 commit 8d9a09e

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

packages/firestore/rollup.config.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@
1515
* limitations under the License.
1616
*/
1717

18-
import tmp from 'tmp';
19-
import json from '@rollup/plugin-json';
18+
import { version as grpcVersion } from '@grpc/grpc-js/package.json';
2019
import alias from '@rollup/plugin-alias';
21-
import typescriptPlugin from 'rollup-plugin-typescript2';
22-
import typescript from 'typescript';
23-
import replace from 'rollup-plugin-replace';
20+
import json from '@rollup/plugin-json';
2421
import copy from 'rollup-plugin-copy';
22+
import replace from 'rollup-plugin-replace';
2523
import { terser } from 'rollup-plugin-terser';
24+
import typescriptPlugin from 'rollup-plugin-typescript2';
25+
import tmp from 'tmp';
26+
import typescript from 'typescript';
2627

27-
import pkg from './package.json';
2828
import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target';
2929

30+
import pkg from './package.json';
31+
3032
const util = require('./rollup.shared');
3133

3234
// Customize how import.meta.url is polyfilled in cjs nodejs build. We use it to be able to use require() in esm.
@@ -69,7 +71,8 @@ const nodePlugins = function () {
6971
]
7072
}),
7173
replace({
72-
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
74+
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos'),
75+
'__GRPC_VERSION__': grpcVersion
7376
})
7477
];
7578
};

packages/firestore/src/platform/node/grpc_connection.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
// This is a hack fix for Node ES modules to use `require`.
19-
// @ts-ignore To avoid using `allowSyntheticDefaultImports` flag.
20-
import module from 'module';
21-
2218
import {
2319
Metadata,
2420
GrpcObject,
@@ -38,11 +34,9 @@ import { logError, logDebug, logWarn } from '../../util/log';
3834
import { NodeCallback, nodePromise } from '../../util/node_api';
3935
import { Deferred } from '../../util/promise';
4036

41-
// This is a hack fix for Node ES modules to use `require`.
42-
// @ts-ignore To avoid using `--module es2020` flag.
43-
const requireInESM = module.createRequire(import.meta.url);
44-
// eslint-disable-next-line @typescript-eslint/no-require-imports
45-
const { version: grpcVersion } = requireInESM('@grpc/grpc-js/package.json');
37+
// TODO: Fetch runtime version from grpc-js/package.json instead
38+
// when there's a cleaner way to dynamic require JSON in both Node ESM and CJS
39+
const grpcVersion = '__GRPC_VERSION__';
4640

4741
const LOG_TAG = 'Connection';
4842
const X_GOOG_API_CLIENT_VALUE = `gl-node/${process.versions.node} fire/${SDK_VERSION} grpc/${grpcVersion}`;

0 commit comments

Comments
 (0)