@svelte-vitals/vite 0.19.0 → 0.20.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.
|
@@ -53,7 +53,7 @@ function parseHtmlHead(html) {
|
|
|
53
53
|
value: attrValue(href),
|
|
54
54
|
...asAttr != null ? { hasAs: true, as: asAttr } : {},
|
|
55
55
|
...hasCrossorigin ? { hasCrossorigin: true } : {},
|
|
56
|
-
// Keep a literal empty hreflang="" (present-but-invalid) so
|
|
56
|
+
// Keep a literal empty hreflang="" (present-but-invalid) so seo/hreflang can flag it.
|
|
57
57
|
...hreflang != null ? { hreflang } : {},
|
|
58
58
|
...href ? { href } : {}
|
|
59
59
|
});
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { RuleSetting } from '@svelte-vitals/core';
|
|
|
5
5
|
interface SvelteVitalsHookOptions {
|
|
6
6
|
/** Component names treated as meta sources (design §11 layer 4). Mirrors the plugin option. */
|
|
7
7
|
metaComponents?: string[];
|
|
8
|
-
/** Per-rule overrides keyed by rule id, e.g. `{
|
|
8
|
+
/** Per-rule overrides keyed by rule id, e.g. `{ 'seo/json-ld': 'off' }`. Mirrors the plugin option. */
|
|
9
9
|
rules?: Record<string, RuleSetting>;
|
|
10
10
|
}
|
|
11
11
|
|
package/dist/hooks/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
isLoopbackHost,
|
|
3
3
|
isLoopbackOrigin,
|
|
4
4
|
parseHtmlHead
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HURGA7UH.js";
|
|
6
6
|
|
|
7
7
|
// src/plugin.ts
|
|
8
8
|
import { existsSync } from "fs";
|
|
9
9
|
import { writeFile, mkdir } from "fs/promises";
|
|
10
|
-
import { join as join4, isAbsolute, dirname, relative as
|
|
10
|
+
import { join as join4, isAbsolute, dirname, relative as relative3, basename, sep as sep2 } from "path";
|
|
11
11
|
import { defineConfig as defineConfig2 } from "@svelte-vitals/core";
|
|
12
12
|
import { loadConfigFile as loadConfigFile2 } from "svelte-vitals";
|
|
13
13
|
|
|
@@ -151,7 +151,7 @@ function readCoreVersion() {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/analyze.ts
|
|
154
|
-
async function analyze(prerenderPagesDir, cwd, options) {
|
|
154
|
+
async function analyze(prerenderPagesDir, cwd, options, extraProjectFacts) {
|
|
155
155
|
const loaded = await loadConfigFile(cwd);
|
|
156
156
|
const fileConfig = loaded?.config;
|
|
157
157
|
const warnings = loaded?.warnings ?? [];
|
|
@@ -166,7 +166,10 @@ async function analyze(prerenderPagesDir, cwd, options) {
|
|
|
166
166
|
...overrides !== void 0 ? { overrides } : {}
|
|
167
167
|
});
|
|
168
168
|
const { heads, headings, images, htmlLang } = await collectRenderedHeads(prerenderPagesDir);
|
|
169
|
-
const project =
|
|
169
|
+
const project = {
|
|
170
|
+
...await collectRenderedProject(cwd, htmlLang),
|
|
171
|
+
...extraProjectFacts
|
|
172
|
+
};
|
|
170
173
|
const components = await collectComponentFacts(cwd);
|
|
171
174
|
const kitModules = await collectKitModuleFacts(cwd);
|
|
172
175
|
const results = applyOverrides(
|
|
@@ -204,6 +207,23 @@ Scanned ${components.length} component(s) under src/ for Correctness/Security/Ar
|
|
|
204
207
|
};
|
|
205
208
|
}
|
|
206
209
|
|
|
210
|
+
// src/minify-flag.ts
|
|
211
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
212
|
+
import { relative } from "path";
|
|
213
|
+
import { findMinifyDisabled } from "@svelte-vitals/core";
|
|
214
|
+
async function resolveMinifyDisabled(minify, configFile, root) {
|
|
215
|
+
if (minify !== false) return void 0;
|
|
216
|
+
if (!configFile) return {};
|
|
217
|
+
const rel = relative(root, configFile).split("\\").join("/");
|
|
218
|
+
const file = rel === "" ? configFile.split("\\").join("/") : rel;
|
|
219
|
+
let line;
|
|
220
|
+
try {
|
|
221
|
+
line = findMinifyDisabled(await readFile4(configFile, "utf8"))?.line;
|
|
222
|
+
} catch {
|
|
223
|
+
}
|
|
224
|
+
return { file, ...line !== void 0 ? { line } : {} };
|
|
225
|
+
}
|
|
226
|
+
|
|
207
227
|
// src/ui/middleware.ts
|
|
208
228
|
import { renderAppShell } from "@svelte-vitals/core";
|
|
209
229
|
|
|
@@ -396,7 +416,7 @@ function createStore() {
|
|
|
396
416
|
}
|
|
397
417
|
|
|
398
418
|
// src/ui/analysis.ts
|
|
399
|
-
import { relative, sep } from "path";
|
|
419
|
+
import { relative as relative2, sep } from "path";
|
|
400
420
|
function createAnalysisRunner(opts) {
|
|
401
421
|
const debounceMs = opts.debounceMs ?? 500;
|
|
402
422
|
let cachedAnalyze = opts.analyze;
|
|
@@ -445,7 +465,7 @@ function createAnalysisRunner(opts) {
|
|
|
445
465
|
},
|
|
446
466
|
notifyChange(file) {
|
|
447
467
|
if (stopped) return;
|
|
448
|
-
const rel =
|
|
468
|
+
const rel = relative2(opts.root, file).split(sep).join("/");
|
|
449
469
|
parseCache.delete(rel);
|
|
450
470
|
if (timer !== void 0) clearTimeout(timer);
|
|
451
471
|
timer = setTimeout(() => {
|
|
@@ -472,11 +492,17 @@ var CONFIG_BASENAMES = /* @__PURE__ */ new Set([
|
|
|
472
492
|
"svelte.config.ts",
|
|
473
493
|
"svelte-vitals.config.mjs",
|
|
474
494
|
"svelte-vitals.config.js",
|
|
475
|
-
"svelte-vitals.config.ts"
|
|
495
|
+
"svelte-vitals.config.ts",
|
|
496
|
+
"vite.config.js",
|
|
497
|
+
"vite.config.mjs",
|
|
498
|
+
"vite.config.ts",
|
|
499
|
+
"vite.config.cjs",
|
|
500
|
+
"vite.config.mts",
|
|
501
|
+
"vite.config.cts"
|
|
476
502
|
]);
|
|
477
503
|
var IGNORED_SEGMENTS = /* @__PURE__ */ new Set(["node_modules", ".svelte-kit", "build", "dist"]);
|
|
478
504
|
function isRelevant(file, root) {
|
|
479
|
-
const rel =
|
|
505
|
+
const rel = relative3(root, file);
|
|
480
506
|
if (rel === "" || rel.startsWith("..")) return false;
|
|
481
507
|
const segments = rel.split(sep2);
|
|
482
508
|
if (segments.some((s) => IGNORED_SEGMENTS.has(s))) return false;
|
|
@@ -486,12 +512,14 @@ function isRelevant(file, root) {
|
|
|
486
512
|
var DEFAULT_PRERENDER_DIR = ".svelte-kit/output/prerendered/pages";
|
|
487
513
|
function svelteVitals(options = {}) {
|
|
488
514
|
let root = options.cwd ?? process.cwd();
|
|
515
|
+
let minifyFlag;
|
|
489
516
|
const buildPlugin = {
|
|
490
517
|
name: "svelte-vitals",
|
|
491
518
|
apply: "build",
|
|
492
519
|
enforce: "post",
|
|
493
520
|
configResolved(config) {
|
|
494
521
|
if (!options.cwd) root = config.root;
|
|
522
|
+
if (!config.build.ssr) minifyFlag = { minify: config.build.minify, configFile: config.configFile };
|
|
495
523
|
},
|
|
496
524
|
async closeBundle() {
|
|
497
525
|
const pagesDir = options.prerenderDir ? options.prerenderDir : join4(root, DEFAULT_PRERENDER_DIR);
|
|
@@ -499,7 +527,8 @@ function svelteVitals(options = {}) {
|
|
|
499
527
|
if (!existsSync(resolved)) return;
|
|
500
528
|
let result;
|
|
501
529
|
try {
|
|
502
|
-
|
|
530
|
+
const viteMinifyDisabled = minifyFlag ? await resolveMinifyDisabled(minifyFlag.minify, minifyFlag.configFile, root) : void 0;
|
|
531
|
+
result = await analyze(resolved, root, options, viteMinifyDisabled ? { viteMinifyDisabled } : void 0);
|
|
503
532
|
} catch (err) {
|
|
504
533
|
console.warn(`svelte-vitals: skipped \u2014 analysis failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
505
534
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-vitals/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,12 +42,12 @@
|
|
|
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.
|
|
46
|
-
"svelte-vitals": "0.
|
|
45
|
+
"@svelte-vitals/core": "0.28.0",
|
|
46
|
+
"svelte-vitals": "0.31.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@sveltejs/kit": "^2.
|
|
50
|
-
"vite": "^8.1.
|
|
49
|
+
"@sveltejs/kit": "^2.70.1",
|
|
50
|
+
"vite": "^8.1.5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@sveltejs/kit": {
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@sveltejs/kit": "^2.
|
|
58
|
+
"@sveltejs/kit": "^2.70.1",
|
|
59
59
|
"@types/node": "^24.13.3",
|
|
60
60
|
"jsdom": "^29.1.1",
|
|
61
|
-
"svelte": "^5.56.
|
|
62
|
-
"vite": "^8.1.
|
|
61
|
+
"svelte": "^5.56.6",
|
|
62
|
+
"vite": "^8.1.5"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup",
|