Skip to content

Commit

Permalink
feat(perf): wrap json data with JSON.parse to speed up rebundling (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Sep 19, 2024
1 parent dca6a48 commit bbfceee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/shiki/scripts/prepare/langs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function prepareLangs() {
`${COMMENT_HEAD}
${deps.map(i => `import ${i.replace(/\W/g, '_')} from './${i}'`).join('\n')}
const lang = Object.freeze(${JSON.stringify(json)})
const lang = Object.freeze(JSON.parse(${JSON.stringify(JSON.stringify(json))}))
export default [
${[
Expand Down
2 changes: 1 addition & 1 deletion packages/shiki/scripts/prepare/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function prepareTheme(): Promise<void> {
await fs.writeFile(
`./src/assets/themes/${t.name}.js`,
`${COMMENT_HEAD}
export default Object.freeze(${JSON.stringify(theme, null, 2)})
export default Object.freeze(JSON.parse(${JSON.stringify(JSON.stringify(theme))}))
`,
'utf-8',
)
Expand Down

0 comments on commit bbfceee

Please sign in to comment.