@jterrazz/typescript 4.3.0 → 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
@@ -27,84 +27,79 @@ done
27
27
  SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
28
28
  PACKAGE_ROOT="$SCRIPT_DIR/.."
29
29
 
30
- # Use binaries from the package's node_modules
31
- ROLLDOWN="$PACKAGE_ROOT/node_modules/.bin/rolldown"
32
- NODEMON="$PACKAGE_ROOT/node_modules/.bin/nodemon"
33
-
34
- # Add package's node_modules/.bin to PATH so plugins can find binaries like tsgo
35
- export PATH="$PACKAGE_ROOT/node_modules/.bin:$PATH"
30
+ # Find binaries - check package's node_modules first, then project's (handles npm hoisting)
31
+ find_binary() {
32
+ local name="$1"
33
+ if [ -x "$PACKAGE_ROOT/node_modules/.bin/$name" ]; then
34
+ echo "$PACKAGE_ROOT/node_modules/.bin/$name"
35
+ elif [ -x "$PROJECT_ROOT/node_modules/.bin/$name" ]; then
36
+ echo "$PROJECT_ROOT/node_modules/.bin/$name"
37
+ else
38
+ echo "$name" # Fallback to PATH
39
+ fi
40
+ }
41
+
42
+ TSDOWN=$(find_binary tsdown)
36
43
 
37
44
  # Parse command
38
45
  COMMAND="$1"
39
46
  shift 2>/dev/null || true
40
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
+
41
64
  case "$COMMAND" in
42
65
  build)
43
- # Parse build arguments (required: --app or --lib)
44
- BUILD_MODE=""
45
- for arg in "$@"; do
46
- case $arg in
47
- --lib)
48
- BUILD_MODE="lib"
49
- ;;
50
- --app)
51
- BUILD_MODE="app"
52
- ;;
53
- esac
54
- done
55
-
56
- if [ -z "$BUILD_MODE" ]; then
57
- printf "${RED}Error: Build mode required. Use --app or --lib${NC}\n\n"
58
- printf " --app Build for applications (ESM + types)\n"
59
- printf " --lib Build for libraries (ESM + CJS + types)\n"
60
- exit 1
61
- fi
62
-
63
- CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.build.config.js"
64
-
65
- printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Building with Rolldown (${BUILD_MODE} mode)...\n\n"
66
- printf "Project root: %s\n" "$PROJECT_ROOT"
67
- printf "Config path: %s\n\n" "$CONFIG_PATH"
68
-
69
- cd "$PROJECT_ROOT"
66
+ run_tsdown "$SCRIPT_DIR/../config/tsdown.build.ts" "Building application (ESM + types)"
67
+ ;;
70
68
 
71
- if ! BUILD_MODE="$BUILD_MODE" "$ROLLDOWN" --config "$CONFIG_PATH"; then
72
- printf "${RED}Error: Build failed${NC}\n"
73
- exit 1
74
- fi
69
+ bundle)
70
+ run_tsdown "$SCRIPT_DIR/../config/tsdown.bundle.ts" "Bundling library (ESM + CJS + types)"
71
+ ;;
75
72
 
76
- printf "\n${GREEN}Build completed${NC}\n"
73
+ start)
74
+ cd "$PROJECT_ROOT"
75
+ exec node --enable-source-maps dist/index.js "$@"
77
76
  ;;
78
77
 
79
- watch)
80
- CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.dev.config.js"
78
+ dev)
79
+ CONFIG_PATH="$SCRIPT_DIR/../config/tsdown.build.ts"
81
80
 
82
- printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Starting watch mode...\n\n"
83
- printf "Project root: %s\n" "$PROJECT_ROOT"
84
- printf "Config path: %s\n" "$CONFIG_PATH"
85
- printf "Watching: %s/src\n\n" "$PROJECT_ROOT"
81
+ printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} Starting dev mode...\n\n"
86
82
 
87
83
  cd "$PROJECT_ROOT"
88
84
 
89
- "$NODEMON" --quiet \
90
- --watch src \
91
- --ext 'ts,tsx,js,json' \
92
- --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"
93
88
  ;;
94
89
 
95
90
  *)
96
91
  printf "${CYAN_BG}${BRIGHT_WHITE} TYPESCRIPT ${NC} TypeScript/Node project toolkit\n\n"
97
- printf "Usage: typescript <command> [options]\n\n"
92
+ printf "Usage: typescript <command>\n\n"
98
93
  printf "Commands:\n"
99
- printf " build Build the project\n"
100
- printf " watch Start watch mode (build + run on changes)\n\n"
101
- printf "Build options:\n"
102
- printf " --app Build for applications (ESM + types)\n"
103
- 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"
104
98
  printf "Examples:\n"
105
- printf " typescript build --lib\n"
106
- printf " typescript build --app\n"
107
- printf " typescript watch\n"
99
+ printf " typescript build\n"
100
+ printf " typescript bundle\n"
101
+ printf " typescript start\n"
102
+ printf " typescript dev\n"
108
103
  exit 1
109
104
  ;;
110
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.0",
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
- });