Skip to content

Commit

Permalink
feat: advance getShiki and and timelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalYoung committed Mar 1, 2025
1 parent a4d917b commit adb55a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dumi/theme/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async function getShiki() {

class DTReactTech extends ReactTechStack {
async generateMetadata(asset: ExampleBlockAsset) {
console.time(asset.id);
// workaround for esm module
const [
{ transformerTwoslash },
Expand All @@ -72,6 +73,7 @@ class DTReactTech extends ReactTechStack {
};
Object.entries(asset.dependencies).map(([filename, dep]) => {
if (dep.type === 'FILE') {
console.time(`${asset.id}--${filename}`);
const html = codeToHtml(dep.value, {
lang: 'tsx',
theme: 'vitesse-light',
Expand All @@ -96,14 +98,18 @@ class DTReactTech extends ReactTechStack {
}),
],
});
console.timeEnd(`${asset.id}--${filename}`);
asset.dependencies[filename] = <any>{ ...dep, jsx: html };
}
});
console.timeEnd(asset.id);
return asset;
}
}

const AssetsPlugin = async (api: IApi) => {
// 提前先创建 highlighterCore
getShiki();
api.registerTechStack(() => new DTReactTech());

// TODO: 应该在 umi 退出的时候销毁,包括 catch 退出
Expand Down

0 comments on commit adb55a4

Please sign in to comment.