Plugins

Dprint is made up of Wasm and process plugins.

  • Wasm plugins are compiled to a .wasm file and run sandboxed.
  • Process plugins are compiled to an executable file and do not run sandboxed.

It would be ideal for all plugins to be Wasm plugins, but unfortunately many languages don't support compiling to a single .wasm file. Until then, process plugins exist.

The setup for both is the same except process plugins require a checksum to be specified to ensure the downloaded file is the same as what was built on the CI pipeline.

Wasm Plugins

Process Plugins

Using Wasm Plugins in the Browser, Deno, or Node.js

See https://github.com/dprint/js-formatter

Deno/Browser example:

// see current version at https://github.com/dprint/js-formatter/releases
import { createStreaming } from "https://deno.land/x/dprint@x.x.x/mod.ts";

const globalConfig = {
    indentWidth: 2,
    lineWidth: 80,
};
const tsFormatter = await createStreaming(
    fetch("https://plugins.dprint.dev/typescript-x.x.x.wasm"),
);

tsFormatter.setConfig(globalConfig, {
    semiColons: "asi",
});

// outputs: "const t = 5\n"
console.log(tsFormatter.formatText("file.ts", "const   t    = 5;"));