Skip to content

Commit 5e7b8b5

Browse files
Convert to typescript (#287)
* Convert expiring map to JS * Conver option list to TypeScript * Fix ESM plugin loading This doesn’t seem to actually have any side-effects but typescript has revealed possible issues here * Convert plugin loading to typescript * Convert config loading to typescript * Convert sorting code to typescript * Convert utils to typescript * Add types * Convert main file to typescript * wip * Make package type: module * Switch to vitest * Update lockfile * Run fixture tests concurrently * Use tsup for building dts files Can’t use it to bundle just yet * Bump test timeout * Use Node 18 in CI * Use Node v22 in CI Worth seeing if it makes things faster * Remove expired data from maps to prevent memory leaks * Update comments * Remove comments Probably isn’t any reason for this actually * Add better types to `prefixCandidate`
1 parent aa6ec0a commit 5e7b8b5

28 files changed

+4386
-5706
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
env:
1717
CI: true
1818
CACHE_PREFIX: stable
19-
NODE_VERSION: 16
19+
NODE_VERSION: 22
2020

2121
jobs:
2222
build:

build.mjs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import fs from 'fs'
2-
import path from 'path'
3-
import { fileURLToPath } from 'url'
1+
import * as fs from 'node:fs'
2+
import * as path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
44
import esbuild from 'esbuild'
55

66
/**
@@ -62,23 +62,6 @@ function patchCjsInterop() {
6262
}
6363
}
6464

65-
/**
66-
* @returns {import('esbuild').Plugin}
67-
*/
68-
function copyTypes() {
69-
return {
70-
name: 'copy-types',
71-
setup(build) {
72-
build.onEnd(() =>
73-
fs.promises.copyFile(
74-
path.resolve(__dirname, './src/index.d.ts'),
75-
path.resolve(__dirname, './dist/index.d.ts'),
76-
),
77-
)
78-
},
79-
}
80-
}
81-
8265
const __dirname = path.dirname(fileURLToPath(import.meta.url))
8366

8467
let context = await esbuild.context({
@@ -90,7 +73,7 @@ let context = await esbuild.context({
9073
entryPoints: [path.resolve(__dirname, './src/index.js')],
9174
outfile: path.resolve(__dirname, './dist/index.mjs'),
9275
format: 'esm',
93-
plugins: [patchRecast(), patchCjsInterop(), copyTypes()],
76+
plugins: [patchRecast(), patchCjsInterop()],
9477
})
9578

9679
await context.rebuild()

0 commit comments

Comments
 (0)