fix: replace jsonc with jsonc-parser and cleanup build config
This commit is contained in:
1 parent
0bd2ac6707
commit
e867b675fc
12 files changed
+195
-216
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import JSON5 from "json5";
|
||||
import * as JSONC from "jsonc-parser";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
CLIENT_TRANSLATION_FILES,
|
||||
@@ -97,7 +97,7 @@ export const saveClientTranslations = adminAction(
|
||||
// intact. Falls back to a full re-serialization (which DOES drop comments)
|
||||
// only when an edited key cannot be located via the patch contract.
|
||||
const original: Record<string, string> = {};
|
||||
const parsed = JSON5.parse(raw);
|
||||
const parsed = JSONC.parse(raw);
|
||||
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
||||
for (const [k, v] of Object.entries(parsed)) {
|
||||
original[k] = v == null ? "" : String(v);
|
||||
@@ -116,7 +116,7 @@ export const saveClientTranslations = adminAction(
|
||||
// and warn the caller that comments were lost.
|
||||
await fs.writeFile(
|
||||
absPath,
|
||||
JSON5.stringify(ctx.data.data, null, 4),
|
||||
JSON.stringify(ctx.data.data, null, 4),
|
||||
"utf-8",
|
||||
);
|
||||
return actionOk({ commentsLost: true, unpatchedKeys });
|
||||
|
||||
Reference in new issue
Block a user