Skip to content

Commit 8cb9ca4

Browse files
committed
Lazy-load optional OPFS Blueprint dependencies
1 parent 6e15dd7 commit 8cb9ca4

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/playground/website/src/lib/state/opfs/opfs-site-storage.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ import {
2323
} from '@wp-playground/blueprints';
2424
import type { AllPHPVersion } from '@php-wasm/universal';
2525
import { RecommendedPHPVersion } from '@wp-playground/common';
26-
import {
27-
BUNDLE_DIR_NAME,
28-
loadPersistedBlueprintBundle,
29-
loadPersistedBlueprintBundleFromPath,
30-
} from './opfs-blueprint-bundle-storage';
3126
import {
3227
OPFS_SITES_ROOT_PATH,
3328
getCandidateDirectoryNamesForSlug,
@@ -301,6 +296,11 @@ class OpfsSiteStorage {
301296
// This allows the site to access bundled resources, not just the JSON declaration.
302297
if (siteInfo.metadata.originalBlueprintSource?.type === 'opfs-site') {
303298
try {
299+
// Load Blueprint bundle support only for Blueprint-backed site metadata.
300+
const {
301+
loadPersistedBlueprintBundle,
302+
loadPersistedBlueprintBundleFromPath,
303+
} = await import('./opfs-blueprint-bundle-storage');
304304
siteInfo.metadata.originalBlueprint = isLegacyDirectoryName
305305
? await loadPersistedBlueprintBundleFromPath(sitePath)
306306
: await loadPersistedBlueprintBundle(siteInfo.slug);
@@ -357,6 +357,9 @@ class OpfsSiteStorage {
357357
if (!siteDirName) {
358358
throw new Error(`Site with slug '${slug}' does not exist.`);
359359
}
360+
// Only site reset needs Blueprint bundle support.
361+
const { BUNDLE_DIR_NAME } =
362+
await import('./opfs-blueprint-bundle-storage');
360363
const siteDirectory = await this.root.getDirectoryHandle(siteDirName);
361364
const namesToDelete: string[] = [];
362365
for await (const [name] of siteDirectory.entries()) {

0 commit comments

Comments
 (0)