Skip to content

Commit 9fd7b4a

Browse files
authored
eagerly import prettier (#283)
1 parent 5289503 commit 9fd7b4a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
33
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
44
import path from 'node:path';
55
import ts from 'typescript';
6+
import * as prettier from 'prettier';
67
import { SHIKI_LANGUAGE_MAP, escape, normalizeSlugify, smart_quotes, transform } from './utils';
78
import type { Declaration, TypeElement, Modules } from './index';
89

@@ -33,7 +34,6 @@ const METADATA_REGEX =
3334
const CACHE_MAP = new Map<string, string>();
3435

3536
let twoslash_module: typeof import('shiki-twoslash');
36-
let prettier_module: typeof import('prettier');
3737

3838
/**
3939
* A super markdown renderer function. Renders svelte and kit docs specific specific markdown code to html.
@@ -129,7 +129,6 @@ export async function render_content_markdown(
129129
}: RenderContentOptions = {}
130130
) {
131131
twoslash_module ??= await import('shiki-twoslash');
132-
prettier_module ??= await import('prettier');
133132

134133
const highlighter = await twoslash_module.createShikiHighlighter({ theme: 'css-variables' });
135134

@@ -478,7 +477,7 @@ export async function convert_to_ts(js_code: string, indent = '', offset = '') {
478477
code.appendLeft(insertion_point, offset + import_statements + '\n');
479478
}
480479

481-
let transformed = await prettier_module.format(code.toString(), {
480+
let transformed = await prettier.format(code.toString(), {
482481
printWidth: 100,
483482
parser: 'typescript',
484483
useTabs: true,
@@ -500,7 +499,7 @@ export async function convert_to_ts(js_code: string, indent = '', offset = '') {
500499
let name = type_text?.slice(1, -1); // remove { }
501500

502501
const single_line_name = (
503-
await prettier_module.format(name ?? '', {
502+
await prettier.format(name ?? '', {
504503
printWidth: 1000,
505504
parser: 'typescript',
506505
semi: false,

0 commit comments

Comments
 (0)