svelte-shaker 0.5.1 → 0.5.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 +38 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -101,13 +101,51 @@ shaker({
101
101
  include: ['src'], // dirs (relative to root) holding every .svelte call site
102
102
  level: 1, // 0 | 1 | 2 — default 1 (L0/L1/L1.5 always on). 2 = opt-in L2.
103
103
  monomorphize: false, // L2 tuning; only consulted when level: 2.
104
+ parser: 'svelte', // 'svelte' (default) | 'rsvelte' — see below.
104
105
  });
105
106
 
106
107
  // Opt into L2 per-call-site monomorphization:
107
108
  shaker({ include: ['src'], level: 2, monomorphize: true });
108
109
  shaker({ include: ['src'], level: 2, monomorphize: { maxVariants: 16 } });
110
+
111
+ // Opt into the faster rsvelte parser (~1.46x full build, ~2.2x parse).
112
+ // Requires the optional peer `@rsvelte/vite-plugin-svelte-native` (install it
113
+ // yourself). Soundness is unchanged — it only affects speed and, occasionally,
114
+ // shakes a little more. If the native package can't load it THROWS (no silent
115
+ // fallback) so the output stays the same on every machine.
116
+ shaker({ include: ['src'], parser: 'rsvelte' });
117
+ ```
118
+
119
+ ### The rsvelte (Rust) parser
120
+
121
+ By default the engine parses with `svelte/compiler`. Setting `parser: 'rsvelte'`
122
+ swaps in [rsvelte](https://github.com/rsvelte/rsvelte)'s native (Rust) parser,
123
+ which dominates the shake pipeline (~85% of the time is parsing): on a real
124
+ 474-component app the full build runs **~1.46x faster** (parse alone ~2.2x).
125
+
126
+ ```sh
127
+ # rsvelte's native parser is an OPTIONAL peer — install it to opt in:
128
+ pnpm add -D @rsvelte/vite-plugin-svelte-native
109
129
  ```
110
130
 
131
+ ```ts
132
+ // vite.config.ts
133
+ shaker({ include: ['src'], parser: 'rsvelte' });
134
+ ```
135
+
136
+ - **Soundness is parser-independent.** The engine reads only UTF-16
137
+ `start`/`end` offsets, so the chosen parser never changes _what_ is folded —
138
+ only how fast. The few differences from the `svelte/compiler` path are cases
139
+ where rsvelte happens to shake a little _more_, each still behavior-preserving.
140
+ - **No silent fallback.** If `parser: 'rsvelte'` is requested but the native
141
+ package can't be loaded (not installed, or no prebuilt binary for the
142
+ platform), the plugin **throws** rather than quietly using `svelte/compiler` —
143
+ a silent fallback would make the same source shake differently depending on
144
+ whether the optional binary is present, breaking build reproducibility.
145
+
146
+ See [`docs/RUST-MIGRATION.md`](https://github.com/baseballyama/svelte-shaker/blob/main/docs/RUST-MIGRATION.md)
147
+ for the design.
148
+
111
149
  ## What it does
112
150
 
113
151
  | Level | What it removes | Default |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-shaker",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Tree shaking for Svelte components",
5
5
  "keywords": [
6
6
  "dead-code-elimination",