Skip to content

Commit dd7d959

Browse files
authored
chore: migrate to tsdown (#7405)
1 parent 1f6bfac commit dd7d959

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1427
-950
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export default tsEslint.config(
246246
'**/*.spec.*',
247247
'**/*.test.*',
248248
'**/build.mjs',
249+
'**/tsdown.config.*',
249250
'**/tsup.config.*',
250251
'**/rollup.config.mjs',
251252
'**/perf/**',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"ts-jest": "^29.3.4",
130130
"ts-node": "^10.9.2",
131131
"ts2mjs": "^3.0.0",
132+
"tsdown": "^0.12.3",
132133
"tslib": "^2.8.1",
133134
"tsup": "^8.5.0",
134135
"typescript": "~5.8.3",

packages/cspell-io/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"!**/*.map"
2424
],
2525
"scripts": {
26-
"build": "tsup-node",
27-
"build:watch": "tsup-node --watch",
26+
"build": "tsdown",
27+
"build:watch": "tsdown --watch",
2828
"watch": "pnpm build:watch",
2929
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
3030
"clean-build": "pnpm run clean && pnpm run build",

packages/cspell-io/src/CSpellIONode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { RequestFsReadDirectory } from './requests/RequestFsReadDirectory.js';
2828
let defaultCSpellIONode: CSpellIO | undefined = undefined;
2929

3030
export class CSpellIONode implements CSpellIO {
31-
constructor(readonly serviceBus = new ServiceBus()) {
31+
constructor(readonly serviceBus: ServiceBus = new ServiceBus()) {
3232
registerHandlers(serviceBus);
3333
}
3434

packages/cspell-io/src/common/CFileReference.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import type { BufferEncoding } from '../models/BufferEncoding.js';
22
import type { FileReference, FileResourceRequest, UrlOrReference } from '../models/FileResource.js';
33
import { toFileURL } from '../node/file/url.js';
44

5+
export interface CFileReferenceJson {
6+
url: string;
7+
encoding?: string | undefined;
8+
baseFilename?: string | undefined;
9+
gz?: boolean | undefined;
10+
}
11+
512
export class CFileReference implements FileReference {
613
/**
714
* Use to ensure the nominal type separation between CFileReference and FileReference
@@ -46,7 +53,7 @@ export class CFileReference implements FileReference {
4653
);
4754
}
4855

49-
public toJson() {
56+
public toJson(): CFileReferenceJson {
5057
return {
5158
url: this.url.href,
5259
encoding: this.encoding,

packages/cspell-io/src/common/CFileResource.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import type { BufferEncoding } from '../models/BufferEncoding.js';
33
import type { FileReference, FileResource, TextFileResource } from '../models/FileResource.js';
44
import { decode, encodeString, isGZipped } from './encode-decode.js';
55

6+
export interface CFileResourceJson {
7+
url: string;
8+
content: string;
9+
encoding?: string | undefined;
10+
baseFilename?: string | undefined;
11+
gz: boolean;
12+
}
13+
614
export class CFileResource implements TextFileResource {
715
private _text?: string;
816
readonly baseFilename?: string | undefined;
@@ -41,7 +49,7 @@ export class CFileResource implements TextFileResource {
4149
: new Uint8Array(arrayBufferview.buffer, arrayBufferview.byteOffset, arrayBufferview.byteLength);
4250
}
4351

44-
public toJson() {
52+
public toJson(): CFileResourceJson {
4553
return {
4654
url: this.url.href,
4755
content: this.getText(),

packages/cspell-io/src/common/arrayBuffers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export function swapBytes(data: ArrayBufferView): ArrayBufferView {
7575
return swap16(buf);
7676
}
7777

78-
export const __debug__ = {
78+
export const __debug__: {
79+
swap16Poly: typeof swap16Poly;
80+
} = {
7981
swap16Poly,
8082
};

packages/cspell-io/src/handlers/node/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async function compressAndChainWriteRequest(
258258
return res.value;
259259
}
260260

261-
export function registerHandlers(serviceBus: ServiceBus) {
261+
export function registerHandlers(serviceBus: ServiceBus): void {
262262
/**
263263
* Handlers are in order of low to high level
264264
* Order is VERY important.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* eslint-disable n/no-unsupported-features/node-builtins */
22
/** alias of global.fetch, useful for mocking */
3-
export const _fetch = global.fetch;
3+
export const _fetch: typeof global.fetch = global.fetch;
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ServiceRequestFactoryRequestType } from '@cspell/cspell-service-bus';
1+
import type { RequestFactory, ServiceRequestFactoryRequestType } from '@cspell/cspell-service-bus';
22
import { requestFactory } from '@cspell/cspell-service-bus';
33

44
import type { DirEntry } from '../models/Stats.js';
@@ -8,7 +8,6 @@ interface RequestParams {
88
readonly url: URL;
99
}
1010

11-
export const RequestFsReadDirectory = requestFactory<typeof RequestType, RequestParams, Promise<DirEntry[]>>(
12-
RequestType,
13-
);
14-
export type RequestFsReadDirectory = ServiceRequestFactoryRequestType<typeof RequestFsReadDirectory>;
11+
export type RequestFsReadDirectoryFactory = RequestFactory<typeof RequestType, RequestParams, Promise<DirEntry[]>>;
12+
export type RequestFsReadDirectory = ServiceRequestFactoryRequestType<RequestFsReadDirectoryFactory>;
13+
export const RequestFsReadDirectory: RequestFsReadDirectoryFactory = requestFactory(RequestType);

0 commit comments

Comments
 (0)