svelte-vitals 0.5.0 → 0.5.2

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 CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  > **A SvelteKit SEO checker — not a runtime Web Vitals reporter.**
7
7
  > Diagnose your project's SEO health by statically analyzing your source code, before it ships. No browser, no build server, no headless Chrome.
8
+ >
9
+ > **ESM-only** (Node 18+). Ships ES modules only; `require()` is unsupported by design.
8
10
 
9
11
  ```bash
10
12
  npx svelte-vitals
package/dist/bin.js CHANGED
@@ -6,10 +6,71 @@ import {
6
6
  knownRuleIds,
7
7
  readPackageVersion,
8
8
  run
9
- } from "./chunk-RI6LBHFR.js";
9
+ } from "./chunk-LQPB2WAL.js";
10
10
 
11
11
  // src/bin.ts
12
12
  import mri from "mri";
13
+
14
+ // src/resolve-args.ts
15
+ var toList = (v) => typeof v === "string" ? v.split(",").map((s) => s.trim()).filter(Boolean) : [];
16
+ function resolveArgs(argv) {
17
+ const warnings = [];
18
+ const errors = [];
19
+ const positional = argv._[0];
20
+ const metaComponents = typeof argv["meta-components"] === "string" ? argv["meta-components"].split(",").map((s) => s.trim()).filter(Boolean) : void 0;
21
+ const treatRaw = argv["treat-dynamic-as"];
22
+ const treatDynamicAs = treatRaw === "warn" || treatRaw === "fail" || treatRaw === "pass" ? treatRaw : void 0;
23
+ if (typeof treatRaw === "string" && treatDynamicAs === void 0) {
24
+ warnings.push(
25
+ `svelte-vitals: unknown --treat-dynamic-as '${treatRaw}'; expected pass|warn|fail. Defaulting to 'pass'.`
26
+ );
27
+ }
28
+ const route = typeof argv.route === "string" ? argv.route : void 0;
29
+ const allow = toList(argv.rules);
30
+ const ignore = toList(argv.ignore);
31
+ const unknown = findUnknownRuleIds([...allow, ...ignore]);
32
+ if (unknown.length > 0) {
33
+ errors.push(`svelte-vitals: unknown rule id(s) in --rules/--ignore: ${unknown.join(", ")}`);
34
+ errors.push(`Known rule ids: ${knownRuleIds().join(", ")}`);
35
+ }
36
+ let reporter;
37
+ if (argv.json) {
38
+ reporter = "json";
39
+ } else if (typeof argv.reporter === "string") {
40
+ if (!isReporterName(argv.reporter)) {
41
+ errors.push(
42
+ `svelte-vitals: unknown reporter '${argv.reporter}'. Valid values: console, json, agent, sarif, github.`
43
+ );
44
+ } else {
45
+ reporter = argv.reporter;
46
+ }
47
+ }
48
+ const failOnRaw = argv["fail-on"];
49
+ const failOnValid = failOnRaw === "warning" || failOnRaw === "info" || failOnRaw === "critical";
50
+ if (typeof failOnRaw === "string" && !failOnValid) {
51
+ warnings.push(
52
+ `svelte-vitals: unknown --fail-on '${failOnRaw}'; expected critical|warning|info. No threshold applied.`
53
+ );
54
+ }
55
+ const failOn = argv["fail-on-warning"] ? "warning" : failOnValid ? failOnRaw : void 0;
56
+ if (errors.length > 0) return { options: null, warnings, errors };
57
+ return {
58
+ options: {
59
+ cwd: positional ?? process.cwd(),
60
+ metaComponents,
61
+ treatDynamicAs,
62
+ route,
63
+ reporter,
64
+ byRoute: Boolean(argv["by-route"]),
65
+ failOn,
66
+ rules: buildRulesConfig(allow, ignore)
67
+ },
68
+ warnings,
69
+ errors
70
+ };
71
+ }
72
+
73
+ // src/bin.ts
13
74
  var HELP = `svelte-vitals \u2014 a SvelteKit SEO checker (static mode)
14
75
 
15
76
  Usage:
@@ -48,44 +109,11 @@ async function main() {
48
109
  console.log(VERSION);
49
110
  process.exit(0);
50
111
  }
51
- const positional = argv._[0];
52
- const metaComponents = typeof argv["meta-components"] === "string" ? argv["meta-components"].split(",").map((s) => s.trim()).filter(Boolean) : void 0;
53
- const treatRaw = argv["treat-dynamic-as"];
54
- const treatDynamicAs = treatRaw === "warn" || treatRaw === "fail" || treatRaw === "pass" ? treatRaw : void 0;
55
- const route = typeof argv.route === "string" ? argv.route : void 0;
56
- const toList = (v) => typeof v === "string" ? v.split(",").map((s) => s.trim()).filter(Boolean) : [];
57
- const allow = toList(argv.rules);
58
- const ignore = toList(argv.ignore);
59
- const unknown = findUnknownRuleIds([...allow, ...ignore]);
60
- if (unknown.length > 0) {
61
- console.error(`svelte-vitals: unknown rule id(s) in --rules/--ignore: ${unknown.join(", ")}`);
62
- console.error(`Known rule ids: ${knownRuleIds().join(", ")}`);
63
- process.exit(2);
64
- }
65
- let reporter;
66
- if (argv.json) {
67
- reporter = "json";
68
- } else if (typeof argv.reporter === "string") {
69
- if (!isReporterName(argv.reporter)) {
70
- console.error(
71
- `svelte-vitals: unknown reporter '${argv.reporter}'. Valid values: console, json, agent, sarif, github.`
72
- );
73
- process.exit(2);
74
- }
75
- reporter = argv.reporter;
76
- }
77
- const failOnRaw = argv["fail-on"];
78
- const failOn = argv["fail-on-warning"] ? "warning" : failOnRaw === "warning" || failOnRaw === "info" || failOnRaw === "critical" ? failOnRaw : void 0;
79
- const code = await run({
80
- cwd: positional ?? process.cwd(),
81
- metaComponents,
82
- treatDynamicAs,
83
- route,
84
- reporter,
85
- byRoute: Boolean(argv["by-route"]),
86
- failOn,
87
- rules: buildRulesConfig(allow, ignore)
88
- });
112
+ const { options, warnings, errors } = resolveArgs(argv);
113
+ for (const w of warnings) console.error(w);
114
+ for (const e of errors) console.error(e);
115
+ if (!options) process.exit(2);
116
+ const code = await run(options);
89
117
  process.exit(code);
90
118
  }
91
119
  void main();
@@ -114,7 +114,7 @@ function addImportsFromProgram(program, map) {
114
114
  if (spec.type === "ImportDefaultSpecifier") {
115
115
  map.set(local, { source, imported: "default" });
116
116
  } else if (spec.type === "ImportSpecifier") {
117
- map.set(local, { source, imported: spec.imported?.name ?? local });
117
+ map.set(local, { source, imported: spec.imported?.name ?? spec.imported?.value ?? local });
118
118
  }
119
119
  }
120
120
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  knownRuleIds,
7
7
  routeMatcher,
8
8
  run
9
- } from "./chunk-RI6LBHFR.js";
9
+ } from "./chunk-LQPB2WAL.js";
10
10
  export {
11
11
  ProjectError,
12
12
  analyzeProject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "A SvelteKit SEO checker — not a runtime Web Vitals reporter. Static analysis of your routes' head metadata.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -22,6 +22,10 @@
22
22
  "url": "https://github.com/oekazuma/svelte-vitals/issues"
23
23
  },
24
24
  "homepage": "https://github.com/oekazuma/svelte-vitals#readme",
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "sideEffects": false,
25
29
  "bin": {
26
30
  "svelte-vitals": "./dist/bin.js"
27
31
  },
@@ -38,7 +42,7 @@
38
42
  "mri": "^1.2.0",
39
43
  "svelte": "^5.56.3",
40
44
  "tinyglobby": "^0.2.17",
41
- "@svelte-vitals/core": "0.6.0"
45
+ "@svelte-vitals/core": "0.7.0"
42
46
  },
43
47
  "devDependencies": {
44
48
  "@types/node": "^24.7.0"