[Backport 8.x] Fix ECMAScript import (#2476)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
This commit is contained in:
committed by
GitHub
parent
14cdd64f7d
commit
b3b9d40293
10
.github/workflows/nodejs.yml
vendored
10
.github/workflows/nodejs.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [18.x, 20.x, 22.x]
|
node-version: [18.x, 20.x, 22.x, 23.x]
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -57,6 +57,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npm run test:unit
|
npm run test:unit
|
||||||
|
|
||||||
|
- name: ECMAScript module test
|
||||||
|
run: |
|
||||||
|
npm run test:esm
|
||||||
|
|
||||||
license:
|
license:
|
||||||
name: License check
|
name: License check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -110,3 +114,7 @@ jobs:
|
|||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
bun run test:unit-bun
|
bun run test:unit-bun
|
||||||
|
|
||||||
|
- name: ECMAScript module test
|
||||||
|
run: |
|
||||||
|
bun run test:esm
|
||||||
|
|||||||
@ -6,12 +6,15 @@
|
|||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"require": "./index.js"
|
"require": "./index.js",
|
||||||
|
"import": "./index.js",
|
||||||
|
"types": "./index.d.ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build && npm run lint && tap",
|
"test": "npm run build && npm run lint && tap",
|
||||||
"test:unit": "npm run build && tap",
|
"test:unit": "npm run build && tap",
|
||||||
"test:unit-bun": "bun run build && bunx tap",
|
"test:unit-bun": "bun run build && bunx tap",
|
||||||
|
"test:esm": "npm run build && cd test/esm/ && npm install && node test-import.mjs",
|
||||||
"test:coverage-100": "npm run build && tap --coverage --100",
|
"test:coverage-100": "npm run build && tap --coverage --100",
|
||||||
"test:coverage-report": "npm run build && tap --coverage && nyc report --reporter=text-lcov > coverage.lcov",
|
"test:coverage-report": "npm run build && tap --coverage && nyc report --reporter=text-lcov > coverage.lcov",
|
||||||
"test:coverage-ui": "npm run build && tap --coverage --coverage-report=html",
|
"test:coverage-ui": "npm run build && tap --coverage --coverage-report=html",
|
||||||
|
|||||||
7
test/esm/package.json
Normal file
7
test/esm/package.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "esm",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@elastic/elasticsearch": "file:../.."
|
||||||
|
}
|
||||||
|
}
|
||||||
28
test/esm/test-import.mjs
Normal file
28
test/esm/test-import.mjs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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 { Client } from '@elastic/elasticsearch'
|
||||||
|
|
||||||
|
new Client({
|
||||||
|
node: 'http://localhost:9200',
|
||||||
|
auth: {
|
||||||
|
username: 'elastic',
|
||||||
|
password: 'changeme',
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user