@jterrazz/typescript 3.1.0 → 4.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
@@ -1,6 +1,8 @@
1
- # Package Typescript
1
+ *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!*
2
2
 
3
- Drop-in tsconfig presets for consistent builds.
3
+ # @jterrazz/typescript
4
+
5
+ Drop-in TypeScript build tooling with zero configuration.
4
6
 
5
7
  ## Installation
6
8
 
@@ -14,30 +16,33 @@ npm install @jterrazz/typescript
14
16
 
15
17
  ```json
16
18
  // tsconfig.json - Pick one:
17
- {
18
- "extends": "@jterrazz/typescript/tsconfig/node" // Node.js projects
19
- }
20
- {
21
- "extends": "@jterrazz/typescript/tsconfig/next" // Next.js projects
22
- }
23
- {
24
- "extends": "@jterrazz/typescript/tsconfig/expo" // Expo/React Native
25
- }
19
+ { "extends": "@jterrazz/typescript/tsconfig/node" } // Node.js projects
20
+ { "extends": "@jterrazz/typescript/tsconfig/next" } // Next.js projects
21
+ { "extends": "@jterrazz/typescript/tsconfig/expo" } // Expo/React Native
26
22
  ```
27
23
 
28
24
  ### 2. Use the build commands
29
25
 
30
26
  ```bash
31
27
  npx ts-dev # Development with watch mode
32
- npx ts-build # Production build (generates .js, .d.ts, .cjs)
28
+ npx ts-build # Production build
33
29
  ```
34
30
 
35
31
  ## What you get
36
32
 
37
- - **Fast compilation** with SWC (10x faster than tsc)
38
- - **Zero configuration** - works out of the box
39
- - **Multiple outputs** - ESM + CommonJS + TypeScript declarations
40
- - **Source maps** for debugging
33
+ - **Blazing fast** Powered by [Rolldown](https://rolldown.rs) (Rust) and [tsgo](https://github.com/nicolo-ribaudo/typescript-go) (Go)
34
+ - **Zero configuration** Works out of the box
35
+ - **Multiple outputs** ESM + CommonJS + TypeScript declarations
36
+ - **Source maps** Full debugging support
37
+
38
+ ### Build outputs
39
+
40
+ | Mode | Output | Description |
41
+ |------|--------|-------------|
42
+ | `ts-dev` | `dist/index.js` | ESM only, fast rebuilds (~20ms) |
43
+ | `ts-build` | `dist/index.js` | ESM bundle |
44
+ | | `dist/index.cjs` | CommonJS bundle |
45
+ | | `dist/index.d.ts` | TypeScript declarations |
41
46
 
42
47
  ## Project structure
43
48
 
@@ -49,7 +54,15 @@ your-project/
49
54
  └── tsconfig.json # Extends this package
50
55
  ```
51
56
 
52
- That's it! The package handles all the complex build configuration so you can focus on writing code.
57
+ ## How it works
58
+
59
+ The package uses a fully compiled toolchain — no JavaScript in the hot path:
60
+
61
+ | Step | Tool | Language |
62
+ |------|------|----------|
63
+ | Transpile | [Oxc](https://oxc.rs) (via Rolldown) | Rust |
64
+ | Bundle | [Rolldown](https://rolldown.rs) | Rust |
65
+ | Declarations | [tsgo](https://github.com/nicolo-ribaudo/typescript-go) | Go |
53
66
 
54
67
  ## License
55
68
 
package/bin/ts-build.sh CHANGED
@@ -3,70 +3,34 @@
3
3
  # Exit on error
4
4
  set -e
5
5
 
6
- # Colors for output (using Vitest-like colors)
6
+ # Colors for output
7
7
  RED='\033[0;31m'
8
8
  GREEN='\033[0;32m'
9
- CYAN_BG='\033[46m' # Cyan background
10
- BRIGHT_WHITE='\033[1;30m' # Bold black text
11
- NC='\033[0m' # No Color
9
+ CYAN_BG='\033[46m'
10
+ BRIGHT_WHITE='\033[1;30m'
11
+ NC='\033[0m'
12
12
 
13
13
  # Get the directory where the script is being called from (caller's project root)
14
- # If called through bin, we need to get the directory where the command was executed
15
14
  if [ -n "$INIT_CWD" ]; then
16
15
  PROJECT_ROOT="$INIT_CWD"
17
16
  else
18
17
  PROJECT_ROOT=$(pwd)
19
18
  fi
20
19
 
21
- printf "${CYAN_BG}${BRIGHT_WHITE} START ${NC} Starting TypeScript compilation process...\n\n"
20
+ # Get the directory where this script lives (inside @jterrazz/typescript)
21
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22
+ CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.build.config.js"
22
23
 
23
- # Default paths relative to project root
24
- IN_PATH="$PROJECT_ROOT/src"
25
- OUT_PATH="$PROJECT_ROOT/dist"
24
+ printf "${CYAN_BG}${BRIGHT_WHITE} BUILD ${NC} Building with Rolldown...\n\n"
26
25
 
27
- printf "Input directory: %s\n" "$IN_PATH"
28
- printf "Output directory: %s\n" "$OUT_PATH"
26
+ printf "Project root: %s\n" "$PROJECT_ROOT"
27
+ printf "Config path: %s\n\n" "$CONFIG_PATH"
29
28
 
30
- # Convert tsconfig.json to .swcrc
31
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Converting tsconfig.json to .swcrc\n\n"
32
- TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
33
- if [ $? -ne 0 ]; then
34
- printf "${RED}✗ Error: Can't create temporary .swcrc file${NC}\n"
35
- exit 1
36
- fi
37
-
38
- # Ensure we're in the project root directory for TypeScript configuration
39
29
  cd "$PROJECT_ROOT"
40
- npx tsconfig-to-swcconfig --output="$TMP_SWCRC"
41
- printf "${GREEN}✓ Completed${NC}\n"
42
-
43
- # Create typescript declaration files
44
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Generating TypeScript declaration files\n\n"
45
- npx tsc --rootDir "$IN_PATH" --declaration --emitDeclarationOnly --outDir "$OUT_PATH"
46
- printf "${GREEN}✓ Completed${NC}\n"
47
-
48
- # Create javascript ESM files with improved source maps
49
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Compiling TypeScript to ESM with source maps\n\n"
50
- if ! "$PROJECT_ROOT/node_modules/.bin/swc" "$IN_PATH" \
51
- --source-maps \
52
- --copy-files \
53
- --config-file "$TMP_SWCRC" \
54
- --out-dir "$OUT_PATH" \
55
- --strip-leading-paths \
56
- --log-watch-compilation \
57
- "$@"; then
58
- printf "${RED}✗ SWC compilation failed${NC}\n"
59
- exit 1
60
- fi
61
- printf "${GREEN}✓ Completed${NC}\n"
62
30
 
63
- # Create javascript CJS files
64
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Creating CommonJS bundle\n\n"
65
- if ! npx rollup "$OUT_PATH/index.js" --format cjs --file "$OUT_PATH/index.cjs" --silent; then
66
- printf "${RED}✗ Rollup bundling failed${NC}\n"
31
+ if ! npx rolldown --config "$CONFIG_PATH"; then
32
+ printf "${RED} Build failed${NC}\n"
67
33
  exit 1
68
34
  fi
69
- printf "${GREEN}✓ Completed${NC}\n"
70
35
 
71
- printf "\n${CYAN_BG}${BRIGHT_WHITE} END ${NC} Finalizing compilation process\n\n"
72
- printf "${GREEN}✓ Completed${NC}\n"
36
+ printf "\n${GREEN} Build completed${NC}\n"
package/bin/ts-dev.sh CHANGED
@@ -3,54 +3,33 @@
3
3
  # Exit on error
4
4
  set -e
5
5
 
6
- # Colors for output (using Vitest-like colors)
6
+ # Colors for output
7
7
  RED='\033[0;31m'
8
8
  GREEN='\033[0;32m'
9
- CYAN_BG='\033[46m' # Cyan background
10
- BRIGHT_WHITE='\033[1;30m' # Bold black text
11
- NC='\033[0m' # No Color
9
+ CYAN_BG='\033[46m'
10
+ BRIGHT_WHITE='\033[1;30m'
11
+ NC='\033[0m'
12
12
 
13
13
  # Get the directory where the script is being called from (caller's project root)
14
- # If called through bin, we need to get the directory where the command was executed
15
14
  if [ -n "$INIT_CWD" ]; then
16
15
  PROJECT_ROOT="$INIT_CWD"
17
16
  else
18
17
  PROJECT_ROOT=$(pwd)
19
18
  fi
20
19
 
21
- printf "${CYAN_BG}${BRIGHT_WHITE} START ${NC} Starting TypeScript watch mode\n\n"
20
+ # Get the directory where this script lives (inside @jterrazz/typescript)
21
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22
+ CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.dev.config.js"
22
23
 
23
- # Default paths relative to project root
24
- IN_PATH="$PROJECT_ROOT/src"
25
- OUT_PATH="$PROJECT_ROOT/dist"
24
+ printf "${CYAN_BG}${BRIGHT_WHITE} DEV ${NC} Starting watch mode...\n\n"
26
25
 
27
- printf "Input directory: %s\n" "$IN_PATH"
28
- printf "Output directory: %s\n" "$OUT_PATH"
26
+ printf "Project root: %s\n" "$PROJECT_ROOT"
27
+ printf "Config path: %s\n" "$CONFIG_PATH"
28
+ printf "Watching: %s/src\n\n" "$PROJECT_ROOT"
29
29
 
30
- # Convert tsconfig.json to .swcrc
31
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Converting tsconfig.json to .swcrc\n\n"
32
- TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
33
- if [ $? -ne 0 ]; then
34
- printf "${RED}✗ Error: Can't create temporary .swcrc file${NC}\n"
35
- exit 1
36
- fi
37
-
38
- # Ensure we're in the project root directory for TypeScript configuration
39
30
  cd "$PROJECT_ROOT"
40
- npx tsconfig-to-swcconfig --output="$TMP_SWCRC"
41
- printf "${GREEN}✓ Successfully converted tsconfig.json to .swcrc${NC}\n"
42
-
43
- printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} Starting watch mode with nodemon\n\n"
44
- printf "Watching for changes in: %s\n" "$IN_PATH"
45
31
 
46
- # Watch for changes in the src directory, compile and run
47
32
  npx nodemon --quiet \
48
- --watch "$IN_PATH" \
49
- --ext '*' \
50
- --exec "printf 'File change detected, rebuilding\\n' && npx swc $IN_PATH \
51
- --source-maps \
52
- --copy-files \
53
- --config-file $TMP_SWCRC \
54
- --out-dir $OUT_PATH \
55
- --strip-leading-paths \
56
- && printf '${GREEN}✓ Completed${NC}\\n\n' && node --enable-source-maps $OUT_PATH/index.js"
33
+ --watch src \
34
+ --ext 'ts,tsx,js,json' \
35
+ --exec "if OUTPUT=\$(npx 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"
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from 'rolldown';
2
+ import { dts } from 'rolldown-plugin-dts';
3
+
4
+ // ESM build with .d.ts generation
5
+ const esmBuild = defineConfig({
6
+ input: './src/index.ts',
7
+ plugins: [
8
+ dts({
9
+ // Use TypeScript Go for fastest .d.ts generation (experimental)
10
+ tsgo: true,
11
+ }),
12
+ ],
13
+ output: {
14
+ dir: 'dist',
15
+ format: 'esm',
16
+ sourcemap: true,
17
+ },
18
+ });
19
+
20
+ // CJS build (no dts - already generated by ESM build)
21
+ const cjsBuild = defineConfig({
22
+ input: './src/index.ts',
23
+ output: {
24
+ file: 'dist/index.cjs',
25
+ format: 'cjs',
26
+ sourcemap: true,
27
+ },
28
+ });
29
+
30
+ export default [esmBuild, cjsBuild];
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'rolldown';
2
+
3
+ // Dev build - ESM only, no .d.ts (faster rebuilds)
4
+ export default defineConfig({
5
+ input: './src/index.ts',
6
+ output: {
7
+ dir: 'dist',
8
+ format: 'esm',
9
+ sourcemap: true,
10
+ },
11
+ });
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@jterrazz/typescript",
3
3
  "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
4
- "version": "3.1.0",
4
+ "version": "4.0.0",
5
5
  "files": [
6
6
  "tsconfig",
7
- "bin"
7
+ "bin",
8
+ "config"
8
9
  ],
9
10
  "type": "module",
10
11
  "bin": {
@@ -20,26 +21,10 @@
20
21
  "@jterrazz/quality": "^5.0.1"
21
22
  },
22
23
  "dependencies": {
23
- "@swc/cli": "^0.7.9",
24
- "@swc/core": "1.15.3",
24
+ "@typescript/native-preview": "^7.0.0-dev.20250610.1",
25
25
  "nodemon": "3.1.11",
26
- "rollup": "4.53.3",
27
- "tsconfig-to-swcconfig": "2.8.1",
28
- "typescript": "5.9.3"
29
- },
30
- "optionalDependencies": {
31
- "@swc/core-linux-arm64-gnu": "1.15.3",
32
- "@swc/core-linux-x64-gnu": "1.15.3",
33
- "@swc/core-linux-x64-musl": "1.15.3",
34
- "@swc/core-darwin-x64": "1.15.3",
35
- "@swc/core-darwin-arm64": "1.15.3",
36
- "@swc/core-win32-x64-msvc": "1.15.3",
37
- "@rollup/rollup-linux-arm64-gnu": "4.53.3",
38
- "@rollup/rollup-linux-x64-gnu": "4.53.3",
39
- "@rollup/rollup-linux-x64-musl": "4.53.3",
40
- "@rollup/rollup-darwin-x64": "4.53.3",
41
- "@rollup/rollup-darwin-arm64": "4.53.3",
42
- "@rollup/rollup-win32-x64-msvc": "4.53.3"
26
+ "rolldown": "^1.0.0-beta.9",
27
+ "rolldown-plugin-dts": "^0.18.3"
43
28
  },
44
29
  "publishConfig": {
45
30
  "registry": "https://registry.npmjs.org/"