Skip to content

Commit

Permalink
Merge 303c512 into a777385
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Dec 8, 2021
2 parents a777385 + 303c512 commit ba63caf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
17 changes: 10 additions & 7 deletions packages/firestore/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
* limitations under the License.
*/

import tmp from 'tmp';
import json from '@rollup/plugin-json';
import { version as grpcVersion } from '@grpc/grpc-js/package.json';
import alias from '@rollup/plugin-alias';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import replace from 'rollup-plugin-replace';
import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
import typescriptPlugin from 'rollup-plugin-typescript2';
import tmp from 'tmp';
import typescript from 'typescript';

import pkg from './package.json';
import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target';

import pkg from './package.json';

const util = require('./rollup.shared');

// Customize how import.meta.url is polyfilled in cjs nodejs build. We use it to be able to use require() in esm.
Expand Down Expand Up @@ -69,7 +71,8 @@ const nodePlugins = function () {
]
}),
replace({
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos'),
'__GRPC_VERSION__': grpcVersion
})
];
};
Expand Down
12 changes: 3 additions & 9 deletions packages/firestore/src/platform/node/grpc_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
* limitations under the License.
*/

// This is a hack fix for Node ES modules to use `require`.
// @ts-ignore To avoid using `allowSyntheticDefaultImports` flag.
import module from 'module';

import {
Metadata,
GrpcObject,
Expand All @@ -38,11 +34,9 @@ import { logError, logDebug, logWarn } from '../../util/log';
import { NodeCallback, nodePromise } from '../../util/node_api';
import { Deferred } from '../../util/promise';

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

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

0 comments on commit ba63caf

Please sign in to comment.