WIP: multi-build support for both commonjs and ESM
This commit is contained in:
@ -6,3 +6,4 @@ elasticsearch
|
||||
lib
|
||||
junit-output
|
||||
.tap
|
||||
esm
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -68,3 +68,4 @@ bun.lockb
|
||||
test-results
|
||||
processinfo
|
||||
.tap
|
||||
esm
|
||||
|
||||
53
index.mjs
Normal file
53
index.mjs
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
Diagnostic,
|
||||
Transport,
|
||||
WeightedConnectionPool,
|
||||
ClusterConnectionPool,
|
||||
BaseConnectionPool,
|
||||
CloudConnectionPool,
|
||||
BaseConnection,
|
||||
HttpConnection,
|
||||
UndiciConnection,
|
||||
Serializer,
|
||||
errors,
|
||||
events
|
||||
} from '@elastic/transport'
|
||||
|
||||
import * as Client from './esm/client'
|
||||
import * as SniffingTransport from './esm/sniffingTransport'
|
||||
|
||||
export {
|
||||
Client,
|
||||
SniffingTransport,
|
||||
Diagnostic,
|
||||
Transport,
|
||||
WeightedConnectionPool,
|
||||
ClusterConnectionPool,
|
||||
BaseConnectionPool,
|
||||
CloudConnectionPool,
|
||||
BaseConnection,
|
||||
HttpConnection,
|
||||
UndiciConnection,
|
||||
Serializer,
|
||||
errors,
|
||||
events
|
||||
}
|
||||
19
package.json
19
package.json
@ -3,13 +3,18 @@
|
||||
"version": "9.0.0-alpha.4",
|
||||
"versionCanary": "9.0.0-canary.0",
|
||||
"description": "The official Elasticsearch client for Node.js",
|
||||
"type": "module",
|
||||
"main": "./index.js",
|
||||
"types": "index.d.ts",
|
||||
"module": "./index.mjs",
|
||||
"exports": {
|
||||
"require": "./index.js",
|
||||
"import": "./index.js",
|
||||
"types": "./index.d.ts"
|
||||
".": {
|
||||
"require": "./index.js",
|
||||
"import": "./index.mjs"
|
||||
},
|
||||
"./lib/*": "./lib/*.js",
|
||||
"./esm/*": "./esm/*.js"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "npm run build && npm run lint && tap",
|
||||
"test:unit": "npm run build && tap",
|
||||
@ -23,8 +28,10 @@
|
||||
"lint:fix": "ts-standard --fix src",
|
||||
"license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause;0BSD'",
|
||||
"prebuild": "npm run clean-build && npm run lint",
|
||||
"build": "tsc && rm lib/package.json && mv lib/src/* lib/ && rm -rf lib/src",
|
||||
"clean-build": "rimraf ./lib && mkdir lib",
|
||||
"build": "npm run build:cjs && npm run build:esm",
|
||||
"build:cjs": "tsc --project ./tsconfig.cjs.json && rm lib/package.json && mv lib/src/* lib/ && rm -rf lib/src",
|
||||
"build:esm": "tsc --project ./tsconfig.esm.json && rm esm/package.json && mv esm/src/* esm/ && rm -rf esm/src",
|
||||
"clean-build": "rimraf ./lib && mkdir lib; rimraf ./esm && mkdir esm",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
9
tsconfig.cjs.json
Normal file
9
tsconfig.cjs.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node16",
|
||||
"outDir": "lib"
|
||||
}
|
||||
}
|
||||
9
tsconfig.esm.json
Normal file
9
tsconfig.esm.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "esm"
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"target": "es2022",
|
||||
"declaration": true,
|
||||
"pretty": true,
|
||||
"noEmitOnError": true,
|
||||
@ -15,13 +14,12 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"useDefineForClassFields": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"importHelpers": true,
|
||||
"outDir": "lib",
|
||||
"lib": [
|
||||
"ES2019",
|
||||
"es2023",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user