Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fix-prettier-dynamic-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@adobe/spectrum-tokens": patch
---

Use dynamic import for prettier in writeJson so the package loads without prettier
when used outside the monorepo (e.g. spectrum-design-data-mcp via npx).
2 changes: 1 addition & 1 deletion packages/tokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { basename, resolve } from "path";
import { readFile } from "fs/promises";
import * as url from "url";
import { writeFile } from "fs/promises";
import { format } from "prettier";

export const __dirname = url.fileURLToPath(new URL(".", import.meta.url));

Expand All @@ -28,6 +27,7 @@ export const readJson = async (fileName) =>
JSON.parse(await readFile(fileName, "utf8"));

export const writeJson = async (fileName, jsonData) => {
const { format } = await import("prettier");
await writeFile(
fileName,
await format(JSON.stringify(jsonData), { parser: "json-stringify" }),
Expand Down