Skip to content

Commit cc41cee

Browse files
committed
fix: use TypeScript syntax in source code
1 parent 45f9394 commit cc41cee

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

build.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { resolve, dirname } from 'path'
2-
import { copy, copyFile, outputFile, readJSON, writeJSON } from 'fs-extra'
2+
import { copy, outputFile } from 'fs-extra'
33
import ncc from '@vercel/ncc'
44

55
async function main() {
66
const rootDir = __dirname
7+
const declarationFileName = 'jimp.d.ts'
78
const input = resolve(rootDir, 'src', 'jimp.ts')
89
const output = resolve(rootDir, 'dist', 'jimp.cjs')
9-
const pkg = resolve(rootDir, 'package.json')
10+
const declaration = resolve(rootDir, 'dist', declarationFileName)
1011

1112
const opts = {
1213
cache: false,
@@ -15,11 +16,12 @@ async function main() {
1516
}
1617

1718
// @ts-ignore
18-
let { code } = await ncc(input, opts)
19+
let { code, assets } = await ncc(input, opts)
1920

2021
code = code.replace(/new Buffer/g, 'new JIMPBUffer')
2122

2223
await outputFile(output, code)
24+
await outputFile(declaration , assets[declarationFileName].source)
2325

2426
const jimpDir = dirname(require.resolve('jimp/package.json'))
2527
// const { version } = await readJSON(resolve(jimpDir, 'package.json'))
@@ -28,8 +30,6 @@ async function main() {
2830

2931
await copy(resolve(jimpDir, 'fonts'), resolve(rootDir, 'fonts'))
3032

31-
await copyFile(resolve(jimpDir, 'types/ts3.1/index.d.ts'), resolve(rootDir, 'dist/jimp.d.ts'))
32-
3333
// console.log('jimp-compact@' + version)
3434
}
3535

src/jimp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class JIMPBUffer {
1616

1717
globalThis.JIMPBUffer = JIMPBUffer
1818

19-
module.exports = jimp
19+
export = jimp

0 commit comments

Comments
 (0)