diff --git a/.gitignore b/.gitignore index 8365f4d..7235b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore +# Build artifacts +dist/ + # Logs logs diff --git a/README.md b/README.md index 021b4a4..80f71c8 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ # qdl.js + +**Test** + +Run tests in watch mode + +```sh +bun test --watch +``` + +**Build** + +Bundles JS and generates type declarations + +```sh +bun run build +``` diff --git a/bun.lockb b/bun.lockb index b5bb979..33798ef 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index dac0929..b9068ee 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,30 @@ "version": "0.1.0", "license": "MIT", "type": "module", + "main": "dist/qdl.js", + "types": "dist/qdl.d.ts", "exports": { - ".": "./src/qdl.js", - "./utils": "./src/utils.js" + ".": { + "types": "./dist/qdl.d.ts", + "import": "./dist/qdl.js" + }, + "./utils": { + "types": "./dist/utils.d.ts", + "import": "./dist/utils.js" + } + }, + "scripts": { + "build": "rm -rf dist && tsc", + "postinstall": "bun run build" }, "devDependencies": { + "@types/bun": "latest", "@types/w3c-web-usb": "^1.0.10" }, "dependencies": { "crc-32": "^1.2.2" + }, + "peerDependencies": { + "typescript": "^5.0.0" } } diff --git a/jsconfig.json b/tsconfig.json similarity index 60% rename from jsconfig.json rename to tsconfig.json index 9fb19ec..df24228 100644 --- a/jsconfig.json +++ b/tsconfig.json @@ -10,9 +10,16 @@ // Bundler mode "moduleResolution": "bundler", - "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, - "noEmit": true, + + // Compilation + "outDir": "dist", + "declaration": true, + "sourceMap": true, + "incremental": true, + "tsBuildInfoFile": "node_modules/.tsbuildinfo", + // TODO: enable after disabling allowJs + // "isolatedDeclarations": true, // Best practices "strict": true, @@ -21,5 +28,7 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noPropertyAccessFromIndexSignature": true - } + }, + "include": ["src/*.js"], + "exclude": ["src/*.spec.js", "dist", "node_modules"], }