Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/site-kit/src/lib/markdown/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
import path from 'node:path';
import ts from 'typescript';
import * as prettier from 'prettier';
import { SHIKI_LANGUAGE_MAP, escape, normalizeSlugify, smart_quotes, transform } from './utils';
import type { Declaration, TypeElement, Modules } from './index';

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

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

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

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

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

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

const single_line_name = (
await prettier_module.format(name ?? '', {
await prettier.format(name ?? '', {
printWidth: 1000,
parser: 'typescript',
semi: false,
Expand Down
Loading