mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-21 10:14:19 +01:00
simplify setup by emiting index.js in ESM style from napi
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
// @ts-nocheck
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { createRequire } = require('node:module')
|
||||
require = createRequire(__filename)
|
||||
import { createRequire } from 'node:module'
|
||||
const require = createRequire(import.meta.url)
|
||||
const __dirname = new URL('.', import.meta.url).pathname
|
||||
|
||||
const { readFileSync } = require('node:fs')
|
||||
let nativeBinding = null
|
||||
@@ -392,6 +393,6 @@ if (!nativeBinding) {
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
module.exports = nativeBinding
|
||||
module.exports.Database = nativeBinding.Database
|
||||
module.exports.Statement = nativeBinding.Statement
|
||||
const { Database, Statement } = nativeBinding
|
||||
export { Database }
|
||||
export { Statement }
|
||||
|
||||
@@ -6,17 +6,12 @@
|
||||
"url": "https://github.com/tursodatabase/turso"
|
||||
},
|
||||
"description": "The Turso database library",
|
||||
"module": "./promise.mjs",
|
||||
"main": "./promise.cjs",
|
||||
"module": "./dist/promise.js",
|
||||
"main": "./dist/promise.js",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./promise.cjs",
|
||||
"import": "./promise.mjs"
|
||||
},
|
||||
"./sync": {
|
||||
"require": "./sync.cjs",
|
||||
"import": "./sync.mjs"
|
||||
}
|
||||
".": "./dist/promise.js",
|
||||
"./sync": "./dist/sync.js"
|
||||
},
|
||||
"files": [
|
||||
"browser.js",
|
||||
@@ -53,8 +48,8 @@
|
||||
"node": ">= 10"
|
||||
},
|
||||
"scripts": {
|
||||
"artifacts": "napi artifacts && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
|
||||
"build": "napi build --platform --release",
|
||||
"artifacts": "napi artifacts && tsc -p tsconfig.json",
|
||||
"build": "napi build --platform --release --esm",
|
||||
"build:debug": "napi build --platform",
|
||||
"prepublishOnly": "napi prepublish -t npm",
|
||||
"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.
|
||||
*/
|
||||
export class Database {
|
||||
static SqliteError = SqliteError;
|
||||
class Database {
|
||||
db: NativeDB;
|
||||
memory: 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.
|
||||
*/
|
||||
export class Database {
|
||||
static SqliteError = SqliteError;
|
||||
class Database {
|
||||
db: NativeDB;
|
||||
memory: 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,
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"outDir": "dist/esm",
|
||||
"outDir": "dist/",
|
||||
"lib": [
|
||||
"es2020"
|
||||
],
|
||||
Reference in New Issue
Block a user