You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(typescript): expose latest Program to transformers in watch mode (#1923)
* feat(typescript): expose latest Program to transformers in watch mode\n\n- Add optional getProgram to ProgramTransformerFactory.factory\n- Pass getProgram() to program-scoped transformer factories\n- Recompute custom transformers after each TS watch rebuild\n- Docs: document getProgram and watch-mode behavior\n- Test: ensure factories are recreated and getProgram returns the latest Program * test(typescript): close bundle in new watch-mode transformer test; refactor customTransformers for clearer lazy initialization * test(typescript): add watch-mode test for typeChecker factories; tidy emitted-file cleanup in program test * fix(typescript): replace runtime undefined with void 0 in new code\n\n- watchProgram: use void 0 when resetting cached transformers in watch mode\n- tests: use void 0 in new watch-mode transformer test to satisfy no-undefined\n\nRefs PR #1923 review feedback from @shellscape * feat(typescript): add `recreateTransformersOnRebuild` option; default to legacy watch behavior\n\n- Gate watch-mode transformer recreation behind new option (default false)\n- Plumb option through plugin options -> watch host\n- Types/README: document option and clarify `getProgram` semantics\n- Tests: enable option for watch-mode freshness tests * test(typescript): add legacy-behavior regression and format via ESLint * docs(typescript): clarify getProgram getter semantics; fix typos in README (its/TypeScript factory, below) * fix(typescript): strict boolean normalization for recreateTransformersOnRebuild\n\nUse === true instead of Boolean(...) to avoid enabling the option for truthy strings in JS configs. Refs PR #1923 review by @shellscape. --------- Co-authored-by: CharlieHelps <charlie@charlielabs.ai>
By default (legacy behavior), this plugin reuses the same custom transformer factories for the lifetime of a watch session. Advanced users can opt into recreating factories on every TypeScript rebuild by enabling the `recreateTransformersOnRebuild` option. When enabled, both `program`- and `typeChecker`-based factories are rebuilt per watch cycle, and `getProgram()` (when used) reflects the latest Program across rebuilds.
264
+
265
+
### `recreateTransformersOnRebuild`
266
+
267
+
Type: `Boolean`<br>
268
+
Default: `false` (legacy behavior)
269
+
270
+
When `true`, the plugin recreates custom transformer factories on each TypeScript watch rebuild. This ensures factories capture the current `Program`/`TypeChecker` per cycle and that the optional `getProgram()` getter provided to `program`-based factories reflects the latest `Program` across rebuilds. Most users do not need this; enable it if your transformers depend on up‑to‑date Program/TypeChecker identities.
271
+
272
+
```js
273
+
// Opt-in to per-rebuild transformer recreation in watch mode
0 commit comments