@rsvelte/compiler 0.7.13 → 0.7.16

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
@@ -1,86 +1,80 @@
1
- # rsvelte_lint
1
+ # @rsvelte/compiler
2
2
 
3
- A fast, native Svelte linter built directly on the [rsvelte](../../) compiler —
4
- no second ESTree parse, no Node.js in the hot path. See
5
- [`docs/svelte-lint-design.md`](../../docs/svelte-lint-design.md) for the full
6
- architecture & decision record.
3
+ A high-performance Rust implementation of the [Svelte](https://svelte.dev) 5
4
+ compiler, shipped as WebAssembly. Part of the
5
+ [rsvelte](https://github.com/baseballyama/rsvelte) project — a port of the
6
+ official Svelte compiler to Rust, aiming for byte-identical output and a large
7
+ speedup over the JavaScript compiler.
7
8
 
8
- It combines two diagnostic sources:
9
+ The whole compile pipeline — parse, analyze, transform — for client, SSR and
10
+ hydration, with output that matches the official compiler across the in-scope
11
+ test suite.
9
12
 
10
- 1. **Validator wrap** — the rsvelte compiler already emits ~70 warning codes,
11
- ~145 error codes, and 42 `a11y_*` rules during analysis. We surface those as
12
- lint diagnostics with near-zero rule code (the "single biggest lever").
13
- 2. **Native rule engine** — a single shared DFS over the template AST that
14
- dispatches to `Rule` hooks, porting the proven `vize_patina` structure.
13
+ > **⚠️ Early stage.** The API surface is stabilising. Output is verified
14
+ > byte-for-byte against the official compiler across the in-scope Svelte test
15
+ > suite, but treat this as experimental for production use.
15
16
 
16
- ## Try it
17
+ ## Install
17
18
 
18
19
  ```bash
19
- cargo run -p rsvelte_lint -- crates/rsvelte_lint/demo/Demo.svelte
20
+ npm install @rsvelte/compiler
21
+ # pnpm add @rsvelte/compiler
22
+ # yarn add @rsvelte/compiler
20
23
  ```
21
24
 
22
- See [`demo/README.md`](demo/README.md) for the expected output and the opt-in /
23
- autofix / SARIF variants.
25
+ The package is a `wasm-pack` (`--target web`) module — the WebAssembly binary
26
+ ships with the package, so it runs anywhere WebAssembly does (modern browsers,
27
+ Node.js, Deno, Bun) with no native binaries and no `optionalDependencies`.
24
28
 
25
29
  ## Usage
26
30
 
27
- ```bash
28
- cargo run -p rsvelte_lint -- src/ # lint a directory
29
- cargo run -p rsvelte_lint -- --fix src/ # autofix in place
30
- cargo run -p rsvelte_lint -- --format sarif src/ # SARIF for CI code-scanning
31
- cargo run -p rsvelte_lint -- --list-rules # list the native rules
32
- cargo run -p rsvelte_lint -- --print-eslint-config > eslint.rsvelte.json
33
- ```
31
+ ```js
32
+ import init, {
33
+ parse_svelte,
34
+ compile_client,
35
+ compile_server,
36
+ version,
37
+ } from '@rsvelte/compiler';
38
+
39
+ // Initialise the WebAssembly module once before calling any export.
40
+ await init();
41
+
42
+ const source = `<h1>Hello {name}</h1>`;
43
+
44
+ // Compile for the client.
45
+ const client = compile_client(source, 'App');
46
+ console.log(client.js); // generated JavaScript
47
+ console.log(client.css); // scoped styles
34
48
 
35
- Key flags: `--config <file>` (auto-discovers `rsvelte-lint.json` upward when
36
- omitted), `--config-from-eslint <eslint.config.js>` (import `svelte/*`
37
- severities), `--off`/`--error <rule>`, `--max-warnings <n>`. Output formats:
38
- `human`, `human-verbose`, `machine`, `machine-verbose`, `github-actions`,
39
- `sarif`. Exit codes follow ESLint conventions (non-zero on any error or when
40
- `--max-warnings` is exceeded).
41
-
42
- ## Config (`rsvelte-lint.json`)
43
-
44
- ```json
45
- {
46
- "extends": ["recommended"],
47
- "rules": {
48
- "svelte/no-at-html-tags": "error",
49
- "svelte/button-has-type": ["warn", { "submit": true, "reset": false }],
50
- "svelte/no-restricted-html-elements": ["error", { "elements": ["marquee"] }]
51
- },
52
- "files": ["src/**/*.svelte"],
53
- "ignores": ["**/generated/**"]
54
- }
49
+ // Compile for SSR.
50
+ const server = compile_server(source, 'App');
51
+
52
+ // Parse to the Svelte AST (JSON string, same shape the official parser produces).
53
+ const ast = JSON.parse(parse_svelte(source).ast);
54
+
55
+ console.log(version()); // the rsvelte compiler version
55
56
  ```
56
57
 
57
- A rule value is a severity scalar (`"off"`/`"warn"`/`"error"` or `0`/`1`/`2`) or
58
- a `[severity, ...options]` pair. `extends: ["none"]` starts from an empty
59
- baseline.
58
+ ## Why it is fast
60
59
 
61
- ## Coexisting with ESLint
60
+ - Written in Rust with a memory-efficient AST (`u32` spans, compact strings) and
61
+ direct phase-to-phase AST passing — no re-parsing between phases.
62
+ - Thread-safe, parallel parsing via [rayon](https://github.com/rayon-rs/rayon).
63
+ - Designed for integration into the [oxc](https://oxc.rs/) ecosystem.
62
64
 
63
- rsvelte-lint ships as a **complement** to ESLint, not (yet) a replacement. Run
64
- `--print-eslint-config` to generate a flat-config snippet that turns the
65
- native-owned `svelte/*` rules off in ESLint so each finding fires exactly once.
65
+ ## Related packages
66
66
 
67
- ## Native rules
67
+ - [`@rsvelte/svelte2tsx`](https://www.npmjs.com/package/@rsvelte/svelte2tsx) — `.svelte` → TSX for type-checking.
68
+ - [`@rsvelte/svelte-check`](https://www.npmjs.com/package/@rsvelte/svelte-check) — a drop-in `svelte-check`.
69
+ - [`@rsvelte/vite-plugin-svelte`](https://www.npmjs.com/package/@rsvelte/vite-plugin-svelte) — the Vite plugin, backed by the Rust compiler.
68
70
 
69
- Default-on (recommended): `no-at-html-tags`, `no-at-debug-tags` (autofix),
70
- `require-each-key`, `no-dupe-else-if-blocks`, `no-dupe-style-properties`,
71
- `no-object-in-text-mustaches`. Opt-in (off by default, matching
72
- eslint-plugin-svelte's `recommended: false`): `button-has-type`,
73
- `no-restricted-html-elements`. Each is a 1:1 port of the corresponding
74
- eslint-plugin-svelte rule and validated against that plugin's own fixtures by the
75
- compat oracle (`tests/eslint_plugin_oracle.rs`). Run `--list-rules` to see
76
- defaults.
71
+ ## License
77
72
 
78
- ## Testing
73
+ MIT
79
74
 
80
- ```bash
81
- cargo test -p rsvelte_lint
82
- cargo clippy -p rsvelte_lint --all-targets --all-features -- -D warnings
83
- ```
75
+ ---
84
76
 
85
- The compat oracle reads fixtures from the `eslint-plugin-svelte` reference
86
- submodule and skips automatically when it isn't checked out.
77
+ > **Maintainers:** `@rsvelte/compiler` is published from the wasm-pack output in
78
+ > the repo-root `pkg/` directory, not from this directory. See
79
+ > [`PUBLISHING.md`](./PUBLISHING.md) for how the version anchor and README
80
+ > overlay work.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rsvelte/compiler",
3
3
  "type": "module",
4
4
  "description": "Fast native Svelte linter built on the rsvelte compiler (validator wrap + native rule engine)",
5
- "version": "0.7.13",
5
+ "version": "0.7.16",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "rsvelte_lint_bg.wasm",
Binary file