unplugin-keywords 2.11.1 → 2.11.2

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.
Files changed (2) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,18 +13,18 @@
13
13
 
14
14
  A build plugin for structural string literal minification and obfuscation.
15
15
 
16
- `unplugin-keywords` addresses a fundamental limitation in JavaScript minification: the inability to safely mangle string literals used as object keys, custom event types, or structural constants. By explicitly importing these identifiers from a virtual module, the plugin extracts them at the AST level and maps them to deterministic, short hashes during the build process. This explicit opt-in mechanism empowers bundlers to inline and obfuscate application internals without breaking semantic contracts.
16
+ `unplugin-keywords` addresses a fundamental limitation in JavaScript minification: the inability to safely mangle string literals used as object keys, custom event types, or structural constants. By explicitly importing these identifiers from a virtual module, the plugin extracts them at the AST level and maps them to deterministic, short hashes during the build process. This explicit opt-in mechanism allows bundlers to inline and obfuscate application internals without breaking semantic contracts.
17
17
 
18
18
  ## Motivation vs. Property Mangling
19
19
 
20
20
  Traditional JavaScript minifiers rely on property mangling (e.g., Terser's `mangle.properties`) to reduce structural identifiers. `unplugin-keywords` provides a module-based alternative that addresses the structural limitations of global mangling.
21
21
 
22
22
  - **Explicit Opt-In:**
23
- Traditional property mangling requires maintaining complex, global exclusion rules (e.g., [`mangle.json`](https://github.com/preactjs/signals/blob/main/mangle.json)), which are fragile and hard to scale. `unplugin-keywords` utilizes explicit imports (`import * as K from '~keywords'`). Developers unambiguously declare which identifiers are safe to obfuscate directly in the source code.
23
+ Traditional property mangling requires maintaining complex, global exclusion rules (e.g., [`mangle.json`](https://github.com/preactjs/signals/blob/main/mangle.json)), which are fragile and hard to scale. `unplugin-keywords` utilizes explicit imports (`import * as K from '~keywords'`). Developers clearly state which identifiers are safe to obfuscate directly in the source code.
24
24
  - **Gradual Adoption:**
25
25
  Unlike global mangling flags that affect the entire codebase simultaneously, installing this plugin alters nothing by default. It allows incremental adoption on a per-file or per-module basis.
26
26
  - **Cross-Boundary Consistency:**
27
- Standard mangled properties cannot safely cross package boundaries; a property mangled to `a` in Package A will not map to `a` in Package B. Because `~keywords/public` relies on deterministic hashing, identical keys inherently produce identical hashes across independent builds, preserving structural contracts.
27
+ Standard mangled properties cannot safely cross package boundaries; a property mangled to `a` in Package A will not map to `a` in Package B. Because `~keywords/public` relies on deterministic hashing, identical keys always produce the same hashes across independent builds, preserving structural contracts.
28
28
  - **Universal Application:**
29
29
  Standard minifiers only mangle object keys, leaving string literal values intact. This plugin processes both keys and values uniformly (e.g., `[K.type]: K.SET_USER`). It extends obfuscation to literal types (`const mode: typeof K.extract | typeof K.transform = K.extract`) and even arbitrary static strings (`throw new Error(K['Invalid State'])`).
30
30
  - **Trade-offs:**
@@ -53,7 +53,7 @@ Standard minifiers operate exclusively on variable bindings and function names,
53
53
  `unplugin-keywords` solves this by treating structural strings as imported module bindings.
54
54
 
55
55
  **1. Source Code (Development):**
56
- Developers reference strings via a virtual module. The strongly recommended pattern is to use a namespace import (`import * as K`), which clearly demarcates keyword usage throughout the file.
56
+ Developers reference strings via a virtual module. The strongly recommended pattern is to use a namespace import (`import * as K`), which clearly marks keyword usage throughout the file.
57
57
 
58
58
  ```ts
59
59
  import * as K from '~keywords';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-keywords",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "A build plugin for structural string literal minification and obfuscation.",
5
5
  "keywords": [
6
6
  "unplugin",