@jterrazz/typescript 4.1.0 → 4.2.1
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 +7 -4
- package/bin/ts-build.sh +22 -2
- package/config/rolldown.build.config.js +4 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -24,8 +24,9 @@ npm install @jterrazz/typescript
|
|
|
24
24
|
### 2. Use the build commands
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npx ts-dev
|
|
28
|
-
npx ts-build
|
|
27
|
+
npx ts-dev # Development with watch mode
|
|
28
|
+
npx ts-build --app # Production build (ESM + types)
|
|
29
|
+
npx ts-build --lib # Library build (ESM + CJS + types)
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
## What you get
|
|
@@ -40,11 +41,13 @@ npx ts-build # Production build
|
|
|
40
41
|
| Mode | Output | Description |
|
|
41
42
|
|------|--------|-------------|
|
|
42
43
|
| `ts-dev` | `dist/index.js` | ESM only, fast rebuilds (~20ms) |
|
|
43
|
-
| `ts-build` | `dist/index.js` | ESM bundle |
|
|
44
|
+
| `ts-build --app` | `dist/index.js` | ESM bundle |
|
|
45
|
+
| | `dist/index.d.ts` | TypeScript declarations |
|
|
46
|
+
| `ts-build --lib` | `dist/index.js` | ESM bundle |
|
|
44
47
|
| | `dist/index.cjs` | CommonJS bundle |
|
|
45
48
|
| | `dist/index.d.ts` | TypeScript declarations |
|
|
46
49
|
|
|
47
|
-
If `src/instrumentation.ts` exists, it will also generate
|
|
50
|
+
If `src/instrumentation.ts` exists, it will also generate corresponding `instrumentation.*` files.
|
|
48
51
|
|
|
49
52
|
## Project structure
|
|
50
53
|
|
package/bin/ts-build.sh
CHANGED
|
@@ -10,6 +10,26 @@ CYAN_BG='\033[46m'
|
|
|
10
10
|
BRIGHT_WHITE='\033[1;30m'
|
|
11
11
|
NC='\033[0m'
|
|
12
12
|
|
|
13
|
+
# Parse arguments (required: --app or --lib)
|
|
14
|
+
BUILD_MODE=""
|
|
15
|
+
for arg in "$@"; do
|
|
16
|
+
case $arg in
|
|
17
|
+
--lib)
|
|
18
|
+
BUILD_MODE="lib"
|
|
19
|
+
;;
|
|
20
|
+
--app)
|
|
21
|
+
BUILD_MODE="app"
|
|
22
|
+
;;
|
|
23
|
+
esac
|
|
24
|
+
done
|
|
25
|
+
|
|
26
|
+
if [ -z "$BUILD_MODE" ]; then
|
|
27
|
+
printf "${RED}Error: Build mode required. Use --app or --lib${NC}\n\n"
|
|
28
|
+
printf " --app Build for applications (ESM + types)\n"
|
|
29
|
+
printf " --lib Build for libraries (ESM + CJS + types)\n"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
13
33
|
# Get the directory where the script is being called from (caller's project root)
|
|
14
34
|
if [ -n "$INIT_CWD" ]; then
|
|
15
35
|
PROJECT_ROOT="$INIT_CWD"
|
|
@@ -27,14 +47,14 @@ done
|
|
|
27
47
|
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
|
|
28
48
|
CONFIG_PATH="$SCRIPT_DIR/../config/rolldown.build.config.js"
|
|
29
49
|
|
|
30
|
-
printf "${CYAN_BG}${BRIGHT_WHITE} BUILD ${NC} Building with Rolldown...\n\n"
|
|
50
|
+
printf "${CYAN_BG}${BRIGHT_WHITE} BUILD ${NC} Building with Rolldown (${BUILD_MODE} mode)...\n\n"
|
|
31
51
|
|
|
32
52
|
printf "Project root: %s\n" "$PROJECT_ROOT"
|
|
33
53
|
printf "Config path: %s\n\n" "$CONFIG_PATH"
|
|
34
54
|
|
|
35
55
|
cd "$PROJECT_ROOT"
|
|
36
56
|
|
|
37
|
-
if ! npx rolldown --config "$CONFIG_PATH"; then
|
|
57
|
+
if ! BUILD_MODE="$BUILD_MODE" npx rolldown --config "$CONFIG_PATH"; then
|
|
38
58
|
printf "${RED}✗ Build failed${NC}\n"
|
|
39
59
|
exit 1
|
|
40
60
|
fi
|
|
@@ -2,6 +2,9 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { defineConfig } from 'rolldown';
|
|
3
3
|
import { dts } from 'rolldown-plugin-dts';
|
|
4
4
|
|
|
5
|
+
// Build mode: 'lib' = ESM + CJS + types, 'app' = ESM + types only
|
|
6
|
+
const isLibrary = process.env.BUILD_MODE === 'lib';
|
|
7
|
+
|
|
5
8
|
// Externalize all dependencies (node built-ins + node_modules)
|
|
6
9
|
const external = [/node_modules/, /^node:/, /^[a-z@]/];
|
|
7
10
|
|
|
@@ -40,4 +43,4 @@ const cjsBuild = defineConfig({
|
|
|
40
43
|
},
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
export default [esmBuild, cjsBuild];
|
|
46
|
+
export default isLibrary ? [esmBuild, cjsBuild] : [esmBuild];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jterrazz/typescript",
|
|
3
3
|
"author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
|
|
4
|
-
"version": "4.1
|
|
4
|
+
"version": "4.2.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"tsconfig",
|
|
7
7
|
"bin",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@jterrazz/quality": "^5.0.1"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
24
|
+
"@typescript/native-preview": "^7.0.0-dev.20251231.1",
|
|
25
25
|
"nodemon": "3.1.11",
|
|
26
|
-
"rolldown": "^1.0.0-beta.
|
|
27
|
-
"rolldown-plugin-dts": "^0.
|
|
26
|
+
"rolldown": "^1.0.0-beta.58",
|
|
27
|
+
"rolldown-plugin-dts": "^0.20.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|