vite-plugin-keywords 1.0.0 → 1.0.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 +51 -51
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
> [!NOTE]
|
|
15
15
|
> A Rollup version of this plugin, `rollup-plugin-keywords`, is also available. The primary difference is that the Vite plugin utilizes the `hotUpdate` hook to incrementally collect keywords and update modules and types during development. While this documentation is written primarily for the Vite plugin, the setup is almost identical—just add `rollup-plugin-keywords` to your Rollup configuration.
|
|
16
16
|
|
|
17
|
-
A Vite plugin that provides a way to use minifiable `Symbols` (keywords) in place of string literals and object keys, offering a potential strategy for aggressive minification.
|
|
17
|
+
A Vite plugin that provides a way to use minifiable `Symbols` (keywords) in place of string literals and object keys, offering a potential strategy for aggressive minification/obfuscation.
|
|
18
18
|
|
|
19
|
-
This approach introduces a trade-off between a small reduction in bundle size and an increase in code complexity. It is best suited for ~~applications where every byte counts~~ minification nerds.
|
|
19
|
+
This approach introduces a trade-off between a small reduction in bundle size and an increase in code complexity. It is best suited for ~~applications where every byte counts~~ minification/obfuscation nerds.
|
|
20
20
|
|
|
21
21
|
## Rationale
|
|
22
22
|
|
|
@@ -130,55 +130,55 @@ pnpm add -D vite-plugin-keywords
|
|
|
130
130
|
|
|
131
131
|
## Setup
|
|
132
132
|
|
|
133
|
-
1.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
2.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
3.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
4.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
5.
|
|
133
|
+
1. Add the plugin to your `vite.config.ts`.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
// vite.config.ts
|
|
137
|
+
import { defineConfig } from 'vite';
|
|
138
|
+
import keywords from 'vite-plugin-keywords';
|
|
139
|
+
|
|
140
|
+
export default defineConfig({
|
|
141
|
+
plugins: [keywords()],
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
2. Include the generated types file in your `tsconfig.json` or `src/env.d.ts`.
|
|
146
|
+
|
|
147
|
+
```jsonc
|
|
148
|
+
// tsconfig.json
|
|
149
|
+
{
|
|
150
|
+
// ...
|
|
151
|
+
"include": [
|
|
152
|
+
"src",
|
|
153
|
+
".keywords/types.d.ts", // Add this line
|
|
154
|
+
],
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// src/env.d.ts
|
|
160
|
+
/// <reference path="../.keywords/types.d.ts" />
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
3. Exclude the generated types file from your version control system (e.g., Git).
|
|
164
|
+
|
|
165
|
+
```gitignore
|
|
166
|
+
# .gitignore
|
|
167
|
+
.keywords/
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
4. Ensure that your type-checking script in `package.json` is updated to run the plugin first:
|
|
171
|
+
|
|
172
|
+
```jsonc
|
|
173
|
+
// package.json
|
|
174
|
+
{
|
|
175
|
+
"scripts": {
|
|
176
|
+
"typecheck": "keywords && tsc --noEmit",
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
5. The `.keywords/types.d.ts` type file is created automatically on `vite dev/build`, or manually via the `keywords` script.
|
|
182
182
|
|
|
183
183
|
## Options
|
|
184
184
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-keywords",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A Vite plugin that provides minifiable Symbols (keywords) to use in place of string literals for aggressive minification.",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A Vite plugin that provides minifiable Symbols (keywords) to use in place of string literals for aggressive minification/obfuscation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
7
7
|
"vite-plugin",
|
|
8
|
-
"minification"
|
|
8
|
+
"minification",
|
|
9
|
+
"obfuscation"
|
|
9
10
|
],
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"dist"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"minifiable-keywords": "1.0.
|
|
40
|
+
"minifiable-keywords": "1.0.1"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/node": "^24.1.0",
|