[RL-67] Emit type sidecars during builds (Milestone 2) - #43
Merged
Conversation
Add an opt-in `types` option (default off) on every surface: the webpack loader, the vite/rollup/esbuild/bun plugins, and the Next helper. When set, the build also writes the `<name>.d.rs.ts` sidecar, reusing the wasm-pack run it already does - wasm-bindgen's typings are kept instead of dropped, and the generated `.d.ts` is transformed into the sidecar. The module a consumer imports is byte-identical whether the option is on or off. - pack.js: `emitTypes` keeps the typings and writes the sidecar as a side effect - src/utils/writeSidecar.util.js: shared sidecar writer; generateTypes reuses it - index.js / shared-load / vite / rollup / esbuild / bun / next: the `types` option, default off - eslint: ignore generated `*.d.rs.ts` Refs: RL-67
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Milestone 2 of typed
.rsimports (RL-67): an opt-intypesoption (default off) that makes a normal build also write the<name>.d.rs.tssidecar, so types stay fresh fortsc/ESLint without running thegen-typesCLI. Opt-in (not default-on) so existing users see no new files in their source tree unless they ask.How
pack.js- the shared engine every surface calls gains anemitTypesflag. When set it keeps wasm-bindgen's typings in the build it already runs (no second wasm-pack run), transforms the generated.d.tswith the M1 engine, and writes the sidecar. The emission is a pure side effect: the module a consumer imports is byte-identical whether the option is on or off (asserted by a test).src/utils/writeSidecar.util.js- shared sidecar writer;generateTypes(M1) refactored to reuse it (DRY).types: booleanoption (default off) on the webpack loader, the vite/rollup/esbuild/bun plugins, and the Next helper, threaded down toemitTypes. The Next helper now spreads a shared{logLevel, types}object onto every webpack pass and turbopack rule.*.d.rs.ts(joins the existing generated-output ignores).Verified locally (GNU toolchain)
example/typed-imports: M1 fidelity suite + a new test proving the webpack build writes the sidecar withtypes: true.node-webpack3/3,esbuild3/3,rollup3/3.Scope
Milestone 2 of the epic. Remaining: the tsserver Language Service plugin (live editor types, no extension), classes/structs, docs.