UNPKG

2.92 kBTypeScriptView Raw
1import { CancelableRequest, Response } from 'got';
2import { SnowpackConfig, BuildScript } from './config';
3export declare const PIKA_CDN = "https://cdn.pika.dev";
4export declare const GLOBAL_CACHE_DIR: any;
5export declare const RESOURCE_CACHE: string;
6export declare const BUILD_CACHE: string;
7export declare const PROJECT_CACHE_DIR: any;
8export declare const DEV_DEPENDENCIES_DIR: string;
9export declare const HAS_CDN_HASH_REGEX: RegExp;
10export declare const HTML_JS_REGEX: RegExp;
11export interface ImportMap {
12 imports: {
13 [packageName: string]: string;
14 };
15}
16export interface CommandOptions {
17 cwd: string;
18 config: SnowpackConfig;
19 lockfile: ImportMap | null;
20 pkgManifest: any;
21}
22export declare function isYarn(cwd: string): boolean;
23export declare function readLockfile(cwd: string): Promise<ImportMap | null>;
24export declare function writeLockfile(loc: string, importMap: ImportMap): Promise<void>;
25export declare function fetchCDNResource(resourceUrl: string, responseType?: 'text' | 'json' | 'buffer'): Promise<CancelableRequest<Response>>;
26export declare function isTruthy<T>(item: T | false | null | undefined): item is T;
27/** Get the package name + an entrypoint within that package (if given). */
28export declare function parsePackageImportSpecifier(imp: string): [string, string | null];
29/**
30 * Given a package name, look for that package's package.json manifest.
31 * Return both the manifest location (if believed to exist) and the
32 * manifest itself (if found).
33 *
34 * NOTE: You used to be able to require() a package.json file directly,
35 * but now with export map support in Node v13 that's no longer possible.
36 */
37export declare function resolveDependencyManifest(dep: string, cwd: string): [string | null, any | null];
38/**
39 * If Rollup erred parsing a particular file, show suggestions based on its
40 * file extension (note: lowercase is fine).
41 */
42export declare const MISSING_PLUGIN_SUGGESTIONS: {
43 [ext: string]: string;
44};
45export declare function openInBrowser(protocol: string, port: number, browser: string): Promise<true | undefined>;
46export declare function checkLockfileHash(dir: string): Promise<boolean>;
47export declare function updateLockfileHash(dir: string): Promise<void>;
48export declare function clearCache(): Promise<[void, void, void]>;
49/**
50 * Given an import string and a list of scripts, return the mount script that matches the import.
51 *
52 * `mount ./src --to /_dist_` and `mount src --to /_dist_` match `src/components/Button`
53 * `mount src --to /_dist_` does not match `package/components/Button`
54 */
55export declare function findMatchingMountScript(scripts: BuildScript[], spec: string): BuildScript | null | undefined;
56/** Get full extensions of files */
57export declare function getExt(fileName: string): {
58 /** base extension (e.g. `.js`) */
59 baseExt: string;
60 /** full extension, if applicable (e.g. `.proxy.js`) */
61 expandedExt: string;
62};