@jterrazz/typescript 2.0.0 → 2.0.2

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/bin/ts-compile.sh CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
+ # Exit on error
4
+ set -e
5
+
3
6
  # Get the directory where the script is being called from (caller's project root)
4
7
  # If called through bin, we need to get the directory where the command was executed
5
8
  if [ -n "$INIT_CWD" ]; then
@@ -8,33 +11,54 @@ else
8
11
  PROJECT_ROOT=$(pwd)
9
12
  fi
10
13
 
14
+ echo "🚀 Starting TypeScript compilation process..."
15
+
11
16
  # Default paths relative to project root
12
17
  IN_PATH="$PROJECT_ROOT/src"
13
18
  OUT_PATH="$PROJECT_ROOT/dist"
14
19
 
20
+ echo "📂 Input directory: $IN_PATH"
21
+ echo "📂 Output directory: $OUT_PATH"
22
+
15
23
  # Convert tsconfig.json to .swcrc
24
+ echo "🔄 Converting tsconfig.json to .swcrc..."
16
25
  TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
17
26
  if [ $? -ne 0 ]; then
18
- echo "$0: Can't create temporary .swcrc file"
27
+ echo "❌ Error: Can't create temporary .swcrc file"
19
28
  exit 1
20
29
  fi
21
30
 
22
31
  # Ensure we're in the project root directory for TypeScript configuration
23
32
  cd "$PROJECT_ROOT"
24
33
  npx tsconfig-to-swcconfig --output="$TMP_SWCRC"
34
+ echo "✅ Successfully converted tsconfig.json to .swcrc"
25
35
 
26
36
  # Create typescript declaration files
37
+ echo "📝 Generating TypeScript declaration files..."
27
38
  npx tsc --rootDir "$IN_PATH" --declaration --emitDeclarationOnly --outDir "$OUT_PATH"
39
+ echo "✅ TypeScript declaration files generated"
28
40
 
29
41
  # Create javascript ESM files with improved source maps
30
- npx swc "$IN_PATH" \
42
+ echo "⚙️ Compiling TypeScript to ESM with source maps..."
43
+ if ! npx @swc/cli "$IN_PATH" \
31
44
  --source-maps \
32
45
  --copy-files \
33
46
  --config-file "$TMP_SWCRC" \
34
47
  --out-dir "$OUT_PATH" \
35
48
  --strip-leading-paths \
36
49
  --log-watch-compilation \
37
- "$@"
50
+ "$@"; then
51
+ echo "❌ SWC compilation failed"
52
+ exit 1
53
+ fi
54
+ echo "✅ ESM compilation completed"
38
55
 
39
56
  # Create javascript CJS files
40
- npx rollup "$OUT_PATH/index.js" --format cjs --file "$OUT_PATH/index.cjs"
57
+ echo "🔄 Creating CommonJS bundle..."
58
+ if ! npx rollup "$OUT_PATH/index.js" --format cjs --file "$OUT_PATH/index.cjs"; then
59
+ echo "❌ Rollup bundling failed"
60
+ exit 1
61
+ fi
62
+ echo "✅ CommonJS bundle created"
63
+
64
+ echo "✨ Compilation process completed successfully!"
package/bin/ts-watch.sh CHANGED
@@ -8,29 +8,40 @@ else
8
8
  PROJECT_ROOT=$(pwd)
9
9
  fi
10
10
 
11
+ echo "👀 Starting TypeScript watch mode..."
12
+
11
13
  # Default paths relative to project root
12
14
  IN_PATH="$PROJECT_ROOT/src"
13
15
  OUT_PATH="$PROJECT_ROOT/dist"
14
16
 
17
+ echo "📂 Input directory: $IN_PATH"
18
+ echo "📂 Output directory: $OUT_PATH"
19
+
15
20
  # Convert tsconfig.json to .swcrc
21
+ echo "🔄 Converting tsconfig.json to .swcrc..."
16
22
  TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
17
23
  if [ $? -ne 0 ]; then
18
- echo "$0: Can't create temporary .swcrc file"
24
+ echo "❌ Error: Can't create temporary .swcrc file"
19
25
  exit 1
20
26
  fi
21
27
 
22
28
  # Ensure we're in the project root directory for TypeScript configuration
23
29
  cd "$PROJECT_ROOT"
24
30
  npx tsconfig-to-swcconfig --output="$TMP_SWCRC"
31
+ echo "✅ Successfully converted tsconfig.json to .swcrc"
32
+
33
+ echo "⚙️ Starting watch mode with nodemon..."
34
+ echo "📝 Watching for changes in: $IN_PATH"
35
+ echo "🚀 Changes will trigger automatic recompilation and execution"
25
36
 
26
37
  # Watch for changes in the src directory, compile and run
27
38
  npx nodemon --quiet \
28
39
  --watch "$IN_PATH" \
29
40
  --ext '*' \
30
- --exec "npx swc $IN_PATH \
41
+ --exec "echo '🔄 File change detected, recompiling...' && npx swc $IN_PATH \
31
42
  --source-maps \
32
43
  --copy-files \
33
44
  --config-file $TMP_SWCRC \
34
45
  --out-dir $OUT_PATH \
35
46
  --strip-leading-paths \
36
- && node --enable-source-maps $OUT_PATH/index.js"
47
+ && echo '✅ Compilation successful, running...' && node --enable-source-maps $OUT_PATH/index.js"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jterrazz/typescript",
3
- "author": "Jean-Baptiste Terrazzoni <jterrazzoni@gmail.com>",
4
- "version": "2.0.0",
3
+ "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
4
+ "version": "2.0.2",
5
5
  "files": [
6
6
  "tsconfig",
7
7
  "bin"
@@ -16,14 +16,21 @@
16
16
  "@jterrazz/quality": "^1.6.1"
17
17
  },
18
18
  "dependencies": {
19
- "@swc/cli": "0.6.0",
20
- "@swc/core": "1.11.8",
19
+ "@swc/cli": "^0.6.0",
20
+ "@swc/core": "1.11.13",
21
21
  "@types/node": "22.13.10",
22
22
  "nodemon": "3.1.9",
23
23
  "rollup": "4.35.0",
24
24
  "tsconfig-to-swcconfig": "2.8.1",
25
25
  "typescript": "5.8.2"
26
26
  },
27
+ "optionalDependencies": {
28
+ "@swc/core-linux-x64-gnu": "1.11.13",
29
+ "@swc/core-linux-x64-musl": "1.11.13",
30
+ "@swc/core-darwin-x64": "1.11.13",
31
+ "@swc/core-darwin-arm64": "1.11.13",
32
+ "@swc/core-win32-x64-msvc": "1.11.13"
33
+ },
27
34
  "publishConfig": {
28
35
  "registry": "https://registry.npmjs.org/"
29
36
  }