@happyvertical/smrt-vitest 0.39.17 → 0.40.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/AGENTS.md +24 -0
- package/README.md +43 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -24,6 +24,30 @@ Without the plugin → "unregistered class" / "No field metadata found" errors.
|
|
|
24
24
|
4. Registers all classes in ObjectRegistry
|
|
25
25
|
5. Watch mode caveat: manifest only generated at startup — restart vitest after adding new classes/fields
|
|
26
26
|
|
|
27
|
+
## Vite 8 (rolldown/oxc) normalization (#2017)
|
|
28
|
+
|
|
29
|
+
The plugin's `config` hook normalizes three vite 8 behaviors so consumers
|
|
30
|
+
don't carry per-repo workarounds (evidence: anytown.ai#707,
|
|
31
|
+
willgriffin.dev#220):
|
|
32
|
+
|
|
33
|
+
1. `esbuild.tsconfigRaw` is ignored on vite 8 → injects
|
|
34
|
+
`oxc.decorator = { legacy: true, emitDecoratorMetadata: true }` (+ the
|
|
35
|
+
`oxc.tsconfig.compilerOptions` mirror) so `@smrt()` legacy decorators
|
|
36
|
+
still transform.
|
|
37
|
+
2. oxc elides type-position-only imports by default, silently dropping
|
|
38
|
+
side-effect model imports (SMRT object registration) in test files outside
|
|
39
|
+
the tsconfig `include` → injects
|
|
40
|
+
`oxc.typescript = { onlyRemoveTypeImports: true }`.
|
|
41
|
+
3. Rolldown prefix-matches string alias `find`s, mangling unaliased subpath
|
|
42
|
+
imports (`@org/pkg/sub` → `src/index.ts/sub`) → workspace aliases are
|
|
43
|
+
anchored exact-match RegExps; unaliased subpaths fall through to the
|
|
44
|
+
exports map. `aliasFilter` drops entries entirely.
|
|
45
|
+
|
|
46
|
+
Overrides: any `oxc` field the consumer sets is never injected
|
|
47
|
+
(`resolveOxcDefaults`); `oxc: false` suppresses everything. Keys are inert on
|
|
48
|
+
esbuild-based vite ≤ 7. Build-only vite configs that don't list the plugin
|
|
49
|
+
still need their own `oxc.decorator` on vite 8.
|
|
50
|
+
|
|
27
51
|
## CI retry (flaky-test resilience)
|
|
28
52
|
|
|
29
53
|
The plugin injects `test.retry` into every consuming package's config: **2 in CI
|
package/README.md
CHANGED
|
@@ -35,6 +35,49 @@ Without this plugin, tests fail with `"No field metadata found"` or `"unregister
|
|
|
35
35
|
| `packages` | `string[]` | `[]` | Additional packages beyond auto-discovered |
|
|
36
36
|
| `verbose` | `boolean` | `false` | Enable detailed logging |
|
|
37
37
|
| `root` | `string` | `process.cwd()` | Root directory |
|
|
38
|
+
| `setupFile` | `string` | package setup entry | Override the setup file injected into Vitest projects |
|
|
39
|
+
| `aliasFilter` | `(entry) => boolean` | keep all | Drop auto-generated workspace alias entries (receives the raw string `find` and `replacement`) |
|
|
40
|
+
|
|
41
|
+
### Vite 8 (rolldown/oxc) Normalization
|
|
42
|
+
|
|
43
|
+
Vite 8 replaced esbuild with rolldown/oxc, which changed three behaviors that
|
|
44
|
+
break SMRT projects. The plugin normalizes all three so consuming apps don't
|
|
45
|
+
need per-repo workarounds (evidence: anytown.ai#707, willgriffin.dev#220):
|
|
46
|
+
|
|
47
|
+
1. **`esbuild.tsconfigRaw` is ignored** — legacy `@smrt()` decorators reach
|
|
48
|
+
the bundle untransformed. The plugin injects
|
|
49
|
+
`oxc.decorator = { legacy: true, emitDecoratorMetadata: true }` (plus the
|
|
50
|
+
matching `oxc.tsconfig.compilerOptions` mirror).
|
|
51
|
+
2. **oxc elides type-position side-effect imports by default** — test files
|
|
52
|
+
usually sit outside the tsconfig `include`, so a repo-wide
|
|
53
|
+
`verbatimModuleSyntax` never reaches them and side-effect model imports
|
|
54
|
+
(SMRT object registration) are silently dropped. The plugin injects
|
|
55
|
+
`oxc.typescript = { onlyRemoveTypeImports: true }`.
|
|
56
|
+
3. **Rolldown prefix-matches string alias `find`s** — a bare workspace alias
|
|
57
|
+
like `@org/pkg` → `src/index.ts` mangles unaliased subpath imports
|
|
58
|
+
(`@org/pkg/sub` → `src/index.ts/sub`). Workspace aliases are emitted as
|
|
59
|
+
anchored exact-match RegExps, so unaliased subpaths fall through to the
|
|
60
|
+
package exports map; use `aliasFilter` to drop entries entirely.
|
|
61
|
+
|
|
62
|
+
> **Breaking change for direct `getWorkspaceViteAliases()` consumers:**
|
|
63
|
+
> each entry's `find` is now an anchored `RegExp`, not a `string` (the
|
|
64
|
+
> returned array is still ordered most-specific first, and the new second
|
|
65
|
+
> `options` parameter is optional). Code that used `find` as a string —
|
|
66
|
+
> e.g. a `Map` key or an equality filter — should match with
|
|
67
|
+
> `entry.find.test('<specifier>')` instead. Filters passed via
|
|
68
|
+
> `aliasFilter` (or the helper's `options.filter`) are unaffected: they
|
|
69
|
+
> receive the raw string `find` before anchoring. Plugin-only consumers
|
|
70
|
+
> need no changes.
|
|
71
|
+
|
|
72
|
+
All defaults are override-able: any `oxc` field you set in your own config is
|
|
73
|
+
never injected (explicit consumer values always win, and sibling fields still
|
|
74
|
+
deep-merge), and `oxc: false` suppresses injection entirely. The `oxc` keys
|
|
75
|
+
are inert on esbuild-based vite ≤ 7.
|
|
76
|
+
|
|
77
|
+
Note: the plugin only reaches configs that include it (vitest configs and any
|
|
78
|
+
vite config listing it in `plugins`). An app's separate build-only
|
|
79
|
+
`vite.config.ts` without the plugin still needs its own `oxc.decorator`
|
|
80
|
+
settings on vite 8.
|
|
38
81
|
|
|
39
82
|
### Watch Mode Note
|
|
40
83
|
|