🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@kjanat/dprint-plugin-sortpackagejson

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kjanat/dprint-plugin-sortpackagejson

Wasm module for dprint-plugin-sortpackagejson.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

@kjanat/dprint-plugin-sortpackagejson

npm distribution of dprint-plugin-sortpackagejson, which is an adaptation of the sort-package-json npm package.

Install

npm install @dprint/formatter @kjanat/dprint-plugin-sortpackagejson

Or install straight from dprint:

dprint add kjanat/sortpackagejson

Use it in dprint.json like this:

{
  "plugins": [
    "./node_modules/@kjanat/dprint-plugin-sortpackagejson/plugin.wasm",
  ],
  "sortPackageJson": {},
}

Usage

Programmatic consumers can resolve the wasm path in a few ways.

With @dprint/formatter:

import { readFileSync } from "node:fs";
import { createFromBuffer } from "@dprint/formatter";
import { getPath } from "@kjanat/dprint-plugin-sortpackagejson";

const formatter = createFromBuffer(readFileSync(getPath()));

const formattedText = formatter.formatText({
  filePath: "package.json",
  fileText: '{"name":"test","version":"1.0.0"}',
});

console.log(formattedText);

Or resolve the wasm module directly with import.meta.resolve:

import { createFromWasmModule } from "@dprint/formatter";
import { file, fileURLToPath } from "bun";

const wasmModule = await WebAssembly.compile(
  await file(
    fileURLToPath(
      import.meta.resolve("@kjanat/dprint-plugin-sortpackagejson/wasm"),
    ),
  ).arrayBuffer(),
);
const formatter = createFromWasmModule(wasmModule);

And streaming is also supported:

import { createStreaming } from "@dprint/formatter";

const formatter = await createStreaming(
  fetch(import.meta.resolve("@kjanat/dprint-plugin-sortpackagejson/wasm")),
);

Keywords

package.json

FAQs

Package last updated on 29 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts