@svelte-vitals/vite 0.17.0 → 0.19.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { TreatDynamicAs, RuleSetting, Severity, Category } from '@svelte-vitals/core';
2
+ import { TreatDynamicAs, RuleSetting, RuleOverride, Severity, Category } from '@svelte-vitals/core';
3
3
 
4
4
  interface SvelteVitalsOptions {
5
5
  /** Project root (defaults to the Vite config root / cwd). */
@@ -7,6 +7,8 @@ interface SvelteVitalsOptions {
7
7
  treatDynamicAs?: TreatDynamicAs;
8
8
  metaComponents?: string[];
9
9
  rules?: Record<string, RuleSetting>;
10
+ /** Route-/file-scoped rule overrides applied to build-gate results (option > config file). */
11
+ overrides?: RuleOverride[];
10
12
  /** Minimum severity that fails the build (default: 'critical'). */
11
13
  failOn?: Severity;
12
14
  /** Per-category weights for the combined Health score shown in the JSON/console report (flag > config file > default 1 each). */
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  allRules,
17
17
  selectRules,
18
18
  applyRuleSeverities,
19
+ applyOverrides,
19
20
  runRules,
20
21
  computeScore,
21
22
  summarize,
@@ -105,7 +106,10 @@ async function collectRenderedProject(cwd, htmlLang) {
105
106
  import { readFile as readFile3, access as access2 } from "fs/promises";
106
107
  import { join as join3 } from "path";
107
108
  import { glob as glob2 } from "tinyglobby";
108
- import { collectComponentFacts as collect } from "@svelte-vitals/core";
109
+ import {
110
+ collectComponentFacts as collect,
111
+ collectKitModuleFacts as collectKit
112
+ } from "@svelte-vitals/core";
109
113
  var nodeRuntime = {
110
114
  readFile: (path) => readFile3(path, "utf8"),
111
115
  async exists(path) {
@@ -122,6 +126,9 @@ var nodeRuntime = {
122
126
  function collectComponentFacts(root) {
123
127
  return collect(nodeRuntime, root);
124
128
  }
129
+ function collectKitModuleFacts(root) {
130
+ return collectKit(nodeRuntime, root);
131
+ }
125
132
 
126
133
  // src/version.ts
127
134
  import { readFileSync } from "fs";
@@ -149,18 +156,32 @@ async function analyze(prerenderPagesDir, cwd, options) {
149
156
  const fileConfig = loaded?.config;
150
157
  const warnings = loaded?.warnings ?? [];
151
158
  const weights = options.weights ?? fileConfig?.weights;
159
+ const overrides = options.overrides ?? fileConfig?.overrides;
152
160
  const config = defineConfig({
153
161
  treatDynamicAs: options.treatDynamicAs ?? fileConfig?.treatDynamicAs ?? "pass",
154
162
  metaComponents: options.metaComponents ?? fileConfig?.metaComponents ?? [],
155
163
  rules: options.rules ?? fileConfig?.rules ?? {},
156
164
  failOn: options.failOn ?? fileConfig?.failOn ?? "critical",
157
- ...weights !== void 0 ? { weights } : {}
165
+ ...weights !== void 0 ? { weights } : {},
166
+ ...overrides !== void 0 ? { overrides } : {}
158
167
  });
159
168
  const { heads, headings, images, htmlLang } = await collectRenderedHeads(prerenderPagesDir);
160
169
  const project = await collectRenderedProject(cwd, htmlLang);
161
170
  const components = await collectComponentFacts(cwd);
162
- const results = applyRuleSeverities(
163
- await runRules(selectRules(allRules, config), { heads, headings, images, project, components, config }),
171
+ const kitModules = await collectKitModuleFacts(cwd);
172
+ const results = applyOverrides(
173
+ applyRuleSeverities(
174
+ await runRules(selectRules(allRules, config), {
175
+ heads,
176
+ headings,
177
+ images,
178
+ project,
179
+ components,
180
+ config,
181
+ kitModules
182
+ }),
183
+ config
184
+ ),
164
185
  config
165
186
  );
166
187
  const { score } = computeScore(results, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svelte-vitals/vite",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,8 +42,8 @@
42
42
  "esm-env": "^1.2.2",
43
43
  "node-html-parser": "^9.0.0",
44
44
  "tinyglobby": "^0.2.17",
45
- "@svelte-vitals/core": "0.25.0",
46
- "svelte-vitals": "0.28.0"
45
+ "@svelte-vitals/core": "0.27.0",
46
+ "svelte-vitals": "0.30.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@sveltejs/kit": "^2.69.2",