@ogygia/data-shake 0.0.0 → 0.14.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Puru Vijayvargia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,17 @@
1
1
  # @ogygia/data-shake
2
2
 
3
- Placeholder that reserves this name for [ogygia](https://ogygiajs.dev). The first real release is 0.14.
3
+ Data shaking for [ogygia](https://ogygiajs.dev) apps: a page ships only the data its regions' code reads, the way tree shaking ships only the code a page uses.
4
+
5
+ ```ts
6
+ // vite.config.ts
7
+ import { ogygia } from 'ogygia/vite';
8
+ import { dataShake } from '@ogygia/data-shake/vite';
9
+
10
+ export default defineConfig({
11
+ plugins: [ogygia(), dataShake(), sveltekit()]
12
+ });
13
+ ```
14
+
15
+ Its first job is the page seed. An island that reads `page.data` through `$app/state` or `$app/stores` gets the page's data in its seed. Without this plugin that seed is all of `page.data`. With it, the build reads each module for the top-level `page.data` keys it can reach, and the page ships only the keys its islands read. A server hole whose code reads none skips the page look-up. `postrender()` requires it.
16
+
17
+ A read the analysis cannot pin to a literal key (`page.data` spread, passed whole to a function it cannot follow, indexed with a variable) gives that region all of `page.data`, as without the plugin. The build's seed report names the line. See the [API reference](https://ogygiajs.dev/docs/reference/api#datashake).
@@ -0,0 +1,61 @@
1
+ export type PageKeys = ReadonlySet<string> | "all";
2
+ /** `'all'` with its reason: which construct, at which line. */
3
+ export type AllReason = {
4
+ why: string;
5
+ line: number | null;
6
+ };
7
+ /**
8
+ * A call that hands the page to an IMPORTED helper: `getParams(page)`. The module alone cannot say
9
+ * what the helper reads; the build resolves the specifier, summarizes the helper's export
10
+ * ({@link summarize_export}) and folds the answer in — one level deep. A CMS app passed the page
11
+ * to one `url`-reading helper from 149 modules; following the call pins all of them.
12
+ */
13
+ export type PendingCall = {
14
+ specifier: string;
15
+ imported: string;
16
+ arg: number;
17
+ line: number | null;
18
+ };
19
+ export type PageKeysAnswer = {
20
+ keys: PageKeys | null;
21
+ reason: AllReason | null;
22
+ pending: PendingCall[];
23
+ };
24
+ /**
25
+ * The top-level `page.data` keys a module reads, or `'all'` when a read cannot be pinned to a
26
+ * literal key, or `null` when the module never imports the page (nothing to ship for it).
27
+ * `kind` picks the parser: `'svelte'` for a component source, `'script'` for `.ts` / `.js`.
28
+ */
29
+ export declare function page_data_keys(code: string, id: string, kind: "svelte" | "script"): PageKeys | null;
30
+ /** The same answer with the reason an `'all'` was given (for the build report). */
31
+ export declare function page_data_keys_answer(code: string, id: string, kind: "svelte" | "script"): PageKeysAnswer;
32
+ /**
33
+ * What an exported helper reads of a page handed to it as its `arg`-th parameter — the bundle-time
34
+ * half of following `helper(page)`. `'all'` when the export is not a plain function (a re-export,
35
+ * a class, a variable the analysis cannot follow), when the parameter is not a plain name, or when
36
+ * the helper itself hands the page on (one level only).
37
+ */
38
+ export type ExportSummary = PageKeys | {
39
+ follow: string[];
40
+ imported: string;
41
+ };
42
+ export declare function summarize_export(code: string, id: string, kind: "svelte" | "script", name: string, arg: number): ExportSummary;
43
+ /** Union two answers: `'all'` absorbs everything, `null` is the identity. */
44
+ export declare function merge_page_keys(a: PageKeys | null, b: PageKeys | null): PageKeys | null;
45
+ /** Does this module even mention a page-store specifier? (the transform's pre-filter) */
46
+ export declare function mentions_page_store(code: string): boolean;
47
+ export type PendingResolver = (specifier: string, importer: string) => Promise<{
48
+ id: string;
49
+ } | null | undefined>;
50
+ /**
51
+ * For every module with pending `helper(page)` calls: resolve each helper, summarize its export,
52
+ * fold the answer into the module's keys (`'all'` with a reason when the helper cannot be
53
+ * summarized). Runs once per build, before the closure union. `read` and `resolve` are the
54
+ * build's (fs + the bundler's resolver), threaded in so this stays testable.
55
+ */
56
+ export declare function follow_pending_page_calls(program: {
57
+ page_keys: Map<string, PageKeys>;
58
+ page_key_reasons: Map<string, AllReason>;
59
+ page_pending: Map<string, PendingCall[]>;
60
+ }, resolve: PendingResolver, read?: (file: string) => string | null): Promise<void>;
61
+ export declare function read_file_sync(file: string): string | null;
@@ -0,0 +1,761 @@
1
+ import fs from "node:fs";
2
+ import { parse_roots } from "@ogygia/compiler";
3
+ // src/analysis.ts
4
+ const PAGE_SPECIFIER_RE = /^\$app\/(?:state|stores)$/;
5
+ const SAFE_FIELDS = /* @__PURE__ */ new Set([
6
+ "url",
7
+ "params",
8
+ "route",
9
+ "status",
10
+ "error",
11
+ "form",
12
+ "state"
13
+ ]);
14
+ const SKIP_KEYS = /* @__PURE__ */ new Set([
15
+ "start",
16
+ "end",
17
+ "loc",
18
+ "range",
19
+ "parent",
20
+ "metadata",
21
+ "leadingComments",
22
+ "trailingComments"
23
+ ]);
24
+ const PAGE_SPECIFIER_HINT_RE = /\$app\/st(?:ate|ores)/;
25
+ const WHOLE_USE = /* @__PURE__ */ new Map([
26
+ ["VariableDeclarator", "`page.data` is aliased whole (`const d = page.data`)"],
27
+ ["SpreadElement", "`page.data` is spread"],
28
+ ["ReturnStatement", "`page.data` is returned whole"],
29
+ ["ArrowFunctionExpression", "`page.data` is returned whole"]
30
+ ]);
31
+ const FLIP_SIDE = {
32
+ server: "client",
33
+ client: "server"
34
+ };
35
+ var All = class extends Error {
36
+ why;
37
+ at;
38
+ constructor(why, at) {
39
+ super(why);
40
+ this.why = why;
41
+ this.at = at;
42
+ }
43
+ };
44
+ /**
45
+ * The top-level `page.data` keys a module reads, or `'all'` when a read cannot be pinned to a
46
+ * literal key, or `null` when the module never imports the page (nothing to ship for it).
47
+ * `kind` picks the parser: `'svelte'` for a component source, `'script'` for `.ts` / `.js`.
48
+ */
49
+ function page_data_keys(code, id, kind) {
50
+ return page_data_keys_answer(code, id, kind).keys;
51
+ }
52
+ /** The same answer with the reason an `'all'` was given (for the build report). */
53
+ function page_data_keys_answer(code, id, kind) {
54
+ if (!PAGE_SPECIFIER_HINT_RE.test(code)) return {
55
+ keys: null,
56
+ reason: null,
57
+ pending: []
58
+ };
59
+ const roots = parse_roots(code, id, kind);
60
+ if (!roots) return {
61
+ keys: "all",
62
+ reason: {
63
+ why: "the module did not parse here (the bundler will say why)",
64
+ line: null
65
+ },
66
+ pending: []
67
+ };
68
+ const scan = new Scan(code);
69
+ try {
70
+ for (const root of roots) scan.collect_bindings(root);
71
+ if (!scan.refs.size) return {
72
+ keys: null,
73
+ reason: null,
74
+ pending: []
75
+ };
76
+ let grew = true;
77
+ while (grew) grew = roots.map((root) => scan.grow(root)).some(Boolean);
78
+ for (const root of roots) scan.walk(root, null, null);
79
+ return {
80
+ keys: scan.keys,
81
+ reason: null,
82
+ pending: scan.pending
83
+ };
84
+ } catch (e) {
85
+ if (e instanceof All) return {
86
+ keys: "all",
87
+ reason: {
88
+ why: e.why,
89
+ line: e.at === null ? null : line_of(code, e.at)
90
+ },
91
+ pending: []
92
+ };
93
+ throw e;
94
+ }
95
+ }
96
+ function summarize_export(code, id, kind, name, arg) {
97
+ const roots = parse_roots(code, id, kind);
98
+ if (!roots) return "all";
99
+ let fn = null;
100
+ let named_follow = null;
101
+ const stars = [];
102
+ let imported = name;
103
+ let fn_name = null;
104
+ const local_fns = /* @__PURE__ */ new Map();
105
+ const imports = /* @__PURE__ */ new Map();
106
+ for (const root of roots) {
107
+ visit(root, (node) => {
108
+ if (node.type === "FunctionDeclaration" && node.id?.name && !enclosing_scope(node)) local_fns.set(node.id.name, node);
109
+ if (node.type === "VariableDeclarator" && node.id?.type === "Identifier" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression") && !enclosing_scope(node)) local_fns.set(node.id.name, node.init);
110
+ if (node.type === "ImportDeclaration") {
111
+ for (const s of node.specifiers ?? []) if (s.type === "ImportSpecifier") imports.set(s.local.name, {
112
+ specifier: String(node.source?.value ?? ""),
113
+ imported: spec_name(s.imported) ?? s.local.name
114
+ });
115
+ }
116
+ if (node.type === "ExportAllDeclaration" && node.source) stars.push(String(node.source.value));
117
+ if (node.type !== "ExportNamedDeclaration") return;
118
+ for (const s of node.specifiers ?? []) {
119
+ if (spec_name(s.exported) !== name) continue;
120
+ const local = spec_name(s.local) ?? name;
121
+ if (node.source) {
122
+ named_follow = String(node.source.value);
123
+ imported = local;
124
+ } else if (local_fns.has(local)) {
125
+ fn = local_fns.get(local);
126
+ fn_name = local;
127
+ } else if (imports.has(local)) {
128
+ named_follow = imports.get(local).specifier;
129
+ imported = imports.get(local).imported;
130
+ }
131
+ }
132
+ const d = node.declaration;
133
+ if (!d) return;
134
+ if (d.type === "FunctionDeclaration" && d.id?.name === name) {
135
+ fn = d;
136
+ fn_name = name;
137
+ }
138
+ if (d.type === "VariableDeclaration") {
139
+ for (const v of d.declarations ?? []) if (v.id?.type === "Identifier" && v.id.name === name && v.init && (v.init.type === "ArrowFunctionExpression" || v.init.type === "FunctionExpression")) {
140
+ fn = v.init;
141
+ fn_name = name;
142
+ }
143
+ }
144
+ });
145
+ if (fn) {
146
+ const rebound = fn_name;
147
+ if (rebound !== null && roots.some((r) => assigned_names(r).has(rebound))) return "all";
148
+ break;
149
+ }
150
+ }
151
+ if (!fn) {
152
+ if (named_follow) return {
153
+ follow: [named_follow],
154
+ imported
155
+ };
156
+ return stars.length ? {
157
+ follow: stars,
158
+ imported
159
+ } : "all";
160
+ }
161
+ const param = fn.params?.[arg];
162
+ if (!param || param.type !== "Identifier") return "all";
163
+ const scan = new Scan(code);
164
+ for (const [local, imp] of imports) scan.import_binding(local, imp.specifier, imp.imported);
165
+ try {
166
+ scan.seed_param(param.name, fn);
167
+ scan.grow(fn);
168
+ scan.walk(fn.params, fn, "params");
169
+ scan.walk(fn.body, fn, "body");
170
+ if (scan.pending.length) return "all";
171
+ return scan.keys;
172
+ } catch (e) {
173
+ if (e instanceof All) return "all";
174
+ throw e;
175
+ }
176
+ }
177
+ function line_of(code, offset) {
178
+ let line = 1;
179
+ for (let i = 0; i < offset && i < code.length; i++) if (code.charCodeAt(i) === 10) line++;
180
+ return line;
181
+ }
182
+ const WRAPPERS = /* @__PURE__ */ new Set([
183
+ "TSAsExpression",
184
+ "TSNonNullExpression",
185
+ "TSSatisfiesExpression",
186
+ "TSTypeAssertion",
187
+ "ParenthesizedExpression",
188
+ "ChainExpression"
189
+ ]);
190
+ function unwrap_up(node) {
191
+ let cur = node;
192
+ let parent = cur.__parent;
193
+ let key = cur.__key;
194
+ while (parent && WRAPPERS.has(parent.type) && key === "expression") {
195
+ cur = parent;
196
+ parent = cur.__parent;
197
+ key = cur.__key;
198
+ }
199
+ return {
200
+ node: cur,
201
+ parent,
202
+ key
203
+ };
204
+ }
205
+ /** Union two answers: `'all'` absorbs everything, `null` is the identity. */
206
+ function merge_page_keys(a, b) {
207
+ if (a === "all" || b === "all") return "all";
208
+ if (!a) return b;
209
+ if (!b) return a;
210
+ return /* @__PURE__ */ new Set([...a, ...b]);
211
+ }
212
+ /** Does this module even mention a page-store specifier? (the transform's pre-filter) */
213
+ function mentions_page_store(code) {
214
+ return PAGE_SPECIFIER_HINT_RE.test(code);
215
+ }
216
+ const SCOPE_TYPES = /* @__PURE__ */ new Set([
217
+ "FunctionDeclaration",
218
+ "FunctionExpression",
219
+ "ArrowFunctionExpression",
220
+ "ClassMethod",
221
+ "MethodDefinition",
222
+ "PropertyDefinition",
223
+ "Program",
224
+ "Fragment",
225
+ "Root"
226
+ ]);
227
+ var Scan = class {
228
+ refs = /* @__PURE__ */ new Set();
229
+ #scopes = /* @__PURE__ */ new Map();
230
+ keys = /* @__PURE__ */ new Set();
231
+ pending = [];
232
+ #imports = /* @__PURE__ */ new Map();
233
+ #store = /* @__PURE__ */ new Map();
234
+ #local_fns = /* @__PURE__ */ new Map();
235
+ #followed = /* @__PURE__ */ new Set();
236
+ #assigned = /* @__PURE__ */ new Set();
237
+ code;
238
+ constructor(code) {
239
+ this.code = code;
240
+ }
241
+ seed_param(name, fn) {
242
+ this.#add_ref(name, fn.body ?? fn);
243
+ this.#scopes.get(name).add(fn);
244
+ this.#followed.add(fn);
245
+ }
246
+ #add_ref(name, at) {
247
+ const scope = at ? enclosing_scope(at) : null;
248
+ let scopes = this.#scopes.get(name);
249
+ if (!scopes) this.#scopes.set(name, scopes = /* @__PURE__ */ new Set());
250
+ if (scopes.has(scope)) return false;
251
+ scopes.add(scope);
252
+ this.refs.add(name);
253
+ return true;
254
+ }
255
+ import_binding(local, specifier, imported) {
256
+ this.#imports.set(local, {
257
+ specifier,
258
+ imported
259
+ });
260
+ if (specifier === "svelte/store" && (imported === "get" || imported === "derived")) this.#store.set(local, imported);
261
+ }
262
+ #local_fn(callee) {
263
+ const fn = this.#local_fns.get(callee.name);
264
+ return fn && !declared_above(callee.name, callee, false) ? fn : void 0;
265
+ }
266
+ #store_helper(callee) {
267
+ const helper = this.#store.get(callee.name);
268
+ return helper && !declared_above(callee.name, callee, false) ? helper : void 0;
269
+ }
270
+ #in_followed(node) {
271
+ for (let n = node; n; n = n.__parent) if (this.#followed.has(n)) return true;
272
+ return false;
273
+ }
274
+ #in_scope(name, use) {
275
+ const scopes = this.#scopes.get(name);
276
+ if (!scopes) return false;
277
+ if (scopes.has(null)) return true;
278
+ for (let n = use; n; n = n.__parent) if (scopes.has(n)) return true;
279
+ return false;
280
+ }
281
+ collect_bindings(root) {
282
+ visit(root, (node) => {
283
+ if (node.type === "FunctionDeclaration" && node.id?.name && !enclosing_scope(node)) this.#local_fns.set(node.id.name, node);
284
+ if (node.type === "VariableDeclarator" && node.id?.type === "Identifier" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression") && !enclosing_scope(node)) this.#local_fns.set(node.id.name, node.init);
285
+ if ((node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.specifiers?.some((s) => spec_name(s.local) === "page")) && PAGE_SPECIFIER_RE.test(String(node.source?.value ?? ""))) throw new All("the page store is re-exported", node.start ?? null);
286
+ if (node.type === "ImportExpression" && PAGE_SPECIFIER_RE.test(static_string(node.source) ?? "")) throw new All("the page store is imported with `import()`", node.start ?? null);
287
+ if (node.type !== "ImportDeclaration") return;
288
+ const specifier = String(node.source?.value ?? "");
289
+ for (const s of node.specifiers ?? []) if (s.type === "ImportSpecifier") this.import_binding(s.local.name, specifier, spec_name(s.imported) ?? s.local.name);
290
+ else if (s.type === "ImportDefaultSpecifier") this.import_binding(s.local.name, specifier, "default");
291
+ if (!PAGE_SPECIFIER_RE.test(specifier)) return;
292
+ for (const s of node.specifiers ?? []) {
293
+ if (s.type === "ImportNamespaceSpecifier" || s.type === "ImportDefaultSpecifier") throw new All("the page store is imported as a namespace", s.start ?? null);
294
+ if (s.type === "ImportSpecifier" && spec_name(s.imported) === "getStores") throw new All("the page store is taken from `getStores()`", s.start ?? null);
295
+ if (s.type === "ImportSpecifier" && spec_name(s.imported) === "page") this.#add_ref(s.local.name, null);
296
+ }
297
+ });
298
+ for (const name of assigned_names(root)) this.#assigned.add(name);
299
+ for (const name of this.#assigned) this.#local_fns.delete(name);
300
+ }
301
+ grow(root) {
302
+ let any = false;
303
+ let grew = true;
304
+ while (grew) {
305
+ grew = false;
306
+ visit(root, (node) => {
307
+ if (node.type === "VariableDeclarator" && node.init && this.is_page_value(unwrap_down(node.init))) {
308
+ if (node.id?.type === "Identifier") {
309
+ if (this.#add_ref(node.id.name, node)) grew = true;
310
+ } else throw new All("the page is destructured (`const { data } = page`)", node.start ?? null);
311
+ }
312
+ if (node.type === "CallExpression") {
313
+ const callee = node.callee;
314
+ const args = node.arguments ?? [];
315
+ const local = callee?.type === "Identifier" ? this.#local_fn(callee) : void 0;
316
+ if (local) {
317
+ const fn = local;
318
+ args.forEach((a, i) => {
319
+ if (!this.is_page_value(a)) return;
320
+ const p = fn.params?.[i];
321
+ if (p?.type === "Identifier") {
322
+ if (this.#add_ref(p.name, fn.body ?? fn)) grew = true;
323
+ this.#scopes.get(p.name).add(fn);
324
+ this.#followed.add(fn);
325
+ }
326
+ });
327
+ }
328
+ if (callee?.type === "MemberExpression" && !callee.computed && callee.property?.name === "subscribe" && this.is_page_value(callee.object)) {
329
+ const fn = args[0];
330
+ const p = fn?.params?.[0];
331
+ if (fn && p?.type === "Identifier" && this.#add_ref(p.name, fn.body ?? fn)) {
332
+ this.#scopes.get(p.name).add(fn);
333
+ grew = true;
334
+ }
335
+ }
336
+ if (callee?.type === "Identifier" && this.#store_helper(callee) === "derived" && args.length >= 2) {
337
+ const fn = args[1];
338
+ const param = fn?.params?.[0];
339
+ if (args[0]?.type === "Identifier" && this.is_page_value(args[0])) {
340
+ if (param?.type === "Identifier") {
341
+ if (this.#add_ref(param.name, fn)) grew = true;
342
+ } else if (param) throw new All("a derived() over the page destructures its parameter", param.start ?? null);
343
+ } else if (args[0]?.type === "ArrayExpression") args[0].elements.forEach((el, i) => {
344
+ if (el?.type !== "Identifier" || !this.is_page_value(el)) return;
345
+ const p = param?.type === "ArrayPattern" ? param.elements[i] : null;
346
+ if (p?.type === "Identifier") {
347
+ if (this.#add_ref(p.name, fn)) grew = true;
348
+ } else throw new All("a derived([…, page, …]) does not name the page parameter", (p ?? el).start ?? null);
349
+ });
350
+ }
351
+ }
352
+ });
353
+ if (grew) any = true;
354
+ }
355
+ return any;
356
+ }
357
+ is_page_value(raw) {
358
+ const n = unwrap_down(raw);
359
+ if (n.type === "Identifier") {
360
+ const bare = n.name.startsWith("$") ? n.name.slice(1) : n.name;
361
+ return this.#in_scope(n.name, n) || bare !== n.name && this.#in_scope(bare, n);
362
+ }
363
+ if (n.type === "CallExpression" && n.callee?.type === "Identifier" && this.#store_helper(n.callee) === "get") {
364
+ const a = n.arguments?.[0];
365
+ return !!a && a.type === "Identifier" && this.#in_scope(a.name, a);
366
+ }
367
+ return false;
368
+ }
369
+ walk(node, parent, key) {
370
+ if (!node || typeof node !== "object") return;
371
+ if (Array.isArray(node)) {
372
+ for (const child of node) this.walk(child, parent, key);
373
+ return;
374
+ }
375
+ if (node.type === "Identifier" && node.name === "arguments" && this.#in_followed(node)) throw new All("a function handed the page reads `arguments`", node.start ?? null);
376
+ if (typeof node.type === "string" && this.is_page_value(node) && !is_declaration(node, parent, key)) {
377
+ this.judge(node, parent, key);
378
+ if (node.type === "CallExpression") return;
379
+ }
380
+ if (node.type === "IfStatement" || node.type === "ConditionalExpression") {
381
+ const side = runs_on(node.test);
382
+ if (side) {
383
+ this.walk(node.test, node, "test");
384
+ if (side !== "server") this.walk(node.consequent, node, "consequent");
385
+ if (side !== "client" && node.alternate) this.walk(node.alternate, node, "alternate");
386
+ return;
387
+ }
388
+ }
389
+ if (node.type === "LogicalExpression" && node.operator === "&&" && runs_on(node.left) === "server") {
390
+ this.walk(node.left, node, "left");
391
+ return;
392
+ }
393
+ for (const k of Object.keys(node)) {
394
+ if (SKIP_KEYS.has(k)) continue;
395
+ const v = node[k];
396
+ if (v && typeof v === "object") this.walk(v, node, k);
397
+ }
398
+ }
399
+ judge(value, raw_parent, raw_key) {
400
+ const { node: v, parent, key } = raw_parent && WRAPPERS.has(raw_parent.type) ? unwrap_up(value) : {
401
+ node: value,
402
+ parent: raw_parent,
403
+ key: raw_key
404
+ };
405
+ const at = value.start ?? null;
406
+ if (!parent) throw new All("the page is used bare", at);
407
+ if (parent.type === "MemberExpression" && key === "object") {
408
+ const field = member_name(parent);
409
+ if (field === "data") {
410
+ this.judge_data(parent);
411
+ return;
412
+ }
413
+ if (field !== null && SAFE_FIELDS.has(field)) return;
414
+ if (field === "subscribe") {
415
+ const call = parent.__parent;
416
+ const fn = call?.type === "CallExpression" && parent.__key === "callee" ? call.arguments?.[0] : null;
417
+ if (fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") && fn.params?.[0]?.type === "Identifier") return;
418
+ throw new All("`page.subscribe(…)` hands a subscriber the whole page", at);
419
+ }
420
+ throw new All(field === null ? "the page is indexed with an expression" : `\`page.${field}\` is read`, at);
421
+ }
422
+ if (parent.type === "VariableDeclarator" && key === "init") return;
423
+ if (parent.type === "CallExpression" && key === "arguments" && parent.callee?.type === "Identifier") {
424
+ const name = parent.callee.name;
425
+ const helper = this.#store_helper(parent.callee);
426
+ if (helper === "get") return;
427
+ if (helper === "derived") {
428
+ const cb = parent.arguments[1];
429
+ if (parent.arguments[0] === v && (cb?.type === "ArrowFunctionExpression" || cb?.type === "FunctionExpression") && cb.params?.[0]?.type === "Identifier") return;
430
+ throw new All("`derived(page, …)` hands the page to a callback it does not read here", at);
431
+ }
432
+ const fn = this.#local_fn(parent.callee);
433
+ if (fn) {
434
+ const i = parent.arguments.indexOf(v);
435
+ if (fn.params?.[i]?.type === "Identifier") return;
436
+ throw new All(`the whole page is passed to \`${name}(…)\`, whose parameter is destructured`, at);
437
+ }
438
+ const imp = declared_above(name, parent.callee, false) ? void 0 : this.#imports.get(name);
439
+ if (imp) {
440
+ this.pending.push({
441
+ specifier: imp.specifier,
442
+ imported: imp.imported,
443
+ arg: parent.arguments.indexOf(v),
444
+ line: at === null ? null : line_of(this.code, at)
445
+ });
446
+ return;
447
+ }
448
+ throw new All(`the whole page is passed to \`${name}(…)\``, at);
449
+ }
450
+ if (parent.type === "ArrayExpression") {
451
+ const call = parent.__parent;
452
+ if (call?.type === "CallExpression" && call.callee?.type === "Identifier" && this.#store_helper(call.callee) === "derived" && call.arguments?.[0] === parent && call.arguments.length >= 2) return;
453
+ throw new All("the whole page is put in an array", at);
454
+ }
455
+ if (parent.type === "CallExpression" && key === "arguments" && parent.callee?.type === "MemberExpression" && parent.callee.object?.name === "Object" && parent.callee.property?.name === "keys") return;
456
+ throw new All("the whole page escapes (passed on, returned, spread, exported or compared)", at);
457
+ }
458
+ judge_data(data_member) {
459
+ let { parent: owner, key: owner_key } = unwrap_up(data_member);
460
+ const at = data_member.start ?? null;
461
+ while (owner && owner.type === "LogicalExpression" && (owner.operator === "||" || owner.operator === "??") && owner_key === "left") {
462
+ const up = unwrap_up(owner);
463
+ owner = up.parent;
464
+ owner_key = up.key;
465
+ }
466
+ if (!owner) throw new All("`page.data` is used bare", at);
467
+ if (owner.type === "MemberExpression" && owner_key === "object") {
468
+ const k = member_name(owner);
469
+ if (k === null) throw new All("`page.data[…]` is indexed with an expression", at);
470
+ const call = unwrap_up(owner);
471
+ if (call.parent?.type === "CallExpression" && call.key === "callee") throw new All(`\`page.data.${k}(…)\` is called with \`page.data\` as \`this\``, at);
472
+ this.keys.add(k);
473
+ return;
474
+ }
475
+ if (owner.type === "VariableDeclarator" && owner_key === "init" && owner.id?.type === "ObjectPattern") {
476
+ for (const p of owner.id.properties) {
477
+ if (p.type !== "Property" || p.computed) throw new All("`page.data` is destructured with a rest or computed key", p.start ?? at);
478
+ let k = null;
479
+ if (p.key?.type === "Identifier") k = p.key.name;
480
+ else if (p.key?.type === "Literal") k = String(p.key.value);
481
+ if (k === null) throw new All("`page.data` is destructured with a non-literal key", p.start ?? at);
482
+ this.keys.add(k);
483
+ }
484
+ return;
485
+ }
486
+ if (owner.type === "CallExpression") throw new All(`\`page.data\` is handed whole to ${call_name(owner)}(…)`, at);
487
+ throw new All(WHOLE_USE.get(owner.type) ?? `\`page.data\` is used whole (${owner.type})`, at);
488
+ }
489
+ };
490
+ function runs_on(test) {
491
+ const t = test ? unwrap_down(test) : null;
492
+ if (!t) return null;
493
+ if (t.type === "UnaryExpression" && t.operator === "!") {
494
+ const inner = runs_on(t.argument);
495
+ return inner && FLIP_SIDE[inner];
496
+ }
497
+ if (t.type === "LogicalExpression" && t.operator === "??") {
498
+ const side = runs_on(t.left);
499
+ return side !== null && side === runs_on(t.right) ? side : null;
500
+ }
501
+ if (t.type === "MemberExpression" && !t.computed && t.property?.name === "SSR" && t.object?.type === "MemberExpression" && t.object.property?.name === "env" && t.object.object?.type === "MetaProperty") return "server";
502
+ if (t.type !== "BinaryExpression") return null;
503
+ const eq = t.operator === "===" || t.operator === "==";
504
+ if (!eq && t.operator !== "!==" && t.operator !== "!=") return null;
505
+ const typeof_global = (n) => n?.type === "UnaryExpression" && n.operator === "typeof" && n.argument?.type === "Identifier" && (n.argument.name === "window" || n.argument.name === "document") && !declared_above(n.argument.name, n.argument, true);
506
+ const undef = (n) => (n?.type === "Literal" || n?.type === "StringLiteral") && n.value === "undefined";
507
+ const l = unwrap_down(t.left);
508
+ const r = unwrap_down(t.right);
509
+ if (!(typeof_global(l) && undef(r) || typeof_global(r) && undef(l))) return null;
510
+ return eq ? "server" : "client";
511
+ }
512
+ function declared_above(name, use, module) {
513
+ for (let n = use.__parent; n; n = n.__parent) {
514
+ if ((n.type === "Program" || n.type === "Fragment" || n.type === "Root") && !module) return false;
515
+ if (declares(n, name)) return true;
516
+ }
517
+ return false;
518
+ }
519
+ function declares(n, name) {
520
+ const has = (pattern) => pattern_names(pattern).includes(name);
521
+ switch (n.type) {
522
+ case "FunctionDeclaration":
523
+ case "FunctionExpression":
524
+ case "ArrowFunctionExpression": return (n.params ?? []).some(has) || n.type === "FunctionExpression" && n.id?.name === name;
525
+ case "Program":
526
+ case "BlockStatement":
527
+ case "StaticBlock": return (n.body ?? []).some((s) => statement_declares(s, name));
528
+ case "ForStatement": return n.init?.type === "VariableDeclaration" && statement_declares(n.init, name);
529
+ case "ForInStatement":
530
+ case "ForOfStatement": return n.left?.type === "VariableDeclaration" && statement_declares(n.left, name);
531
+ case "CatchClause": return has(n.param);
532
+ case "SnippetBlock": return (n.parameters ?? []).some(has);
533
+ case "EachBlock": return has(n.context) || n.index === name;
534
+ default: return false;
535
+ }
536
+ }
537
+ function statement_declares(s, name) {
538
+ const d = s.type === "ExportNamedDeclaration" || s.type === "ExportDefaultDeclaration" ? s.declaration : s;
539
+ if (!d) return false;
540
+ if (d.type === "VariableDeclaration") return (d.declarations ?? []).some((x) => pattern_names(x.id).includes(name));
541
+ if (d.type === "FunctionDeclaration" || d.type === "ClassDeclaration") return d.id?.name === name;
542
+ if (d.type === "ImportDeclaration") return (d.specifiers ?? []).some((x) => x.local?.name === name);
543
+ return false;
544
+ }
545
+ function pattern_names(p) {
546
+ if (!p) return [];
547
+ if (p.type === "Identifier") return [p.name];
548
+ if (p.type === "ObjectPattern") return (p.properties ?? []).flatMap((x) => pattern_names(x.type === "RestElement" ? x.argument : x.value));
549
+ if (p.type === "ArrayPattern") return (p.elements ?? []).flatMap((x) => pattern_names(x));
550
+ if (p.type === "RestElement") return pattern_names(p.argument);
551
+ if (p.type === "AssignmentPattern") return pattern_names(p.left);
552
+ if (WRAPPERS.has(p.type)) return pattern_names(p.expression);
553
+ return [];
554
+ }
555
+ function enclosing_scope(node) {
556
+ for (let n = node.__parent; n; n = n.__parent) if (SCOPE_TYPES.has(n.type)) return n.type === "Program" || n.type === "Fragment" || n.type === "Root" ? null : n;
557
+ return null;
558
+ }
559
+ function unwrap_down(n) {
560
+ let cur = n;
561
+ while (cur && WRAPPERS.has(cur.type) && cur.expression) cur = cur.expression;
562
+ return cur;
563
+ }
564
+ function call_name(call) {
565
+ const c = call.callee;
566
+ if (!c) return "?";
567
+ if (c.type === "Identifier") return c.name;
568
+ if (c.type === "MemberExpression") return `${c.object?.name ?? "…"}.${c.property?.name ?? "…"}`;
569
+ return "?";
570
+ }
571
+ function member_name(m) {
572
+ if (!m.computed) return m.property?.type === "Identifier" ? m.property.name : null;
573
+ return static_string(m.property);
574
+ }
575
+ function static_string(n) {
576
+ if (n?.type === "Literal" && typeof n.value === "string") return n.value;
577
+ if (n?.type === "TemplateLiteral" && n.expressions?.length === 0) return n.quasis?.[0]?.value?.cooked ?? null;
578
+ return null;
579
+ }
580
+ function spec_name(n) {
581
+ if (!n) return null;
582
+ if (n.type === "Identifier") return n.name;
583
+ if (n.type === "Literal") return String(n.value);
584
+ return null;
585
+ }
586
+ function is_declaration(node, parent, key) {
587
+ if (!parent || node.type !== "Identifier") return false;
588
+ if (parent.type === "VariableDeclarator" && key === "id") return true;
589
+ if (parent.type === "Property" && key === "key" && !parent.computed) return true;
590
+ if (parent.type === "MemberExpression" && key === "property" && !parent.computed) return true;
591
+ if (parent.type === "ImportSpecifier" || parent.type === "ImportDefaultSpecifier" || parent.type === "ImportNamespaceSpecifier") return true;
592
+ if (key === "params") return true;
593
+ if (parent.type === "ArrayPattern" || parent.type === "ObjectPattern" || parent.type === "RestElement") return true;
594
+ if (parent.type === "AssignmentPattern") return key === "left";
595
+ if ((parent.type === "FunctionDeclaration" || parent.type === "FunctionExpression" || parent.type === "ClassDeclaration") && key === "id") return true;
596
+ if (parent.type === "LabeledStatement" && key === "label") return true;
597
+ return false;
598
+ }
599
+ function assigned_names(root) {
600
+ const names = /* @__PURE__ */ new Set();
601
+ const target = (t) => {
602
+ if (!t) return;
603
+ if (t.type === "Identifier") names.add(t.name);
604
+ else if (t.type === "ObjectPattern") for (const p of t.properties ?? []) target(p.type === "RestElement" ? p.argument : p.value);
605
+ else if (t.type === "ArrayPattern") for (const e of t.elements ?? []) target(e);
606
+ else if (t.type === "RestElement") target(t.argument);
607
+ else if (t.type === "AssignmentPattern") target(t.left);
608
+ else if (WRAPPERS.has(t.type)) target(t.expression);
609
+ };
610
+ const rec = (node) => {
611
+ if (!node || typeof node !== "object") return;
612
+ if (Array.isArray(node)) {
613
+ for (const child of node) rec(child);
614
+ return;
615
+ }
616
+ if (node.type === "AssignmentExpression") target(node.left);
617
+ else if (node.type === "UpdateExpression") target(node.argument);
618
+ for (const k of Object.keys(node)) {
619
+ if (SKIP_KEYS.has(k)) continue;
620
+ const v = node[k];
621
+ if (v && typeof v === "object") rec(v);
622
+ }
623
+ };
624
+ rec(root);
625
+ return names;
626
+ }
627
+ function visit(root, fn) {
628
+ const rec = (node, parent, key) => {
629
+ if (!node || typeof node !== "object") return;
630
+ if (Array.isArray(node)) {
631
+ for (const child of node) rec(child, parent, key);
632
+ return;
633
+ }
634
+ if (typeof node.type === "string") {
635
+ Object.defineProperty(node, "__parent", {
636
+ value: parent,
637
+ enumerable: false,
638
+ configurable: true
639
+ });
640
+ Object.defineProperty(node, "__key", {
641
+ value: key,
642
+ enumerable: false,
643
+ configurable: true
644
+ });
645
+ fn(node);
646
+ }
647
+ for (const k of Object.keys(node)) {
648
+ if (SKIP_KEYS.has(k)) continue;
649
+ const v = node[k];
650
+ if (v && typeof v === "object") rec(v, node, k);
651
+ }
652
+ };
653
+ rec(root, null, null);
654
+ }
655
+ const FOLLOW_MAX_HOPS = 4;
656
+ const SVELTE_EXT_RE = /\.svelte$/;
657
+ const SCRIPT_EXT_RE = /\.(?:[cm]?[jt]sx?)$/;
658
+ /**
659
+ * For every module with pending `helper(page)` calls: resolve each helper, summarize its export,
660
+ * fold the answer into the module's keys (`'all'` with a reason when the helper cannot be
661
+ * summarized). Runs once per build, before the closure union. `read` and `resolve` are the
662
+ * build's (fs + the bundler's resolver), threaded in so this stays testable.
663
+ */
664
+ async function follow_pending_page_calls(program, resolve, read = read_file_sync) {
665
+ const summaries = /* @__PURE__ */ new Map();
666
+ for (const [module, calls] of program.page_pending) {
667
+ let keys = program.page_keys.get(module) ?? /* @__PURE__ */ new Set();
668
+ for (const call of calls) {
669
+ if (keys === "all") break;
670
+ const answer = await summarize_call(call, module, resolve, read, summaries);
671
+ if (answer.keys === "all") {
672
+ keys = "all";
673
+ program.page_key_reasons.set(module, {
674
+ why: `the whole page is passed to \`${call.imported}(…)\` — ${answer.why}`,
675
+ line: call.line
676
+ });
677
+ break;
678
+ }
679
+ keys = merge_page_keys(keys, answer.keys) ?? keys;
680
+ }
681
+ program.page_keys.set(module, keys ?? /* @__PURE__ */ new Set());
682
+ }
683
+ program.page_pending.clear();
684
+ }
685
+ async function summarize_call(call, importer, resolve, read, memo) {
686
+ let specifier = call.specifier;
687
+ let from = importer;
688
+ let name = call.imported;
689
+ for (let hop = 0; hop < FOLLOW_MAX_HOPS; hop++) {
690
+ let resolved;
691
+ try {
692
+ resolved = await resolve(specifier, from);
693
+ } catch {
694
+ resolved = null;
695
+ }
696
+ if (!resolved?.id) return {
697
+ keys: "all",
698
+ why: `\`${specifier}\` could not be resolved from the caller`
699
+ };
700
+ const file = resolved.id.split("?")[0];
701
+ const memo_key = `${file}#${name}#${call.arg}`;
702
+ const hit = memo.get(memo_key);
703
+ if (hit) return {
704
+ keys: hit,
705
+ why: ""
706
+ };
707
+ let kind = null;
708
+ if (SVELTE_EXT_RE.test(file)) kind = "svelte";
709
+ else if (SCRIPT_EXT_RE.test(file)) kind = "script";
710
+ const code = kind ? read(file) : null;
711
+ if (!kind || code === null) return {
712
+ keys: "all",
713
+ why: `the helper's module (${file}) could not be read`
714
+ };
715
+ const summary = summarize_export(code, file, kind, name, call.arg);
716
+ if (summary === "all") return {
717
+ keys: "all",
718
+ why: `\`${name}\` in ${file} hands the page on, or is not a plain function`
719
+ };
720
+ if (!is_reexport(summary)) {
721
+ memo.set(memo_key, summary);
722
+ return {
723
+ keys: summary,
724
+ why: ""
725
+ };
726
+ }
727
+ if (summary.follow.length === 1) {
728
+ specifier = summary.follow[0];
729
+ from = file;
730
+ name = summary.imported;
731
+ continue;
732
+ }
733
+ for (const source of summary.follow) {
734
+ const sub = await summarize_call({
735
+ ...call,
736
+ specifier: source,
737
+ imported: summary.imported
738
+ }, file, resolve, read, memo);
739
+ if (sub.keys !== "all") return sub;
740
+ }
741
+ return {
742
+ keys: "all",
743
+ why: `\`${name}\` was not found behind the \`export *\` of ${file}`
744
+ };
745
+ }
746
+ return {
747
+ keys: "all",
748
+ why: `\`${name}\` sits behind more than ${FOLLOW_MAX_HOPS} re-exports`
749
+ };
750
+ }
751
+ function is_reexport(s) {
752
+ return typeof s === "object" && s !== null && "follow" in s;
753
+ }
754
+ function read_file_sync(file) {
755
+ try {
756
+ return fs.readFileSync(file, "utf8");
757
+ } catch {
758
+ return null;
759
+ }
760
+ }
761
+ export { follow_pending_page_calls, mentions_page_store, merge_page_keys, page_data_keys, page_data_keys_answer, read_file_sync, summarize_export };
@@ -0,0 +1,4 @@
1
+ import { PageReads } from "@ogygia/compiler/vite";
2
+ /** One build's answers (a plugin instance per configured `ogygia()`: Kit 2 builds each leg in its
3
+ * own). `read` is the build's file reader, threaded in so this stays testable. */
4
+ export declare function page_reads(read?: (file: string) => string | null): PageReads;
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import { follow_pending_page_calls, mentions_page_store, page_data_keys_answer, read_file_sync, summarize_export } from "./analysis.js";
2
+ // src/index.ts
3
+ const SCRIPT_MODULE_RE = /\.(?:[cm]?[jt]sx?)$/;
4
+ /** One build's answers (a plugin instance per configured `ogygia()`: Kit 2 builds each leg in its
5
+ * own). `read` is the build's file reader, threaded in so this stays testable. */
6
+ function page_reads(read = read_file_sync) {
7
+ const state = {
8
+ page_keys: /* @__PURE__ */ new Map(),
9
+ page_key_reasons: /* @__PURE__ */ new Map(),
10
+ page_pending: /* @__PURE__ */ new Map()
11
+ };
12
+ const kind_of = (id) => id.endsWith(".svelte") ? "svelte" : "script";
13
+ return {
14
+ module(id, code) {
15
+ if (!mentions_page_store(code)) return;
16
+ if (!id.endsWith(".svelte") && !SCRIPT_MODULE_RE.test(id)) return;
17
+ const { keys, reason, pending } = page_data_keys_answer(code, id, kind_of(id));
18
+ if (keys !== null) state.page_keys.set(id, keys);
19
+ if (reason) state.page_key_reasons.set(id, reason);
20
+ if (pending.length) state.page_pending.set(id, pending);
21
+ else state.page_pending.delete(id);
22
+ },
23
+ settle: (resolve) => follow_pending_page_calls(state, resolve, read),
24
+ keys(id) {
25
+ if (state.page_pending.has(id)) return "unknown";
26
+ const k = state.page_keys.get(id);
27
+ if (k === void 0) return null;
28
+ return k === "all" ? "unknown" : k;
29
+ },
30
+ why: (id) => state.page_key_reasons.get(id) ?? null,
31
+ async dev(files, resolve) {
32
+ const read_keys = /* @__PURE__ */ new Set();
33
+ let all = false;
34
+ let any = false;
35
+ const why = [];
36
+ const add = (k) => {
37
+ if (k === null) return;
38
+ any = true;
39
+ if (k === "all") all = true;
40
+ else for (const x of k) read_keys.add(x);
41
+ };
42
+ for (const f of files) {
43
+ const code = read(f);
44
+ if (!code) continue;
45
+ const a = page_data_keys_answer(code, f, kind_of(f));
46
+ if (a.keys === "all" && a.reason) why.push({
47
+ file: f,
48
+ line: a.reason.line,
49
+ why: a.reason.why
50
+ });
51
+ add(a.keys);
52
+ for (const p of a.pending) {
53
+ const target = (await resolve(p.specifier, f))?.id;
54
+ const tcode = target ? read(target) : null;
55
+ const s = tcode ? summarize_export(tcode, target, kind_of(target), p.imported, p.arg) : "all";
56
+ if (s === "all" || !(s instanceof Set)) {
57
+ why.push({
58
+ file: f,
59
+ line: p.line,
60
+ why: `the page is handed to ${p.imported}(), which the analysis cannot follow`
61
+ });
62
+ add("all");
63
+ } else add(s);
64
+ }
65
+ }
66
+ if (!any) return {
67
+ keys: null,
68
+ why
69
+ };
70
+ return {
71
+ keys: all ? "unknown" : [...read_keys],
72
+ why
73
+ };
74
+ }
75
+ };
76
+ }
77
+ export { page_reads };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { OgygiaPlugin } from "@ogygia/compiler/vite";
2
+ /**
3
+ * Data shaking, listed beside `ogygia()` (`plugins: [ogygia(), dataShake(), sveltekit()]`): a page
4
+ * ships only the data its regions' code reads. Its first job is the page seed.
5
+ *
6
+ * An island that reads `page.data` through `$app/state` / `$app/stores` gets the page seed. Without
7
+ * this plugin that seed is all of `page.data`, and every server hole looks it up. With it, the build
8
+ * reads each module once for the top-level `page.data` keys it can reach; the page ships only the
9
+ * keys its islands read, and a hole whose tree reads none skips the lookup. Any read the analysis
10
+ * cannot pin answers `'unknown'`, and that region gets all of `page.data` as before.
11
+ */
12
+ export declare function dataShake(): OgygiaPlugin;
package/dist/vite.js ADDED
@@ -0,0 +1,22 @@
1
+ import { page_reads } from "./index.js";
2
+ import { definePlugin } from "@ogygia/compiler/vite";
3
+ // src/vite.ts
4
+ /**
5
+ * Data shaking, listed beside `ogygia()` (`plugins: [ogygia(), dataShake(), sveltekit()]`): a page
6
+ * ships only the data its regions' code reads. Its first job is the page seed.
7
+ *
8
+ * An island that reads `page.data` through `$app/state` / `$app/stores` gets the page seed. Without
9
+ * this plugin that seed is all of `page.data`, and every server hole looks it up. With it, the build
10
+ * reads each module once for the top-level `page.data` keys it can reach; the page ships only the
11
+ * keys its islands read, and a hole whose tree reads none skips the lookup. Any read the analysis
12
+ * cannot pin answers `'unknown'`, and that region gets all of `page.data` as before.
13
+ */
14
+ function dataShake() {
15
+ return definePlugin({
16
+ name: "@ogygia/data-shake",
17
+ build(b) {
18
+ b.pageReads(page_reads());
19
+ }
20
+ });
21
+ }
22
+ export { dataShake };
package/package.json CHANGED
@@ -1,13 +1,53 @@
1
1
  {
2
- "name": "@ogygia/data-shake",
3
- "version": "0.0.0",
4
- "description": "Placeholder that reserves the name for ogygia. The first real release is 0.14.",
5
- "homepage": "https://ogygiajs.dev",
6
- "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/ogygiajs/ogygia.git",
10
- "directory": "packages/data-shake"
11
- },
12
- "files": ["README.md"]
13
- }
2
+ "name": "@ogygia/data-shake",
3
+ "version": "0.14.1",
4
+ "description": "Data shaking for ogygia apps: a page ships only the data its regions' code reads, starting with page.data",
5
+ "keywords": [
6
+ "data-shaking",
7
+ "ogygia",
8
+ "page-data",
9
+ "sveltekit",
10
+ "vite"
11
+ ],
12
+ "homepage": "https://ogygiajs.dev",
13
+ "license": "MIT",
14
+ "author": "Puru Vijayvargia <devpuruvj@gmail.com>",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/ogygiajs/ogygia.git",
18
+ "directory": "packages/data-shake"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ "./vite": {
28
+ "types": "./dist/vite.d.ts",
29
+ "default": "./dist/vite.js"
30
+ }
31
+ },
32
+ "devDependencies": {
33
+ "@ogygia/compiler": "0.14.1",
34
+ "@ogygia/config": "0.0.0",
35
+ "@ogygia/core": "0.14.1",
36
+ "@typescript/native": "npm:typescript@^7.0.2",
37
+ "svelte": "5.57.3",
38
+ "tsdown": "^0.23.4",
39
+ "typescript": "^6.0.3",
40
+ "vite": "^8.3.5",
41
+ "vitest": "^4.1.12"
42
+ },
43
+ "peerDependencies": {
44
+ "@ogygia/compiler": "^0.14.1",
45
+ "svelte": "^5.56.8",
46
+ "vite": "^8.2.4"
47
+ },
48
+ "scripts": {
49
+ "build": "tsdown",
50
+ "check": "tsc -p . && tsc -p test && vitest run",
51
+ "test": "vitest run"
52
+ }
53
+ }