svelte-shaker 0.5.1 → 0.6.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 +38 -0
- package/dist/{types/src/analyze.d.ts → analyze.d.ts} +3 -3
- package/dist/analyze.js +1072 -0
- package/dist/{types/src/css.d.ts → css.d.ts} +2 -2
- package/dist/css.js +256 -0
- package/dist/{types/src/dead.d.ts → dead.d.ts} +2 -2
- package/dist/dead.js +195 -0
- package/dist/{types/src/engine.d.ts → engine.d.ts} +3 -3
- package/dist/engine.js +109 -0
- package/dist/{types/src/eval.d.ts → eval.d.ts} +2 -2
- package/dist/eval.js +222 -0
- package/dist/{types/src/index.d.ts → index.d.ts} +11 -11
- package/dist/index.js +86 -1
- package/dist/ir.js +15 -0
- package/dist/{types/src/mono.d.ts → mono.d.ts} +3 -3
- package/dist/mono.js +451 -0
- package/dist/parse.js +19 -0
- package/dist/{types/src/rsvelte-parse.d.ts → rsvelte-parse.d.ts} +1 -1
- package/dist/rsvelte-parse.js +31 -0
- package/dist/{types/src/scan.d.ts → scan.d.ts} +2 -2
- package/dist/scan.js +40 -1
- package/dist/{types/src/transform.d.ts → transform.d.ts} +4 -4
- package/dist/transform.js +825 -0
- package/dist/{types/src/vite.d.ts → vite.d.ts} +10 -2
- package/dist/vite.js +289 -1
- package/package.json +9 -18
- package/dist/index.cjs +0 -1
- /package/dist/{types/src/ir.d.ts → ir.d.ts} +0 -0
- /package/dist/{types/src/parse.d.ts → parse.d.ts} +0 -0
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 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AnyNode, type Parse, type ParseCache, type Root } from './parse';
|
|
2
|
-
import { type AnalyzeInput, type ComponentId, type ComponentPlan, type Literal } from './ir';
|
|
3
|
-
import { type Span } from './dead';
|
|
1
|
+
import { type AnyNode, type Parse, type ParseCache, type Root } from './parse.js';
|
|
2
|
+
import { type AnalyzeInput, type ComponentId, type ComponentPlan, type Literal } from './ir.js';
|
|
3
|
+
import { type Span } from './dead.js';
|
|
4
4
|
export type Resolve = (source: string, importer: ComponentId) => Promise<ComponentId | null> | ComponentId | null;
|
|
5
5
|
export type ReadFile = (id: ComponentId) => Promise<string> | string;
|
|
6
6
|
/** One declared prop in a `$props()` destructuring. */
|