diff --git a/src/scripts/pinyinify.ts b/src/scripts/pinyinify.ts index e2a6ba9..5481f1a 100644 --- a/src/scripts/pinyinify.ts +++ b/src/scripts/pinyinify.ts @@ -2,16 +2,18 @@ import { readFileSync, readdirSync, writeFileSync } from "fs" import { pinyin } from "pinyin" function pinyinify(name: string) { - // we are using pinyin2, the return value of pinyin() is an array of arrays - const fullPinyin = pinyin(name, { - heteronym: true, - style: pinyin.STYLE_NORMAL, - }) - const partialPinyin = pinyin(name, { - heteronym: true, - style: pinyin.STYLE_FIRST_LETTER, - }) - return [fullPinyin.join(""), partialPinyin.join("")] + return [ + pinyin(name, { + compact: true, + heteronym: true, + style: pinyin.STYLE_NORMAL, + }), + pinyin(name, { + compact: true, + heteronym: true, + style: pinyin.STYLE_FIRST_LETTER, + }), + ].flatMap(py => py.map(el => el.join(""))) } function addAliasToSchema(json: any) { diff --git a/tsconfig.json b/tsconfig.json index a7fc6fb..f1ebb79 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "skipLibCheck": true, /* Bundler mode */ - "moduleResolution": "bundler", + "moduleResolution": "node", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, @@ -18,7 +18,9 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true }, "include": ["src"], "references": [{ "path": "./tsconfig.node.json" }]