feat(fmt): prototype dprint-npm + in-process WASM backends for deno fmt#34682
Draft
bartlomieju wants to merge 1 commit into
Draft
feat(fmt): prototype dprint-npm + in-process WASM backends for deno fmt#34682bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
Behind the DENO_FMT_DPRINT env var, add two prototype backends for `deno fmt` that use the pinned dprint npm package + WASM plugins instead of the in-process dprint plugin crates: - DENO_FMT_DPRINT=1 (cli): shell out to the pinned dprint CLI npm package. - DENO_FMT_DPRINT=wasm: run the dprint WASM plugins in-process by embedding a MainWorker (like deno lint's plugin host) and loading the plugins via @dprint/formatter from pinned @dprint/* npm packages. No subprocess. Both reuse Deno's file discovery and map the full deno.json fmt option set onto generated dprint config. The default in-process formatter is unchanged. Adds a spec test (tests/specs/fmt/dprint_npm_parity) that runs the same `fmt --check` under all three backends via the variants matrix.
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.
Prototype exploring a different model for
deno fmt: instead of compilingthe dprint formatter plugins into the binary as native Rust crates, drive
formatting through the pinned
dprintnpm package and its WASM plugins,with a default version and plugin set pinned in the binary. This decouples
the formatters from the core binary so they can be versioned and updated
independently.
Everything is gated behind the
DENO_FMT_DPRINTenvironment variable, sothe existing in-process formatter remains the default and is untouched. Two
backends are implemented for comparison.
DENO_FMT_DPRINT=1shells out tothe pinned
dprintCLI npm package.DENO_FMT_DPRINT=wasmruns the dprintWASM plugins in the same process by embedding a
MainWorker(the samepattern
deno lintuses for its plugin host) and loading the plugins via@dprint/formatterfrom pinned@dprint/*npm packages, so V8 executes theWASM with no subprocess. Both backends reuse Deno's own file discovery and
map the full
deno.jsonfmtoption set onto generated dprint config, andproduce byte-identical output to the current formatter (SQL aside, which
uses a different underlying formatter).
A spec test under
tests/specs/fmt/dprint_npm_parityruns the samefmt --checkacross all three code paths via thevariantsmatrix. Notethe two dprint variants fetch packages/plugins from the network and so are
not hermetic yet; vendoring the
@dprint/*packages and g-plane plugin WASMinto the test registry would fix that. Draft, work in progress.