Make client more ESM-friendly (#2348)
* Use node: prefix for stdlib imports * Make code more ESM-friendly * Add missing mjs file * Drop mjs file from package.json
This commit is contained in:
@ -17,10 +17,11 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { ConnectionOptions as TlsConnectionOptions } from 'tls'
|
||||
import { URL } from 'url'
|
||||
import buffer from 'buffer'
|
||||
import os from 'os'
|
||||
import process from 'node:process'
|
||||
import { ConnectionOptions as TlsConnectionOptions } from 'node:tls'
|
||||
import { URL } from 'node:url'
|
||||
import buffer from 'node:buffer'
|
||||
import os from 'node:os'
|
||||
import {
|
||||
Transport,
|
||||
UndiciConnection,
|
||||
@ -48,16 +49,18 @@ import BaseConnection, { prepareHeaders, ConnectionOptions } from '@elastic/tran
|
||||
import SniffingTransport from './sniffingTransport'
|
||||
import Helpers from './helpers'
|
||||
import API from './api'
|
||||
import packageJson from '../package.json'
|
||||
import transportPackageJson from '@elastic/transport/package.json'
|
||||
|
||||
const kChild = Symbol('elasticsearchjs-child')
|
||||
const kInitialOptions = Symbol('elasticsearchjs-initial-options')
|
||||
let clientVersion: string = require('../package.json').version // eslint-disable-line
|
||||
let clientVersion: string = packageJson.version
|
||||
/* istanbul ignore next */
|
||||
if (clientVersion.includes('-')) {
|
||||
// clean prerelease
|
||||
clientVersion = clientVersion.slice(0, clientVersion.indexOf('-')) + 'p'
|
||||
}
|
||||
let transportVersion: string = require('@elastic/transport/package.json').version // eslint-disable-line
|
||||
let transportVersion: string = transportPackageJson.version // eslint-disable-line
|
||||
/* istanbul ignore next */
|
||||
if (transportVersion.includes('-')) {
|
||||
// clean prerelease
|
||||
|
||||
@ -21,9 +21,9 @@
|
||||
/* eslint-disable @typescript-eslint/promise-function-async */
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
||||
|
||||
import assert from 'assert'
|
||||
import { promisify } from 'util'
|
||||
import { Readable } from 'stream'
|
||||
import assert from 'node:assert'
|
||||
import * as timersPromises from 'node:timers/promises'
|
||||
import { Readable } from 'node:stream'
|
||||
import { errors, TransportResult, TransportRequestOptions, TransportRequestOptionsWithMeta } from '@elastic/transport'
|
||||
import Client from './client'
|
||||
import * as T from './api/types'
|
||||
@ -163,8 +163,8 @@ export interface EsqlToRecords<TDocument> {
|
||||
}
|
||||
|
||||
const { ResponseError, ConfigurationError } = errors
|
||||
const sleep = promisify(setTimeout)
|
||||
const pImmediate = promisify(setImmediate)
|
||||
const sleep = timersPromises.setTimeout
|
||||
const pImmediate = timersPromises.setImmediate
|
||||
/* istanbul ignore next */
|
||||
const noop = (): void => {}
|
||||
const kClient = Symbol('elasticsearch-client')
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import assert from 'assert'
|
||||
import assert from 'node:assert'
|
||||
import { Transport, SniffOptions } from '@elastic/transport'
|
||||
|
||||
export default class SniffingTransport extends Transport {
|
||||
|
||||
Reference in New Issue
Block a user