Skip to content

Commit 76f2acf

Browse files
TS6 & TSDown (#48)
1 parent c988397 commit 76f2acf

11 files changed

Lines changed: 1121 additions & 825 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ jobs:
3333
- name: Run lint
3434
run: yarn lint
3535

36+
types:
37+
name: Type check
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
42+
43+
- name: Setup node
44+
uses: ./.github/actions/setup-node
45+
46+
- name: Run type check
47+
run: yarn types
48+
3649
build:
3750
name: Build
3851
runs-on: ubuntu-latest

‎.lintstagedrc‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.lintstagedrc.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Configuration } from 'lint-staged';
2+
3+
const config: Configuration = {
4+
'*': () => ['oxlint', 'oxfmt'],
5+
};
6+
7+
export default config;

‎jest.config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import type { Config } from 'jest';
22

3+
import packageJson from './package.json' with { type: 'json' };
4+
35
const config: Config = {
46
preset: 'ts-jest',
57
testEnvironment: 'jsdom',
68
testMatch: ['<rootDir>/src/**/*.test.{js,jsx,ts,tsx}'],
9+
globals: {
10+
__VERSION__: JSON.stringify(packageJson.version),
11+
},
712
};
813

914
export default config;

‎package.json‎

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
"description": "Sigma Computing Plugin Client API",
55
"license": "MIT",
66
"homepage": "https://github.com/sigmacomputing/plugin",
7-
"main": "./dist/index.js",
7+
"type": "module",
8+
"main": "./dist/cjs/index.cjs",
9+
"module": "./dist/esm/index.js",
10+
"types": "./dist/cjs/index.d.cts",
11+
"exports": {
12+
".": {
13+
"import": {
14+
"types": "./dist/esm/index.d.ts",
15+
"default": "./dist/esm/index.js"
16+
},
17+
"require": {
18+
"types": "./dist/cjs/index.d.cts",
19+
"default": "./dist/cjs/index.cjs"
20+
}
21+
},
22+
"./package.json": "./package.json"
23+
},
824
"repository": {
925
"type": "git",
1026
"url": "https://github.com/sigmacomputing/plugin.git"
@@ -15,55 +31,48 @@
1531
},
1632
"packageManager": "yarn@4.13.0",
1733
"files": [
18-
"dist/**/*"
34+
"dist/**/*",
35+
"src/**/*",
36+
"!src/**/__tests__/**/*"
1937
],
20-
"typesVersions": {
21-
"*": {
22-
"react": [
23-
"dist/react/index.d.ts"
24-
]
25-
}
26-
},
2738
"publishConfig": {
2839
"access": "public"
2940
},
3041
"scripts": {
31-
"build": "yarn tsc --build tsconfig.build.json",
32-
"build:watch": "yarn build --watch",
42+
"build": "tsdown",
43+
"build:watch": "tsdown --watch",
3344
"format": "yarn oxfmt",
3445
"lint": "yarn oxlint",
3546
"precommit": "lint-staged",
3647
"publish": "yarn build && yarn npm publish",
3748
"test": "jest --ci",
38-
"test:watch": "yarn test --watch"
49+
"test:watch": "yarn test --watch",
50+
"types": "tsc --noEmit"
3951
},
4052
"peerDependencies": {
41-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
42-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
53+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
4354
},
4455
"peerDependenciesMeta": {
4556
"react": {
4657
"optional": true
47-
},
48-
"react-dom": {
49-
"optional": true
5058
}
5159
},
5260
"devDependencies": {
53-
"@jest/types": "^27.5.1",
54-
"@types/jest": "^27.5.1",
55-
"@types/node": "^18.7.14",
61+
"@arethetypeswrong/core": "^0.18.2",
62+
"@types/jest": "^30.0.0",
63+
"@types/node": "^24.0.0",
5664
"@types/react": "^19.0.0",
57-
"@types/react-dom": "^19.0.0",
5865
"jest": "^30.3.0",
5966
"jest-environment-jsdom": "^30.3.0",
60-
"jest-watch-typeahead": "^2.1.1",
61-
"lint-staged": "^13.0.3",
67+
"jest-watch-typeahead": "^3.0.1",
68+
"lint-staged": "^16.4.0",
6269
"oxfmt": "^0.38.0",
6370
"oxlint": "^1.53.0",
6471
"oxlint-tsgolint": "^0.16.0",
65-
"ts-jest": "^29.4.6",
66-
"ts-node": "^10.9.2",
67-
"typescript": "^4.8.2"
72+
"publint": "^0.3.18",
73+
"ts-jest": "^29.4.9",
74+
"tsdown": "^0.21.10",
75+
"typescript": "^6.0.2",
76+
"unplugin-unused": "^0.5.7"
6877
}
6978
}

‎src/client/initialize.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ export function initialize<T = {}>(): PluginInstance<T> {
4141
});
4242

4343
// send initialize event
44-
void execPromise(
45-
'wb:plugin:init',
46-
require('../../package.json').version,
47-
).then(config => {
44+
void execPromise('wb:plugin:init', __VERSION__).then(config => {
4845
Object.assign(pluginConfig, config);
4946
emit('init', pluginConfig);
5047
emit('config', pluginConfig.config);

‎src/globals.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare const __VERSION__: string;

‎src/react.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
export * from './react/hooks';
2-
export {
3-
SigmaClientProviderProps,
4-
SigmaClientProvider,
5-
} from './react/Provider';
2+
export type { SigmaClientProviderProps } from './react/Provider';
3+
export { SigmaClientProvider } from './react/Provider';

‎tsconfig.json‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
{
22
"compilerOptions": {
3-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
4-
"module": "CommonJS",
5-
"moduleResolution": "node",
6-
"target": "ES2015",
3+
"lib": ["DOM", "ESNext"],
74

8-
"baseUrl": "./",
9-
10-
"declaration": true,
11-
"declarationMap": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"target": "ESNext",
128

139
"jsx": "react-jsx",
14-
"downlevelIteration": true,
1510
"noImplicitAny": true,
1611
"strict": true,
1712

1813
"allowSyntheticDefaultImports": true,
1914
"esModuleInterop": true,
2015
"forceConsistentCasingInFileNames": true,
2116
"skipLibCheck": true,
22-
"resolveJsonModule": true
17+
"types": ["jest"]
2318
},
24-
"include": ["src", "jest.config.ts"]
19+
"include": ["src", "jest.config.ts", "tsdown.config.ts"]
2520
}

‎tsdown.config.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineConfig } from 'tsdown';
2+
3+
import packageJson from './package.json' with { type: 'json' };
4+
5+
export default defineConfig({
6+
clean: true,
7+
failOnWarn: true,
8+
logLevel: 'warn',
9+
10+
dts: true,
11+
entry: ['src/index.ts'],
12+
format: {
13+
esm: {
14+
outputOptions: {
15+
dir: 'dist/esm',
16+
},
17+
},
18+
cjs: {
19+
outputOptions: {
20+
dir: 'dist/cjs',
21+
},
22+
},
23+
},
24+
platform: 'browser',
25+
sourcemap: true,
26+
27+
define: {
28+
__VERSION__: JSON.stringify(packageJson.version),
29+
},
30+
31+
publint: true,
32+
attw: true,
33+
unused: true,
34+
});

0 commit comments

Comments
 (0)