Skip to content

Commit 02dfe2b

Browse files
authored
remove tsdx, add rollup build (#595)
2 parents 4970a12 + 5d4f02c commit 02dfe2b

File tree

5 files changed

+781
-4597
lines changed

5 files changed

+781
-4597
lines changed

packages/client/package.json

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,19 @@
44
"private": true,
55
"license": "MIT",
66
"main": "dist/index.js",
7+
"module": "dist/index.esm.js",
78
"typings": "dist/index.d.ts",
89
"files": [
910
"dist",
1011
"src"
1112
],
1213
"engines": {
13-
"node": ">=10"
14+
"node": ">=12"
1415
},
1516
"scripts": {
16-
"start": "tsdx watch",
17-
"build": "tsdx build",
18-
"test": "tsdx test",
19-
"lint": "tsdx lint",
20-
"prepare": "tsdx build",
21-
"size": "size-limit",
22-
"analyze": "size-limit --why"
23-
},
24-
"husky": {
25-
"hooks": {
26-
"pre-commit": "tsdx lint"
27-
}
17+
"build": "rimraf dist && tsc && rollup --bundleConfigAsCjs -c",
18+
"dev": "rollup --bundleConfigAsCjs -c -w",
19+
"lint": "eslint 'src/**/*.ts'"
2820
},
2921
"prettier": {
3022
"printWidth": 80,
@@ -33,23 +25,24 @@
3325
"trailingComma": "es5"
3426
},
3527
"author": "Colin Kennedy",
36-
"module": "dist/client.esm.js",
37-
"size-limit": [
38-
{
39-
"path": "dist/client.cjs.production.min.js",
40-
"limit": "10 KB"
41-
},
42-
{
43-
"path": "dist/client.esm.js",
44-
"limit": "10 KB"
45-
}
46-
],
4728
"dependencies": {
4829
"axios": "^1.7.4",
4930
"command-line-args": "^5.2.1"
5031
},
5132
"devDependencies": {
33+
"@rollup/plugin-commonjs": "^25.0.7",
34+
"@rollup/plugin-node-resolve": "^15.2.3",
35+
"@rollup/plugin-typescript": "^11.1.6",
36+
"@types/jest": "^29.5.12",
5237
"@types/node": "^20.2.5",
53-
"tsdx": "^0.14.1"
38+
"@typescript-eslint/eslint-plugin": "^7.4.0",
39+
"@typescript-eslint/parser": "^7.4.0",
40+
"eslint": "^8.57.0",
41+
"jest": "^29.7.0",
42+
"rimraf": "^5.0.5",
43+
"rollup": "^4.12.1",
44+
"ts-jest": "^29.1.2",
45+
"tslib": "^2.6.2",
46+
"typescript": "^5.4.2"
5447
}
5548
}

packages/client/rollup.config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import resolve from '@rollup/plugin-node-resolve';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import typescript from '@rollup/plugin-typescript';
4+
import { defineConfig } from 'rollup';
5+
6+
export default defineConfig({
7+
input: 'src/index.ts',
8+
output: [
9+
{
10+
file: 'dist/index.js',
11+
format: 'cjs',
12+
sourcemap: true,
13+
},
14+
{
15+
file: 'dist/index.esm.js',
16+
format: 'esm',
17+
sourcemap: true,
18+
},
19+
],
20+
// Mark all Node.js built-ins and dependencies as external
21+
external: [
22+
/node_modules/,
23+
'fs',
24+
'path',
25+
'buffer',
26+
'axios',
27+
'command-line-args',
28+
],
29+
plugins: [
30+
resolve({
31+
preferBuiltins: true,
32+
}),
33+
commonjs(),
34+
typescript({
35+
tsconfig: './tsconfig.json',
36+
sourceMap: true,
37+
}),
38+
],
39+
});

packages/client/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as fs from 'fs';
2-
// import { addNote55 } from '../../vue/src/db/courseDB';
3-
// import PouchDb from 'pouchdb-core';
4-
import console from 'console';
5-
import Blob from 'buffer';
62
import axios from 'axios';
3+
74
// import { addNote55 } from 'new-skuilder';
85

96
// const spellingCourseID = 'a9fae15687220aa6ce62018005087c95';
107
// testAPI();
118

9+
type AudioData = Buffer;
10+
1211
makeSpellingNotes();
1312
makeSelectionNotes();
1413

@@ -59,7 +58,7 @@ function isCVCeWord(w: string): boolean {
5958

6059
function cardText(w: string): string {
6160
return `Spell the word:
62-
61+
6362
{{ ${w} }}`;
6463
}
6564

@@ -114,7 +113,7 @@ function spellingCardTags(w: string): string[] {
114113

115114
type spellingNote = {
116115
md: string;
117-
audio: Blob.Blob;
116+
audio: AudioData;
118117
tags: string[];
119118
};
120119

packages/client/tsconfig.json

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
11
{
2-
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
3-
"include": ["src", "types"],
42
"compilerOptions": {
5-
"module": "esnext",
6-
"lib": ["dom", "esnext"],
7-
"importHelpers": true,
8-
// output .d.ts declaration files for consumers
9-
"declaration": true,
10-
// output .js.map sourcemap files for consumers
3+
"target": "es2018",
4+
"module": "esnext", // Changed from "commonjs" to "esnext"
5+
"lib": ["es2018"],
6+
"moduleResolution": "node",
117
"sourceMap": true,
12-
// match output dir to input dir. e.g. dist/index instead of dist/src/index
13-
"rootDir": "./src",
14-
// stricter type-checking for stronger correctness. Recommended by TS
15-
"strict": true,
16-
// linter checks for common issues
8+
"declaration": true,
9+
"esModuleInterop": true,
1710
"noImplicitReturns": true,
18-
"noFallthroughCasesInSwitch": true,
19-
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
11+
"noImplicitThis": true,
12+
"noImplicitAny": true,
13+
"strictNullChecks": true,
2014
"noUnusedLocals": true,
2115
"noUnusedParameters": true,
22-
// use Node's module resolution algorithm, instead of the legacy TS one
23-
"moduleResolution": "node",
24-
// transpile JSX to React.createElement
25-
"jsx": "react",
26-
// interop between ESM and CJS modules. Recommended by TS
27-
"esModuleInterop": true,
28-
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
16+
"allowSyntheticDefaultImports": true,
17+
"outDir": "dist",
18+
"declarationDir": "dist",
19+
"resolveJsonModule": true,
2920
"skipLibCheck": true,
30-
// error out if import and file system have a casing mismatch. Recommended by TS
31-
"forceConsistentCasingInFileNames": true,
32-
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
33-
"noEmit": true,
34-
// for yarn 2 monorepo support
35-
"composite": true
36-
}
21+
"forceConsistentCasingInFileNames": true
22+
},
23+
"include": ["src"],
24+
"exclude": ["node_modules", "dist"]
3725
}

0 commit comments

Comments
 (0)