@jterrazz/typescript 4.3.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  Drop-in TypeScript build tooling with zero configuration.
4
4
 
5
- ## About
6
-
7
- _Hey there – I'm Jean-Baptiste, just another developer doing weird things with code. All my projects live on [jterrazz.com](https://jterrazz.com) – complete with backstories and lessons learned. Feel free to poke around – you might just find something useful!_
8
-
9
5
  ## Installation
10
6
 
11
7
  ```bash
@@ -26,30 +22,30 @@ npm install @jterrazz/typescript
26
22
  ### 2. Use the CLI
27
23
 
28
24
  ```bash
29
- npx typescript watch # Watch mode (build + run on changes)
30
- npx typescript build --app # Production build (ESM + types)
31
- npx typescript build --lib # Library build (ESM + CJS + types)
25
+ npx typescript build # Build application (ESM + types)
26
+ npx typescript bundle # Bundle library (ESM + CJS + types)
27
+ npx typescript start # Run the built application
28
+ npx typescript dev # Build, run, and rebuild on changes
32
29
  ```
33
30
 
34
31
  ## What you get
35
32
 
36
- - **Blazing fast** — Powered by [Rolldown](https://rolldown.rs) (Rust) and [tsgo](https://github.com/nicolo-ribaudo/typescript-go) (Go)
33
+ - **Blazing fast** — Powered by [tsdown](https://tsdown.dev) / [Rolldown](https://rolldown.rs) (Rust)
37
34
  - **Zero configuration** — Works out of the box
38
35
  - **Multiple outputs** — ESM + CommonJS + TypeScript declarations
39
36
  - **Source maps** — Full debugging support
40
37
 
41
38
  ### Build outputs
42
39
 
43
- | Command | Output | Description |
44
- | ------------------------ | ----------------- | ------------------------------- |
45
- | `typescript watch` | `dist/index.js` | ESM only, fast rebuilds (~20ms) |
46
- | `typescript build --app` | `dist/index.js` | ESM bundle |
47
- | | `dist/index.d.ts` | TypeScript declarations |
48
- | `typescript build --lib` | `dist/index.js` | ESM bundle |
49
- | | `dist/index.cjs` | CommonJS bundle |
50
- | | `dist/index.d.ts` | TypeScript declarations |
51
-
52
- If `src/instrumentation.ts` exists, it will also generate corresponding `instrumentation.*` files.
40
+ | Command | Output | Description |
41
+ | ------------------- | ----------------- | ----------------------- |
42
+ | `typescript build` | `dist/index.js` | ESM bundle |
43
+ | | `dist/index.d.ts` | TypeScript declarations |
44
+ | `typescript bundle` | `dist/index.js` | ESM bundle |
45
+ | | `dist/index.cjs` | CommonJS bundle |
46
+ | | `dist/index.d.ts` | TypeScript declarations |
47
+ | `typescript start` | — | Runs `dist/index.js` |
48
+ | `typescript dev` | `dist/index.js` | Watch + rebuild + run |
53
49
 
54
50
  ## Project structure
55
51
 
@@ -66,11 +62,11 @@ your-project/
66
62
 
67
63
  The package uses a fully compiled toolchain — no JavaScript in the hot path:
68
64
 
69
- | Step | Tool | Language |
70
- | ------------ | ------------------------------------------------------- | -------- |
71
- | Transpile | [Oxc](https://oxc.rs) (via Rolldown) | Rust |
72
- | Bundle | [Rolldown](https://rolldown.rs) | Rust |
73
- | Declarations | [tsgo](https://github.com/nicolo-ribaudo/typescript-go) | Go |
65
+ | Step | Tool | Language |
66
+ | ------------ | ------------------------------------- | -------- |
67
+ | Transpile | [Oxc](https://oxc.rs) (via tsdown) | Rust |
68
+ | Bundle | [Rolldown](https://rolldown.rs) | Rust |
69
+ | Declarations | [tsdown](https://tsdown.dev) built-in | Rust |
74
70
 
75
71
  ## License
76
72
 
package/bin/typescript.sh CHANGED
@@ -39,83 +39,67 @@ find_binary() {
39
39
  fi
40
40
  }
41
41
 
42
- ROLLDOWN=$(find_binary rolldown)
43
- NODEMON=$(find_binary nodemon)
44
-
45
- # Add both bin directories to PATH so plugins can find binaries like tsgo
46
- export PATH="$PACKAGE_ROOT/node_modules/.bin:$PROJECT_ROOT/node_modules/.bin:$PATH"
42
+ TSDOWN=$(find_binary tsdown)
47
43
 
48
44
  # Parse command
49
45
  COMMAND="$1"
50
46
  shift 2>/dev/null || true
51
47
 
48
+ run_tsdown() {
49
+ local CONFIG_PATH="$1"
50
+ local LABEL="$2"
51
+
52
+ printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} ${LABEL}...\n\n"
53
+
54
+ cd "$PROJECT_ROOT"
55
+
56
+ if ! "$TSDOWN" --config "$CONFIG_PATH" --cwd "$PROJECT_ROOT"; then
57
+ printf "${RED}Error: Build failed${NC}\n"
58
+ exit 1
59
+ fi
60
+
61
+ printf "\n${GREEN}Build completed${NC}\n"
62
+ }
63
+
52
64
  case "$COMMAND" in
53
65
  build)
54
- # Parse build arguments (required: --app or --lib)
55
- BUILD_MODE=""
56
- for arg in "$@"; do
57
- case $arg in
58
- --lib)
59
- BUILD_MODE="lib"
60
- ;;
61
- --app)
62
- BUILD_MODE="app"
63
- ;;
64
- esac
65
- done
66
-
67
- if [ -z "$BUILD_MODE" ]; then
68
- printf "${RED}Error: Build mode required. Use --app or --lib${NC}\n\n"
69
- printf " --app Build for applications (ESM + types)\n"
70
- printf " --lib Build for libraries (ESM + CJS + types)\n"
71
- exit 1
72
- fi
73
-
74
- CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.build.config.js"
75
-
76
- printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Building with Rolldown (${BUILD_MODE} mode)...\n\n"
77
- printf "Project root: %s\n" "$PROJECT_ROOT"
78
- printf "Config path: %s\n\n" "$CONFIG_PATH"
79
-
80
- cd "$PROJECT_ROOT"
66
+ run_tsdown "$SCRIPT_DIR/../config/tsdown.build.ts" "Building application (ESM + types)"
67
+ ;;
81
68
 
82
- if ! BUILD_MODE="$BUILD_MODE" "$ROLLDOWN" --config "$CONFIG_PATH"; then
83
- printf "${RED}Error: Build failed${NC}\n"
84
- exit 1
85
- fi
69
+ bundle)
70
+ run_tsdown "$SCRIPT_DIR/../config/tsdown.bundle.ts" "Bundling library (ESM + CJS + types)"
71
+ ;;
86
72
 
87
- printf "\n${GREEN}Build completed${NC}\n"
73
+ start)
74
+ cd "$PROJECT_ROOT"
75
+ exec node --enable-source-maps dist/index.js "$@"
88
76
  ;;
89
77
 
90
- watch)
91
- CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.dev.config.js"
78
+ dev)
79
+ CONFIG_PATH="$SCRIPT_DIR/../config/tsdown.build.ts"
92
80
 
93
- printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Starting watch mode...\n\n"
94
- printf "Project root: %s\n" "$PROJECT_ROOT"
95
- printf "Config path: %s\n" "$CONFIG_PATH"
96
- printf "Watching: %s/src\n\n" "$PROJECT_ROOT"
81
+ printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Starting dev mode...\n\n"
97
82
 
98
83
  cd "$PROJECT_ROOT"
99
84
 
100
- "$NODEMON" --quiet \
101
- --watch src \
102
- --ext 'ts,tsx,js,json' \
103
- --exec "if OUTPUT=\$(\"$ROLLDOWN\" --config \"$CONFIG_PATH\" 2>&1); then printf '${GREEN}Rebuilt${NC}\n'; node --enable-source-maps dist/index.js; else echo \"\$OUTPUT\" | grep -v 'tsgo.*experimental' | grep -v 'PLUGIN_TIMINGS'; exit 1; fi"
85
+ "$TSDOWN" --config "$CONFIG_PATH" --cwd "$PROJECT_ROOT" \
86
+ --watch \
87
+ --on-success "node --enable-source-maps dist/index.js"
104
88
  ;;
105
89
 
106
90
  *)
107
91
  printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} TypeScript/Node project toolkit\n\n"
108
- printf "Usage: typescript <command> [options]\n\n"
92
+ printf "Usage: typescript <command>\n\n"
109
93
  printf "Commands:\n"
110
- printf " build Build the project\n"
111
- printf " watch Start watch mode (build + run on changes)\n\n"
112
- printf "Build options:\n"
113
- printf " --app Build for applications (ESM + types)\n"
114
- printf " --lib Build for libraries (ESM + CJS + types)\n\n"
94
+ printf " build Build application (ESM + types)\n"
95
+ printf " bundle Bundle library (ESM + CJS + types)\n"
96
+ printf " start Run the built application\n"
97
+ printf " dev Build, run, and rebuild on changes\n\n"
115
98
  printf "Examples:\n"
116
- printf " typescript build --lib\n"
117
- printf " typescript build --app\n"
118
- printf " typescript watch\n"
99
+ printf " typescript build\n"
100
+ printf " typescript bundle\n"
101
+ printf " typescript start\n"
102
+ printf " typescript dev\n"
119
103
  exit 1
120
104
  ;;
121
105
  esac
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm"],
6
+ dts: true,
7
+ sourcemap: true,
8
+ clean: true,
9
+ hash: false,
10
+ outExtensions: () => ({
11
+ js: ".js",
12
+ }),
13
+ });
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm", "cjs"],
6
+ dts: true,
7
+ sourcemap: true,
8
+ clean: true,
9
+ hash: false,
10
+ outExtensions: ({ format }) => ({
11
+ js: format === "cjs" ? ".cjs" : ".js",
12
+ }),
13
+ });
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@jterrazz/typescript",
3
- "version": "4.3.1",
3
+ "version": "5.0.0",
4
4
  "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/jterrazz/package-typescript"
8
+ },
5
9
  "bin": {
6
10
  "typescript": "bin/typescript.sh"
7
11
  },
@@ -21,22 +25,11 @@
21
25
  "build": "# no build script"
22
26
  },
23
27
  "dependencies": {
24
- "@typescript/native-preview": "^7.0.0-dev.20260124.1",
25
- "nodemon": "3.1.11",
26
- "rolldown": "^1.0.0-rc.1",
27
- "rolldown-plugin-dts": "^0.21.6"
28
+ "tsdown": "^0.21.5"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@jterrazz/codestyle": "^1.2.6",
31
- "@types/node": "^25.0.10",
32
- "vitest": "^4.0.18"
33
- },
34
- "peerDependencies": {
35
- "@types/node": "*"
36
- },
37
- "peerDependenciesMeta": {
38
- "@types/node": {
39
- "optional": true
40
- }
32
+ "@types/node": "^25.5.0",
33
+ "vitest": "^4.1.2"
41
34
  }
42
35
  }
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "display": "Expo",
3
- "include": ["../../../../src/"],
3
+ "include": ["../../../../**/*.ts", "../../../../**/*.tsx"],
4
+ "exclude": ["../../../../node_modules"],
4
5
 
5
6
  "compilerOptions": {
6
7
  "allowJs": true,
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "display": "Node ESM",
3
- "include": ["../../../../src/"],
3
+ "include": ["../../../../**/*.ts"],
4
+ "exclude": ["../../../../node_modules"],
4
5
 
5
6
  "compilerOptions": {
6
7
  "moduleResolution": "Bundler",
@@ -1,46 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { defineConfig } from "rolldown";
3
- import { dts } from "rolldown-plugin-dts";
4
-
5
- // Build mode: 'lib' = ESM + CJS + types, 'app' = ESM + types only
6
- const isLibrary = process.env.BUILD_MODE === "lib";
7
-
8
- // Externalize all dependencies (node built-ins + node_modules)
9
- const external = [/node_modules/, /^node:/, /^[a-z@]/];
10
-
11
- // Build input with optional instrumentation entry point
12
- const input = {
13
- index: "src/index.ts",
14
- ...(existsSync("src/instrumentation.ts") && { instrumentation: "src/instrumentation.ts" }),
15
- };
16
-
17
- // ESM build with .d.ts generation
18
- const esmBuild = defineConfig({
19
- input,
20
- external,
21
- plugins: [
22
- dts({
23
- // Use TypeScript Go for fastest .d.ts generation (experimental)
24
- tsgo: true,
25
- }),
26
- ],
27
- output: {
28
- dir: "dist",
29
- format: "esm",
30
- sourcemap: true,
31
- },
32
- });
33
-
34
- // CJS build (no dts - already generated by ESM build)
35
- const cjsBuild = defineConfig({
36
- input,
37
- external,
38
- output: {
39
- dir: "dist",
40
- entryFileNames: "[name].cjs",
41
- format: "cjs",
42
- sourcemap: true,
43
- },
44
- });
45
-
46
- export default isLibrary ? [esmBuild, cjsBuild] : [esmBuild];
@@ -1,20 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { defineConfig } from "rolldown";
3
-
4
- // Build input with optional instrumentation entry point
5
- const input = {
6
- index: "src/index.ts",
7
- ...(existsSync("src/instrumentation.ts") && { instrumentation: "src/instrumentation.ts" }),
8
- };
9
-
10
- // Dev build - ESM only, no .d.ts (faster rebuilds)
11
- // Externalize all dependencies for Node.js apps
12
- export default defineConfig({
13
- input,
14
- external: [/node_modules/, /^node:/, /^[a-z@]/],
15
- output: {
16
- dir: "dist",
17
- format: "esm",
18
- sourcemap: true,
19
- },
20
- });