Skip to content

Commit

Permalink
feat: emit type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Dec 2, 2024
1 parent 68bef20 commit 47289fc
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 30 deletions.
8 changes: 5 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"check": "deno task patch && deno task format:fail && deno task lint:fail && deno task type && deno task test",
"patch": "deno run -A ./scripts/patch.ts",
"release": "deno run -A --reload https://raw.githubusercontent.com/globalbrain/hado/main/scripts/release.ts",
"update": "deno run -A --reload https://raw.githubusercontent.com/globalbrain/hado/main/scripts/update.ts"
"update": "deno run -A --reload https://raw.githubusercontent.com/globalbrain/hado/main/scripts/update.ts && deno install"
},
"fmt": {
"lineWidth": 100,
Expand All @@ -29,10 +29,12 @@
"singleQuote": true
},
"imports": {
"@ast-grep/napi": "npm:@ast-grep/napi@^0.30.1",
"@ast-grep/napi": "npm:@ast-grep/napi@^0.31.0",
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.11.0",
"@std/assert": "jsr:@std/assert@^1.0.8",
"esbuild": "npm:esbuild@^0.24.0",
"prettier": "npm:prettier@^3.4.1"
"prettier": "npm:prettier@^3.4.1",
"typescript": "npm:typescript@^5.7.2",
"unplugin-isolated-decl": "npm:unplugin-isolated-decl@^0.9.1"
}
}
154 changes: 130 additions & 24 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { denoPlugins } from '@luca/esbuild-deno-loader'
import * as esbuild from 'esbuild'
import tsid from 'unplugin-isolated-decl/esbuild'
import denoJson from '../deno.json' with { type: 'json' }

try {
await Deno.remove('dist', { recursive: true })
await Deno.mkdir('dist')
} catch (err) {
if (!(err instanceof Deno.errors.NotFound)) {
throw err
}
}

await esbuild.build({
plugins: [...denoPlugins()],
plugins: [
tsid(),
...denoPlugins(),
],
entryPoints: [denoJson.exports],
outfile: 'dist/index.js',
outdir: 'dist',
bundle: true,
format: 'esm',
platform: 'neutral',
Expand Down Expand Up @@ -48,4 +53,4 @@ await Deno.writeTextFile(
await Deno.copyFile('LICENSE.md', 'dist/LICENSE.md')
await Deno.copyFile('README.md', 'dist/README.md')

// TODO: make it more generic, emit dts files too
// TODO: make it more generic

0 comments on commit 47289fc

Please sign in to comment.