mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-21 02:14:18 +01:00
simplify setup by emiting index.js in ESM style from napi
This commit is contained in:
@@ -3,8 +3,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
/* auto-generated by NAPI-RS */
|
/* auto-generated by NAPI-RS */
|
||||||
|
|
||||||
const { createRequire } = require('node:module')
|
import { createRequire } from 'node:module'
|
||||||
require = createRequire(__filename)
|
const require = createRequire(import.meta.url)
|
||||||
|
const __dirname = new URL('.', import.meta.url).pathname
|
||||||
|
|
||||||
const { readFileSync } = require('node:fs')
|
const { readFileSync } = require('node:fs')
|
||||||
let nativeBinding = null
|
let nativeBinding = null
|
||||||
@@ -392,6 +393,6 @@ if (!nativeBinding) {
|
|||||||
throw new Error(`Failed to load native binding`)
|
throw new Error(`Failed to load native binding`)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nativeBinding
|
const { Database, Statement } = nativeBinding
|
||||||
module.exports.Database = nativeBinding.Database
|
export { Database }
|
||||||
module.exports.Statement = nativeBinding.Statement
|
export { Statement }
|
||||||
|
|||||||
@@ -6,17 +6,12 @@
|
|||||||
"url": "https://github.com/tursodatabase/turso"
|
"url": "https://github.com/tursodatabase/turso"
|
||||||
},
|
},
|
||||||
"description": "The Turso database library",
|
"description": "The Turso database library",
|
||||||
"module": "./promise.mjs",
|
"module": "./dist/promise.js",
|
||||||
"main": "./promise.cjs",
|
"main": "./dist/promise.js",
|
||||||
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": "./dist/promise.js",
|
||||||
"require": "./promise.cjs",
|
"./sync": "./dist/sync.js"
|
||||||
"import": "./promise.mjs"
|
|
||||||
},
|
|
||||||
"./sync": {
|
|
||||||
"require": "./sync.cjs",
|
|
||||||
"import": "./sync.mjs"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"browser.js",
|
"browser.js",
|
||||||
@@ -53,8 +48,8 @@
|
|||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"artifacts": "napi artifacts && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
|
"artifacts": "napi artifacts && tsc -p tsconfig.json",
|
||||||
"build": "napi build --platform --release",
|
"build": "napi build --platform --release --esm",
|
||||||
"build:debug": "napi build --platform",
|
"build:debug": "napi build --platform",
|
||||||
"prepublishOnly": "napi prepublish -t npm",
|
"prepublishOnly": "napi prepublish -t npm",
|
||||||
"test": "true",
|
"test": "true",
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
const { Database } = require('./dist/cjs/promise');
|
|
||||||
module.exports = Database;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { SqliteError } from "./dist/esm/sqlite-error.js"
|
|
||||||
import { Database } from "./dist/esm/promise.js"
|
|
||||||
|
|
||||||
export default Database;
|
|
||||||
export { SqliteError }
|
|
||||||
@@ -34,8 +34,7 @@ function createErrorByName(name, message) {
|
|||||||
/**
|
/**
|
||||||
* Database represents a connection that can prepare and execute SQL statements.
|
* Database represents a connection that can prepare and execute SQL statements.
|
||||||
*/
|
*/
|
||||||
export class Database {
|
class Database {
|
||||||
static SqliteError = SqliteError;
|
|
||||||
db: NativeDB;
|
db: NativeDB;
|
||||||
memory: boolean;
|
memory: boolean;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -399,3 +398,5 @@ class Statement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { Database, SqliteError }
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
const { Database } = require('./dist/cjs/sync');
|
|
||||||
module.exports = Database;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { SqliteError } from "./dist/esm/sqlite-error.js"
|
|
||||||
import { Database } from "./dist/esm/sync.js"
|
|
||||||
|
|
||||||
export default Database;
|
|
||||||
export { SqliteError }
|
|
||||||
@@ -34,8 +34,7 @@ function createErrorByName(name, message) {
|
|||||||
/**
|
/**
|
||||||
* Database represents a connection that can prepare and execute SQL statements.
|
* Database represents a connection that can prepare and execute SQL statements.
|
||||||
*/
|
*/
|
||||||
export class Database {
|
class Database {
|
||||||
static SqliteError = SqliteError;
|
|
||||||
db: NativeDB;
|
db: NativeDB;
|
||||||
memory: boolean;
|
memory: boolean;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -393,3 +392,5 @@ class Statement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { Database, SqliteError }
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es2015",
|
|
||||||
"outDir": "dist/cjs",
|
|
||||||
"lib": [
|
|
||||||
"es2020"
|
|
||||||
],
|
|
||||||
"paths": {
|
|
||||||
"#entry-point": [
|
|
||||||
"./index.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"outDir": "dist/esm",
|
"outDir": "dist/",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2020"
|
"es2020"
|
||||||
],
|
],
|
||||||
Reference in New Issue
Block a user