@jterrazz/typescript 1.9.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/LICENCE +1 -0
- package/README.md +39 -0
- package/bin/swc-compile.sh +20 -0
- package/bin/swc-watch.sh +14 -0
- package/package.json +30 -0
- package/tsconfig/expo.json +17 -0
- package/tsconfig/node-esm.json +16 -0
package/LICENCE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2O24 Jean-Baptiste Terrazzoni <jterrazzoni@gmail.com>. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Package Typescript
|
|
2
|
+
|
|
3
|
+
This package provides a consistent TypeScript configuration for projects. It includes two commands: `swc-compiler` and `swc-runner`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package globally or locally:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @jterrazz/package-typescript
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### TypeScript Configuration
|
|
16
|
+
|
|
17
|
+
Use the provided `tsconfig.json` in your project:
|
|
18
|
+
|
|
19
|
+
```json5
|
|
20
|
+
// tsconfig.json
|
|
21
|
+
{
|
|
22
|
+
extends: '@jterrazz/package-typescript/tsconfig/node-esm',
|
|
23
|
+
compilerOptions: {
|
|
24
|
+
// Your custom compiler options here
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Commands
|
|
30
|
+
|
|
31
|
+
- `swc-compiler`: Compile TypeScript files using SWC.
|
|
32
|
+
- `swc-runner`: Execute TypeScript files using SWC.
|
|
33
|
+
|
|
34
|
+
## Implementation Details
|
|
35
|
+
|
|
36
|
+
- The package reads directly from the `tsconfig.json` file, keeping the implementation details hidden.
|
|
37
|
+
- Consumers don't need to worry about the underlying scripts.
|
|
38
|
+
|
|
39
|
+
Happy coding!
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
IN_PATH=src
|
|
3
|
+
OUT_PATH=dist
|
|
4
|
+
|
|
5
|
+
# Convert tsconfig.json to .swcrc
|
|
6
|
+
TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
|
|
7
|
+
if [ $? -ne 0 ]; then
|
|
8
|
+
echo "$0: Can't create temporary .swcrc file"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
tsconfig-to-swcconfig --output="$TMP_SWCRC"
|
|
12
|
+
|
|
13
|
+
# Create typescript declaration files
|
|
14
|
+
tsc --declaration --emitDeclarationOnly --outDir "$OUT_PATH"
|
|
15
|
+
|
|
16
|
+
# Create javascript ESM files
|
|
17
|
+
swc "$IN_PATH" --source-maps --copy-files --config-file "$TMP_SWCRC" --out-dir "$OUT_PATH" --strip-leading-paths "$@"
|
|
18
|
+
|
|
19
|
+
# Create javascript CJS files
|
|
20
|
+
rollup $OUT_PATH/index.js --format cjs --name --file $OUT_PATH/index.cjs
|
package/bin/swc-watch.sh
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
IN_PATH=src
|
|
3
|
+
OUT_PATH=dist
|
|
4
|
+
|
|
5
|
+
# Convert tsconfig.json to .swcrc
|
|
6
|
+
TMP_SWCRC=$(mktemp -q /tmp/.swcrc.XXXXXX)
|
|
7
|
+
if [ $? -ne 0 ]; then
|
|
8
|
+
echo "$0: Can't create temporary .swcrc file"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
tsconfig-to-swcconfig --output="$TMP_SWCRC"
|
|
12
|
+
|
|
13
|
+
# Watch for changes in the src directory, compile and run
|
|
14
|
+
nodemon --quiet --watch src --ext '*' --exec "swc $IN_PATH --source-maps --quiet --copy-files --config-file $TMP_SWCRC --out-dir $OUT_PATH --strip-leading-paths && node --enable-source-maps $OUT_PATH/index.js"
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jterrazz/typescript",
|
|
3
|
+
"author": "Jean-Baptiste Terrazzoni <jterrazzoni@gmail.com>",
|
|
4
|
+
"version": "1.9.1",
|
|
5
|
+
"files": [
|
|
6
|
+
"tsconfig",
|
|
7
|
+
"bin"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"bin": {
|
|
11
|
+
"swc-compile": "bin/swc-compile.sh",
|
|
12
|
+
"swc-watch": "bin/swc-watch.sh"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@jterrazz/package-typescript-quality": "^1.5.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@swc/cli": "0.6.0",
|
|
20
|
+
"@swc/core": "1.11.8",
|
|
21
|
+
"@types/node": "22.13.10",
|
|
22
|
+
"nodemon": "3.1.9",
|
|
23
|
+
"rollup": "4.35.0",
|
|
24
|
+
"tsconfig-to-swcconfig": "2.8.1",
|
|
25
|
+
"typescript": "5.8.2"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"display": "Expo",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"jsx": "react-native",
|
|
8
|
+
"lib": ["DOM", "ESNext"],
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"target": "ESNext"
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"display": "ESM",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"types": ["node", "jest"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"skipLibCheck": true
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
|
|
16
|
+
}
|