Repository navigation
Port JavaScript sources when their extensions are configured - #1
Merged
Merged
Conversation
A new `extensions` key (default ["ts", "tsx"]) lists the source extensions in the graph. With js/mjs/cjs/jsx added, those files are discovered under roots, parsed with the TypeScript (or TSX) grammar, resolved by their own names after TypeScript candidates, and mapped to Rust files without the extension. Also exit quietly when stdout closes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Problem and intent
rustify only sees
.ts/.tsx. Projects with plain JavaScript modules, such as astroshots, whoseastroshotCLI isbin/*.mjs, can't track those files in the port, so the CLI would be ported outside the graph, index, and ratchet.Goal: let a project opt JavaScript files into the graph and port them exactly like TypeScript.
What changed
extensionskey inrustify.toml, default["ts", "tsx"]. Existing configs behave as before.js/mjs/cjs/jsxadded:roots(.d.tsanddist/are still never sources).jsxuses TSX)./x.mjsresolves tox.ts/x.tsxfirst, thenx.mjs. Bare imports also try.js/.mjs/.cjs/.jsxandindex.*. Candidates whose extension isn't configured are ignored.bin/cli.mjsbecomesbin/cli.rs.jsxas a component.rustify graph | headno longer prints a broken-pipe panic.configuration.md,workflow.md, the README, and the examplerustify.toml.Scope: CLI only. Risk: low, because the default leaves current behavior unchanged. No user impact unless
extensionsis set.Testing
tests/porting_workflow.rs::ports_javascript_modules_when_their_extensions_are_configured. It runs the real binary against a temporary git repository with a.mjsCLI that imports another.mjsfile and a TS module:mjsconfigured, all three files are in the graph and the brief mapsbin/cli.mjstobin/cli.rs/cli::bin::cli.mjstest is foundstartanddonerecord the symbol mappackages::tests::a_javascript_import_falls_back_to_the_javascript_file_after_typescript, plus the existing candidate test, which now also asserts thatdist/never becomes a source.cargo test(21 unit + 16 e2e),clippy -D warnings, andfmt --checkall pass locally. CI runs them in therustifyworkflow on this PR.🤖 Generated with Claude Code