MCPcopy
hub / github.com/FredKSchott/snowpack / PackageSource

Interface PackageSource

snowpack/src/types.ts:376–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374
375/** PackageSource - a common interface for loading and interacting with dependencies. */
376export interface PackageSource {
377 /**
378 * Do any work needed before starting the dev server or build. Either will wait
379 * for this to complete before continuing. Example: For "local", this involves
380 * running esinstall (if needed) to prepare your local dependencies as ESM.
381 */
382 prepare(): Promise<void>;
383 /**
384 * Like prepare(), but only looks at a single file and meant to run at anytime,
385 * usually after the server has already started and is running.
386 */
387 prepareSingleFile(fileLoc: string): Promise<void>;
388 /**
389 * Load a dependency with the given spec (ex: "/pkg/react" -> "react")
390 * If load fails or is unsuccessful, reject the promise.
391 */
392 load(
393 spec: string,
394 options: {isSSR: boolean},
395 ): Promise<undefined | {contents: Buffer | string; imports: InstallTarget[]}>;
396 /** Resolve a package import to URL (ex: "react" -> "/pkg/react") */
397 resolvePackageImport(
398 spec: string,
399 options?: {source?: string; importMap?: ImportMap; depth?: number},
400 ): Promise<string>;
401 /** Modify the build install config for optimized build install. */
402 modifyBuildInstallOptions(
403 installOptions: EsinstallOptions,
404 installTargets: InstallTarget[],
405 ): Promise<EsinstallOptions>;
406 getCacheFolder(): string;
407 clearCache(): void | Promise<void>;
408}
409
410export type ScannableExt =
411 | '.astro'

Callers 14

preparePackagesFunction · 0.65
addCommandFunction · 0.65
rmCommandFunction · 0.65
commandFunction · 0.65
startServerFunction · 0.65
startServerFunction · 0.65
loadUrlFunction · 0.65
plugin.test.jsFile · 0.65
plugin.test.jsFile · 0.65
loadUrlFunction · 0.65
handleRequestFunction · 0.65

Implementers 2

PackageSourceRemotesnowpack/src/sources/remote.ts
PackageSourceLocalsnowpack/src/sources/local.ts

Calls

no outgoing calls

Tested by

no test coverage detected