Skip to content

Commit d5882d5

Browse files
committed
fix: small optimization for initial load time of guide command
Try to load just the madwizard/cli, rather than all of madwizard (which loads lots of stuff we don't need for the initial execution in headless mode). It's possible that webpack has already optimized this away, but it's a small enough change... This PR also updates the Guide.tsx component to avoid calling an internal API of madwizard/Parser
1 parent 9611d1c commit d5882d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

plugins/plugin-madwizard/src/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { Arguments, ParsedOptions, ReactResponse, Registrar, Tab } from "@kui-shell/core"
18-
import { setTabReadonly } from "./util"
1918

2019
interface Options extends ParsedOptions {
2120
u: boolean
@@ -32,13 +31,14 @@ function withFilepath(
3231
return async ({ tab, argvNoOptions, parsedOptions }: Arguments<Options>) => {
3332
if (!parsedOptions.u) {
3433
// CLI path
35-
const { CLI } = await import("madwizard")
36-
await CLI.cli(["madwizard", task, ...argvNoOptions.slice(1)], undefined, { store: process.env.GUIDEBOOK_STORE })
34+
const { cli } = await import("madwizard/dist/fe/cli/index.js")
35+
await cli(["madwizard", task, ...argvNoOptions.slice(1)], undefined, { store: process.env.GUIDEBOOK_STORE })
3736
return true
3837
}
3938

4039
// UI path
4140
if (readonly) {
41+
const { setTabReadonly } = await import("./util")
4242
setTabReadonly({ tab })
4343
}
4444
return {

plugins/plugin-madwizard/src/read.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
export default async function read(filepath: string) {
1818
const { Parser, reader } = await import("madwizard")
19-
return Parser.blockify(filepath, await reader(), undefined, undefined, { store: process.env.GUIDEBOOK_STORE })
19+
return Parser.parse(filepath, await reader(), undefined, undefined, { store: process.env.GUIDEBOOK_STORE })
2020
}

0 commit comments

Comments
 (0)