diff --git a/package.json b/package.json index 2e7f84c..79388d8 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,20 @@ { "name": "kysely-d1", "description": "Kysely dialect for Cloudflare D1", - "main": "./dist/index.js", + "main": "./dist/index.cjs", + "module": "./dist/index.js", "version": "0.3.0", "types": "./dist/index.d.ts", "repository": "git@github.com:aidenwallis/kysely-d1.git", "author": "Aiden ", "license": "MIT", + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs" + } + }, "files": [ "dist" ], @@ -18,7 +26,7 @@ "serverless" ], "scripts": { - "build": "tsc", + "build": "tsc && tsc -p tsconfig.cjs.json && mv dist/cjs/index.js dist/index.cjs && rmdir dist/cjs", "check": "prettier --check src/ example/", "format": "prettier --write src/ example/" }, diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..6314c46 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist/cjs", + "declaration": false + } +} diff --git a/tsconfig.json b/tsconfig.json index 663768e..7dec5aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "extends": "@tsconfig/node14/tsconfig.json", "compilerOptions": { "rootDir": "src", + "module": "ESNext", "outDir": "dist", "alwaysStrict": true, "skipLibCheck": true,