@ttsc/paths 0.8.1 → 0.9.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 +10 -31
- package/package.json +8 -2
- package/plugin/main.go +1 -1
package/README.md
CHANGED
|
@@ -9,30 +9,15 @@
|
|
|
9
9
|
[](https://github.com/samchon/ttsc/tree/master/docs)
|
|
10
10
|
[](https://discord.gg/E94XhzrUCZ)
|
|
11
11
|
|
|
12
|
-
`@ttsc/paths` rewrites
|
|
12
|
+
`@ttsc/paths` rewrites module specifiers that match `compilerOptions.paths` into relative JavaScript and declaration imports.
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
16
|
-
Install `ttsc
|
|
16
|
+
Install `ttsc` and TypeScript-Go, then the paths plugin:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install -D ttsc @typescript/native-preview
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Open your project's `tsconfig.json`, then configure `paths`, `rootDir`, `outDir`, and this plugin under `compilerOptions`. If the file already has `compilerOptions`, merge these fields into the existing object:
|
|
23
|
-
|
|
24
|
-
```jsonc
|
|
25
|
-
{
|
|
26
|
-
"compilerOptions": {
|
|
27
|
-
"paths": {
|
|
28
|
-
"@/*": ["./src/*"],
|
|
29
|
-
"@lib/*": ["./src/modules/*"],
|
|
30
|
-
},
|
|
31
|
-
"rootDir": "src",
|
|
32
|
-
"outDir": "dist",
|
|
33
|
-
"plugins": [{ "transform": "@ttsc/paths" }],
|
|
34
|
-
},
|
|
35
|
-
}
|
|
19
|
+
npm install -D ttsc @typescript/native-preview
|
|
20
|
+
npm install -D @ttsc/paths
|
|
36
21
|
```
|
|
37
22
|
|
|
38
23
|
Run your normal `ttsc` command:
|
|
@@ -41,33 +26,27 @@ Run your normal `ttsc` command:
|
|
|
41
26
|
npx ttsc
|
|
42
27
|
```
|
|
43
28
|
|
|
44
|
-
|
|
29
|
+
## Configuration
|
|
45
30
|
|
|
46
|
-
|
|
31
|
+
`@ttsc/paths` has no separate plugin options. It reads the same `compilerOptions.paths`, `rootDir`, and `outDir` values that `ttsc` uses for the project.
|
|
47
32
|
|
|
48
|
-
|
|
33
|
+
Configure those fields under `compilerOptions`:
|
|
49
34
|
|
|
50
35
|
```jsonc
|
|
51
36
|
{
|
|
52
37
|
"compilerOptions": {
|
|
53
38
|
"paths": {
|
|
39
|
+
"@/*": ["./src/*"],
|
|
54
40
|
"@lib/*": ["./src/modules/*"],
|
|
55
41
|
},
|
|
56
42
|
"rootDir": "src",
|
|
57
43
|
"outDir": "dist",
|
|
58
|
-
"plugins": [
|
|
59
|
-
// Keep lint first.
|
|
60
|
-
{ "transform": "@ttsc/lint", "config": { "no-var": "error" } },
|
|
61
|
-
|
|
62
|
-
// First-party utilities use their documented transform order.
|
|
63
|
-
{ "transform": "@ttsc/banner", "banner": "License MIT" },
|
|
64
|
-
{ "transform": "@ttsc/paths" },
|
|
65
|
-
{ "transform": "@ttsc/strip", "calls": ["console.log"] },
|
|
66
|
-
],
|
|
67
44
|
},
|
|
68
45
|
}
|
|
69
46
|
```
|
|
70
47
|
|
|
48
|
+
An import such as `import { value } from "@lib/value"` becomes a relative JavaScript import such as `import { value } from "./modules/value.js"`. Declaration output follows the same source rewrite.
|
|
49
|
+
|
|
71
50
|
## References
|
|
72
51
|
|
|
73
52
|
Inspired by [`typescript-transform-paths`](https://github.com/LeDDGroup/typescript-transform-paths).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/paths",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "First-party ttsc plugin that rewrites emitted module specifiers from tsconfig paths.",
|
|
5
5
|
"main": "src/index.cjs",
|
|
6
6
|
"exports": {
|
|
@@ -13,11 +13,17 @@
|
|
|
13
13
|
"typescript",
|
|
14
14
|
"tsgo"
|
|
15
15
|
],
|
|
16
|
+
"ttsc": {
|
|
17
|
+
"plugin": {
|
|
18
|
+
"transform": "@ttsc/paths"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
16
21
|
"files": [
|
|
17
22
|
"README.md",
|
|
18
23
|
"src/index.cjs",
|
|
19
24
|
"go.mod",
|
|
20
|
-
"plugin"
|
|
25
|
+
"plugin/main.go",
|
|
26
|
+
"plugin/paths.go"
|
|
21
27
|
],
|
|
22
28
|
"repository": {
|
|
23
29
|
"type": "git",
|
package/plugin/main.go
CHANGED