Skip to content

Commit e91231e

Browse files
authored
refactor: migrate data.ts to be json file (#2)
This would significantly reduce the bundle size.
1 parent e8d76d7 commit e91231e

File tree

5 files changed

+10
-25270
lines changed

5 files changed

+10
-25270
lines changed

data/macro.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"scripts": {
2626
"build": "yarn tsup --minify",
2727
"dev": "yarn tsup --sourcemap",
28-
"tsup": "tsup src/index.ts --dts --format cjs,esm --clean",
29-
"fetch-data": "tsx scripts/fetch-data.ts && prettier --write src/data.ts",
28+
"tsup": "tsup src/index.ts --dts --format cjs,esm --clean --loader \".json=file\"",
29+
"fetch-data": "tsx scripts/fetch-data.ts",
3030
"test": "yarn test:text",
3131
"test:text": "nyc --reporter=text mocha ./__tests__",
3232
"test:html": "nyc --reporter=html mocha ./__tests__",

scripts/fetch-data.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ export class Updater {
1919

2020
const allMacros: MacrosData = Object.assign(macros, cnMacros, koMacros)
2121

22-
const dataFile = path.resolve(__dirname, '../src/data.ts')
23-
let data =
24-
"import { MacrosData } from './utils'\n\n" +
25-
'const data: MacrosData = ' +
26-
JSON.stringify(allMacros, null, 2) +
27-
'\n\nexport default data\n'
28-
await writeFile(dataFile, data, 'utf8')
22+
const dataFile = path.resolve(__dirname, '../data/macro.json')
23+
24+
await writeFile(dataFile, JSON.stringify(allMacros), 'utf8')
2925
}
3026

3127
async fetchXivapi<T>(url: string, columns: string[]): Promise<T[]> {

0 commit comments

Comments
 (0)