@ttsc/strip 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 CHANGED
@@ -9,30 +9,15 @@
9
9
  [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://github.com/samchon/ttsc/tree/master/docs)
10
10
  [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
11
 
12
- `@ttsc/strip` removes configured call-expression statements and debugger statements from TypeScript source before emit.
12
+ `@ttsc/strip` removes configured debug calls and `debugger` statements from TypeScript source AST before emit.
13
13
 
14
14
  ## Setup
15
15
 
16
- Install `ttsc`, TypeScript-Go, and the strip plugin:
16
+ Install `ttsc` and TypeScript-Go, then the strip plugin:
17
17
 
18
18
  ```bash
19
- npm install -D ttsc @typescript/native-preview @ttsc/strip
20
- ```
21
-
22
- Open your project's `tsconfig.json`, then add this entry under `compilerOptions.plugins`. If the file already has `compilerOptions`, merge this into the existing object:
23
-
24
- ```jsonc
25
- {
26
- "compilerOptions": {
27
- "plugins": [
28
- {
29
- "transform": "@ttsc/strip",
30
- "calls": ["console.log", "console.debug", "assert.*"],
31
- "statements": ["debugger"],
32
- },
33
- ],
34
- },
35
- }
19
+ npm install -D ttsc @typescript/native-preview
20
+ npm install -D @ttsc/strip
36
21
  ```
37
22
 
38
23
  Run your normal `ttsc` command:
@@ -41,22 +26,29 @@ Run your normal `ttsc` command:
41
26
  npx ttsc
42
27
  ```
43
28
 
29
+ With no extra config, `@ttsc/strip` removes `console.log`, `console.debug`, `assert.*`, and `debugger`.
30
+
44
31
  Only the configured patterns are removed. `@ttsc/strip` is not a minifier, tree-shaker, or dead-code-elimination pass.
45
32
 
46
- ## Notes
33
+ ## Configuration
34
+
35
+ Default behavior removes these statement patterns:
36
+
37
+ ```json
38
+ {
39
+ "calls": ["console.log", "console.debug", "assert.*"],
40
+ "statements": ["debugger"]
41
+ }
42
+ ```
47
43
 
48
44
  Call patterns match statement-level calls such as `console.log("debug")` or `assert.equal(left, right)`. A wildcard is supported at the end of a dotted call pattern, such as `assert.*`.
49
45
 
46
+ Add a direct plugin config only when the project needs a different strip list:
47
+
50
48
  ```jsonc
51
49
  {
52
50
  "compilerOptions": {
53
51
  "plugins": [
54
- // Keep lint first.
55
- { "transform": "@ttsc/lint", "config": { "no-var": "error" } },
56
-
57
- // First-party utilities use their documented transform order.
58
- { "transform": "@ttsc/banner", "banner": "License MIT" },
59
- { "transform": "@ttsc/paths" },
60
52
  {
61
53
  "transform": "@ttsc/strip",
62
54
  "calls": ["console.log", "console.debug", "assert.*"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/strip",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "First-party ttsc plugin that removes configured calls and statements from emitted JavaScript.",
5
5
  "main": "src/index.cjs",
6
6
  "exports": {
@@ -14,11 +14,17 @@
14
14
  "typescript",
15
15
  "tsgo"
16
16
  ],
17
+ "ttsc": {
18
+ "plugin": {
19
+ "transform": "@ttsc/strip"
20
+ }
21
+ },
17
22
  "files": [
18
23
  "README.md",
19
24
  "src/index.cjs",
20
25
  "go.mod",
21
- "plugin"
26
+ "plugin/main.go",
27
+ "plugin/strip.go"
22
28
  ],
23
29
  "repository": {
24
30
  "type": "git",
package/plugin/main.go CHANGED
@@ -28,7 +28,7 @@ func run(args []string) int {
28
28
  case "transform":
29
29
  return utility.RunTransform(args[1:])
30
30
  case "check":
31
- return 0
31
+ return utility.RunCheck(args[1:])
32
32
  default:
33
33
  fmt.Fprintf(os.Stderr, "@ttsc/strip: unknown command %q\n", args[0])
34
34
  return 2