Skip to content

Commit b1533a0

Browse files
committed
feat: add preload api
1 parent 83d8d20 commit b1533a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/runtime/core/src/garfish.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { interfaces } from './interface';
2222
import { fetchStaticResources } from './utils';
2323
import { GarfishHMRPlugin } from './plugins/fixHMR';
2424
import { GarfishOptionsLife } from './plugins/lifecycle';
25-
import { GarfishPreloadPlugin } from './plugins/preload';
25+
import { loadAppResource, GarfishPreloadPlugin } from './plugins/preload';
2626
import { defaultLoadComponentOptions, getDefaultOptions } from './config';
2727

2828
export class Garfish implements interfaces.Garfish {
@@ -180,6 +180,15 @@ export class Garfish implements interfaces.Garfish {
180180
return this;
181181
}
182182

183+
preloadApp(name: string) {
184+
const appInfo = this.appInfos[name];
185+
assert(
186+
appInfo && appInfo.entry,
187+
`Can't preloadApp unexpected module "${name}".`,
188+
);
189+
loadAppResource(this.loader, appInfo);
190+
}
191+
183192
async loadApp(
184193
appName: string,
185194
options: Partial<interfaces.LoadAppOptions> | string,

0 commit comments

Comments
 (0)