MCPcopy
hub / github.com/freshframework/fresh / build

Method build

packages/fresh/src/dev/builder.ts:255–283  ·  view source on GitHub ↗

* Build optimized assets for your app. By default this will create * a production build. * * This can also be used for testing to apply a snapshot to a particular * code App instance. * * @example Testing * ```ts * const builder = new Builder(); * const applySnapsho

(
    options?: {
      mode?: ResolvedBuildConfig["mode"];
      snapshot?: "disk" | "memory";
    },
  )

Source from the content-addressed store, hash-verified

253 * @returns Apply a snapshot to a particular {@linkcode App} instance.
254 */
255 async build(
256 options?: {
257 mode?: ResolvedBuildConfig["mode"];
258 snapshot?: "disk" | "memory";
259 },
260 ): Promise<(app: App<State>) => void> {
261 this.config.mode = options?.mode ?? "production";
262
263 await this.#crawlFsItems();
264
265 const buildCache = options?.snapshot === "memory"
266 ? new MemoryBuildCache(
267 this.config,
268 this.#fsRoutes,
269 this.#transformer,
270 )
271 : new DiskBuildCache(
272 this.config,
273 this.#fsRoutes,
274 this.#transformer,
275 );
276
277 await this.#build(buildCache, this.config.mode === "development");
278 await buildCache.prepare();
279
280 return (app) => {
281 setBuildCache(app, buildCache, app.config.mode);
282 };
283 }
284
285 async #crawlFsItems() {
286 const { islands, routes } = await crawlFsItem(

Callers 5

buildProdFunction · 0.95
dev.tsFile · 0.80
builder_test.tsFile · 0.80
bundleJsFunction · 0.80
buildAppFunction · 0.80

Calls 3

#crawlFsItemsMethod · 0.95
#buildMethod · 0.95
prepareMethod · 0.65

Tested by

no test coverage detected