@svelte-vitals/vite 0.54.7 → 0.55.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/dist/hooks/index.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -4
- package/package.json +7 -7
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuleSetting } from "@svelte-vitals/core";
|
|
1
|
+
import { Config, RuleSetting } from "@svelte-vitals/core";
|
|
2
2
|
import { Handle } from "@sveltejs/kit";
|
|
3
3
|
//#region src/hooks/handle.d.ts
|
|
4
4
|
/** Options for the dev-time SvelteKit handle. A focused subset of the plugin options. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Category, RuleOverride, RuleSetting, Severity, TreatDynamicAs } from "@svelte-vitals/core";
|
|
1
|
+
import { Category, Config, RuleOverride, RuleSetting, Severity, TreatDynamicAs } from "@svelte-vitals/core";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
interface SvelteVitalsOptions {
|
|
@@ -13,6 +13,8 @@ interface SvelteVitalsOptions {
|
|
|
13
13
|
failOn?: Severity;
|
|
14
14
|
/** Per-category weights for the combined Health score shown in the JSON/console report (flag > config file > default 1 each). */
|
|
15
15
|
weights?: Partial<Record<Category, number>>;
|
|
16
|
+
/** SEO-wide switches (option > config file). `indexable: false` turns off the search-result rules. */
|
|
17
|
+
seo?: Config['seo'];
|
|
16
18
|
/** Report output (default: 'console'). */
|
|
17
19
|
report?: 'console' | 'json' | false;
|
|
18
20
|
/** Write the JSON report to this path. */
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
5
5
|
import { CATEGORIES, defineConfig } from "@svelte-vitals/core";
|
|
6
|
-
import { ROBOTS_SOURCE_PATHS, SITEMAP_SOURCE_PATHS, SVELTE_CONFIG_FILES, VITE_CONFIG_FILES, addFactsDirectives, allRules, buildJsonReport, collectComponentFacts, collectKitModuleFacts, collectSourceFiles, collectSuppressions, computeScore, defaultConfig, findMinifyDisabled, formatConsoleReport, formatFailedRuleWarning, formatJsonReport, hasFailureAtOrAbove, renderAppShell, resolveKitAliases, resolveKitPathsBase, resolveRuleOptions, runAnalysis, safeHref, selectRules, shouldSkipRangeCheck, skippedFileWarnings, summarize, terminalSafe, unknownDirectiveIds, validateRuleSetting, withFailedRulesOff } from "@svelte-vitals/core/internal";
|
|
6
|
+
import { ROBOTS_SOURCE_PATHS, SITEMAP_SOURCE_PATHS, SVELTE_CONFIG_FILES, VITE_CONFIG_FILES, addFactsDirectives, allRules, buildJsonReport, collectComponentFacts, collectKitModuleFacts, collectSourceFiles, collectSuppressions, computeScore, defaultConfig, findMinifyDisabled, formatConsoleReport, formatFailedRuleWarning, formatJsonReport, hasFailureAtOrAbove, isPlainObject, renderAppShell, resolveKitAliases, resolveKitPathsBase, resolveRuleOptions, runAnalysis, safeHref, selectRules, shouldSkipRangeCheck, skippedFileWarnings, summarize, terminalSafe, unknownDirectiveIds, validateRuleSetting, withFailedRulesOff, withIndexableOff } from "@svelte-vitals/core/internal";
|
|
7
7
|
import { CONFIG_FILENAMES, SUPPRESSIONS_FILE, analyzeProject, applySuppressions, createNodeRuntime, findUnknownRuleIds, knownRuleIds, loadConfigFile, loadSuppressions, registryTag, ruleOptionsSpec } from "svelte-vitals";
|
|
8
8
|
//#region src/providers/rendered/collect.ts
|
|
9
9
|
/** Map a prerendered HTML path (relative to pages/, POSIX) to its route. */
|
|
@@ -220,13 +220,15 @@ function readCoreVersion() {
|
|
|
220
220
|
function mergeConfig(options, fileConfig) {
|
|
221
221
|
const weights = options.weights ?? fileConfig?.weights;
|
|
222
222
|
const overrides = options.overrides ?? fileConfig?.overrides;
|
|
223
|
+
const seo = options.seo ?? fileConfig?.seo;
|
|
223
224
|
return defineConfig({
|
|
224
225
|
treatDynamicAs: options.treatDynamicAs ?? fileConfig?.treatDynamicAs ?? "pass",
|
|
225
226
|
metaComponents: options.metaComponents ?? fileConfig?.metaComponents ?? [],
|
|
226
|
-
rules: options.rules ?? fileConfig?.rules ?? {},
|
|
227
|
+
rules: withIndexableOff(options.rules ?? fileConfig?.rules, seo) ?? {},
|
|
227
228
|
failOn: options.failOn ?? fileConfig?.failOn ?? "critical",
|
|
228
229
|
...weights !== void 0 ? { weights } : {},
|
|
229
|
-
...overrides !== void 0 ? { overrides } : {}
|
|
230
|
+
...overrides !== void 0 ? { overrides } : {},
|
|
231
|
+
...seo !== void 0 ? { seo } : {}
|
|
230
232
|
});
|
|
231
233
|
}
|
|
232
234
|
/**
|
|
@@ -713,6 +715,7 @@ function createAnalysisRunner(opts) {
|
|
|
713
715
|
metaComponents: opts.metaComponents,
|
|
714
716
|
rules: opts.rules,
|
|
715
717
|
failOn: opts.failOn,
|
|
718
|
+
seo: opts.seo,
|
|
716
719
|
parseCache
|
|
717
720
|
});
|
|
718
721
|
const { failedRuleIds } = result;
|
|
@@ -875,10 +878,23 @@ function validateOverridesOption(overrides, rules) {
|
|
|
875
878
|
});
|
|
876
879
|
if (errors.length > 0) throw new Error(`svelte-vitals: invalid \`overrides\` option — ${errors.join(" ")}`);
|
|
877
880
|
}
|
|
881
|
+
/**
|
|
882
|
+
* Validate the plugin's `seo` option the same way the config-file loader validates the
|
|
883
|
+
* `seo` key. A `vite.config.js` gets no type checking, and `{ indexable: 'no' }` would
|
|
884
|
+
* otherwise be silently inert — the failure mode `validateRulesOption` exists for.
|
|
885
|
+
*/
|
|
886
|
+
function validateSeoOption(seo) {
|
|
887
|
+
if (seo === void 0) return;
|
|
888
|
+
if (!isPlainObject(seo)) throw new Error("svelte-vitals: invalid `seo` option — must be an object, e.g. { indexable: false }.");
|
|
889
|
+
const unknown = Object.keys(seo).filter((k) => k !== "indexable");
|
|
890
|
+
if (unknown.length > 0) throw new Error(`svelte-vitals: invalid \`seo\` option — unknown key(s): ${unknown.join(", ")}. Known keys: indexable.`);
|
|
891
|
+
if (seo.indexable !== void 0 && typeof seo.indexable !== "boolean") throw new Error("svelte-vitals: invalid `seo` option — seo.indexable must be a boolean.");
|
|
892
|
+
}
|
|
878
893
|
/** svelte-vitals Vite/SvelteKit plugin. */
|
|
879
894
|
function svelteVitals(options = {}) {
|
|
880
895
|
validateRulesOption(options.rules);
|
|
881
896
|
validateOverridesOption(options.overrides, options.rules);
|
|
897
|
+
validateSeoOption(options.seo);
|
|
882
898
|
let root = options.cwd ?? process.cwd();
|
|
883
899
|
let minify;
|
|
884
900
|
let configFile;
|
|
@@ -926,7 +942,7 @@ function svelteVitals(options = {}) {
|
|
|
926
942
|
if (options.ui === false) return buildPlugin;
|
|
927
943
|
return [buildPlugin, {
|
|
928
944
|
name: "svelte-vitals:ui",
|
|
929
|
-
apply: "serve",
|
|
945
|
+
apply: (_config, env) => env.command === "serve" && !process.env.VITEST,
|
|
930
946
|
async configureServer(server) {
|
|
931
947
|
process.env.SVELTE_VITALS_UI = "1";
|
|
932
948
|
const uiRoot = options.cwd ?? server.config.root;
|
|
@@ -956,6 +972,7 @@ function svelteVitals(options = {}) {
|
|
|
956
972
|
metaComponents: options.metaComponents,
|
|
957
973
|
rules: options.rules,
|
|
958
974
|
failOn: options.failOn,
|
|
975
|
+
seo: options.seo,
|
|
959
976
|
onResults: (results, failedRuleIds) => {
|
|
960
977
|
store.setStatic(results);
|
|
961
978
|
staticFailedRuleIds = failedRuleIds ?? [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-vitals/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.1",
|
|
4
4
|
"description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build, plus a live dev dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"node-html-parser": "^9.0.4"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@svelte-vitals/core": "^0.
|
|
46
|
+
"@svelte-vitals/core": "^0.55.1",
|
|
47
47
|
"@sveltejs/kit": "^2.70.3",
|
|
48
|
-
"svelte-vitals": "^0.
|
|
48
|
+
"svelte-vitals": "^0.55.1",
|
|
49
49
|
"vite": "^8.3.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@svelte-vitals/core": "0.
|
|
57
|
+
"@svelte-vitals/core": "0.55.1",
|
|
58
58
|
"@sveltejs/kit": "^2.70.3",
|
|
59
|
-
"@types/node": "^24.13.
|
|
60
|
-
"happy-dom": "^20.14.
|
|
59
|
+
"@types/node": "^24.13.5",
|
|
60
|
+
"happy-dom": "^20.14.5",
|
|
61
61
|
"svelte": "^5.57.0",
|
|
62
|
-
"svelte-vitals": "0.
|
|
62
|
+
"svelte-vitals": "0.55.1",
|
|
63
63
|
"vite": "^8.3.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|