Skip to content

Commit 12b552c

Browse files
committed
ready to publish
1 parent c9164da commit 12b552c

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

__tests__/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config } from '../src';
1+
import Config from '../src';
22

33
export function getDBConfig() {
44
return new Config('root', 'admin123456123456', '127.0.0.1', 2003);

examples/test.ts renamed to examples/simple.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import type { Row } from '../src';
2-
import { Config } from '../src';
1+
import Config, { type Row } from '../src';
32

4-
async function test() {
3+
async function main() {
54
const config = new Config('root', 'admin123456123456', '127.0.0.1', 2003);
6-
const spaceName = `testTable${Date.now()}Space`;
7-
const tableName = `${spaceName}.testTable`;
5+
const spaceName = `testSpace`;
6+
const tableName = `${spaceName}.users`;
87
const db = await config.connect();
98

109
try {
11-
await db.query('create space ' + spaceName);
12-
await db.query('use ' + spaceName);
10+
await db.query(`create space IF NOT EXISTS ${spaceName}`);
11+
await db.query(`use ${spaceName}`);
1312
await db.query(
1413
`CREATE MODEL ${tableName}(username: string, password: string, null email_id: string)`,
1514
);
@@ -27,9 +26,11 @@ async function test() {
2726
console.assert(username === 'test');
2827
console.assert(password === 'password');
2928
console.assert(email_id == null);
29+
} catch (e) {
30+
console.error(e);
3031
} finally {
3132
config.disconnect();
3233
}
3334
}
3435

35-
test();
36+
main();

package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "skytable",
33
"version": "1.0.0",
4-
"main": "dist/index.js",
4+
"main": "dist/cjs/index.js",
5+
"types": "dist/cjs/index.d.ts",
6+
"module": "dist/esm/index.mjs",
57
"description": "Offical NodeJS client driver for Skytable",
68
"author": "Sayan Nandan <nandansayan@outlook.com>",
79
"license": "Apache-2.0",
@@ -12,16 +14,24 @@
1214
"url": "https://github.com/skytable/client-nodejs/issues"
1315
},
1416
"scripts": {
15-
"build": "tsc",
16-
"debugger": "npx tsx examples/test.ts",
17+
"build": "yarn build:cjs && yarn build:esm",
18+
"build:cjs": "tsc",
19+
"build:esm": "tsc --project tsconfig-esm.json",
1720
"test": "jest",
1821
"formatting": "prettier src examples __tests__ --check",
1922
"prettier:fix": "prettier src examples __tests__ --write"
2023
},
21-
"dependencies": {
22-
"@types/node": "^20.10.4"
24+
"exports": {
25+
"./package.json": "./package.json",
26+
".": {
27+
"types": "./dist/cjs/index.d.ts",
28+
"module": "./dist/esm/index.mjs",
29+
"import": "./dist/esm/index.mjs",
30+
"require": "./dist/cjs/index.js"
31+
}
2332
},
2433
"devDependencies": {
34+
"@types/node": "^20.10.4",
2535
"@types/jest": "^29.5.11",
2636
"jest": "^29.7.0",
2737
"nodemon": "^3.0.2",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Config } from './config';
1+
export { Config as default } from './config';
22

33
export * from './skytable';
44

tsconfig-esm.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "ES6",
5+
"rootDir": "./src",
6+
"outDir": "./dist/esm",
7+
},
8+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"skipLibCheck": true,
113113
/* Skip type checking all .d.ts files. */
114114
"declaration": true,
115-
"outDir": "./dist",
115+
"outDir": "./dist/cjs",
116116
"rootDir": "./src",
117117
"baseUrl": ".",
118118
"paths": {

0 commit comments

Comments
 (0)