sveltekit_shim_app_navigation.ts view source
(callback: (navigation: AfterNavigate) => void) => void task runner and toolkit extending SvelteKit
327 declarations
sveltekit_shim_app_navigation.ts view source
(callback: (navigation: AfterNavigate) => void) => void (file: GenFile): Promise<AnalyzedGenResult> filePromise<AnalyzedGenResult> (gen_results: GenResults): Promise<AnalyzedGenResult[]> gen_resultsPromise<AnalyzedGenResult[]> AnalyzedGenResult sveltekit_shim_app_forms.ts view source
<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: ActionResult<Success, Failure>) => Promise<void> Args These extend the CLI args for tasks.
Anything can be assigned to a task's args. It's just a mutable POJO dictionary.
Downstream tasks will see args that upstream events mutate,
unless invoke_task is called with modified args.
Upstream tasks can use listeners to respond to downstream events and values.
It's a beautiful mutable spaghetti mess. cant get enough
The raw CLI args are handled by mri - https://github.com/lukeed/mri
_Array<string>helpbooleanArgSchema typestringdefaultdescriptionstringArgValue sveltekit_shim_app_paths.ts view source
(file: "/CNAME" | "/favicon.png" | "/logo.svg" | "/robots.txt" | (string & {})): string file"/CNAME" | "/favicon.png" | "/logo.svg" | "/robots.txt" | (string & {})string sveltekit_shim_app_paths.ts view source
"" sveltekit_shim_app_paths.ts view source
"" (base_path: string, p?: Paths): PathId base_pathstringpinfer_paths(base_path)PathId sveltekit_shim_app_navigation.ts view source
(callback: (navigation: BeforeNavigate) => void) => void sveltekit_shim_app_environment.ts view source
false This file is created dynamically by render_sveltekit_shim_app_environment but exists here for the sake of the Node loader. There may be a cleaner workaround but I couldn't find it.
https://github.com/nodejs/loaders for details about the forthcoming virtual file support
"build.json" "1" ZodObject<{ version: ZodString; git_commit: ZodNullable<ZodString>; build_cache_config_hash: ZodString; timestamp: ZodString; outputs: ZodArray<...>; }, $strict> Metadata stored in .gro/ directory to track build cache validity. Schema validates structure at load time to catch corrupted cache files.
sveltekit_shim_app_environment.ts view source
false ZodObject<{ path: ZodString; hash: ZodString; size: ZodNumber; mtime: ZodNumber; ctime: ZodNumber; mode: ZodNumber; }, $strict> Metadata about a single build output file. Includes cryptographic hash for validation plus filesystem stats for debugging and optimization.
changeset_helpers.ts view source
"changeset" changeset_helpers.ts view source
".changeset" changeset_helpers.ts view source
"public" changeset_helpers.ts view source
"restricted" changeset_helpers.ts view source
ZodEnum<{ restricted: "restricted"; public: "public"; }> changeset_helpers.ts view source
ZodEnum<{ patch: "patch"; minor: "minor"; major: "major"; }> ({ build, build_dev, build_dist, sveltekit, nodemodules, }: { build?: boolean | undefined; build_dev?: boolean | undefined; build_dist?: boolean | undefined; sveltekit?: boolean | undefined; nodemodules?: boolean | undefined; }, rm_options?: RmOptions): Promise<...> __0{ build?: boolean | undefined; build_dev?: boolean | undefined; build_dist?: boolean | undefined; sveltekit?: boolean | undefined; nodemodules?: boolean | undefined; }rm_optionsRmOptions{force: true, recursive: true}Promise<void> Cli (build_dirs: string[]): Promise<{ path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]> Collects information about all files in build output directories. Returns an array of entries with path, hash, size, mtime, ctime, and mode.
Files are hashed in parallel for performance. For very large builds (10k+ files), this may take several seconds but ensures complete cache validation.
build_dirsArray of output directories to scan (e.g., ['build', 'dist', 'dist_server'])
string[]Promise<{ path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]> (config: GroConfig, log: Logger, git_commit?: string | null | undefined): Promise<{ git_commit: string | null; build_cache_config_hash: string; }> Computes the cache key components for a build. This determines whether a cached build can be reused.
configGro config (build_cache_config_hash is already computed during config load)
logLogger
Loggergit_commit?Optional pre-computed git commit hash (optimization to avoid re-reading)
string | null | undefinedPromise<{ git_commit: string | null; build_cache_config_hash: string; }> child_process_logging.ts view source
(child_process: ChildProcess, replacement?: string, cwd?: string): void Configures process output handling with path replacements while preserving ANSI colors.
child_processChildProcessreplacementstring'.'cwdstringprocess.cwd()void (raw_config: RawGroConfig): Promise<GroConfig> Transforms a RawGroConfig to the more strict GroConfig.
This allows users to provide a more relaxed config.
Hashes the build_cache_config and deletes the raw value for security.
raw_configPromise<GroConfig> gro_plugin_sveltekit_app.ts view source
CopyFileFilter (config: GroConfig, log: Logger, git_commit?: string | null | undefined, build_dirs?: string[] | undefined): Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { ...; }[]; }> Creates build cache metadata after a successful build. Automatically discovers all build output directories (build/, dist/, dist_*).
configGro config
logLogger
Loggergit_commit?Optional pre-computed git commit hash (optimization)
string | null | undefinedbuild_dirs?Optional pre-discovered build directories (optimization to avoid redundant filesystem scans)
string[] | undefinedPromise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }> (): GroConfig GroConfig (root_dir: string): Paths root_dirstringPaths CreateConfigPlugins<TPluginContext> TPluginContextCreateGroConfig gro_plugin_server.ts view source
CreateOutpaths RegExp Declaration namestringkindDeclarationKind | nullParsedSvelteConfig The parsed SvelteKit config for the cwd, cached globally at the module level.
esbuild_helpers.ts view source
TransformOptions sveltekit_shim_app_forms.ts view source
<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure> resultstringActionResult<Success, Failure> sveltekit_shim_app_environment.ts view source
true DevTask_Context sveltekit_shim_app_navigation.ts view source
() => void (): Promise<string[]> Discovers all build output directories in the current working directory. Returns an array of directory names that exist: build/, dist/, dist_*
Promise<string[]> Disknode idPathIdcontentsnull contents means it doesn't exist.
We create the file in memory to track its dependents regardless of its existence on disk.
string | nullexternalIs the source file outside of the root_dir or excluded by watch_dir_options.filter?
booleanctimenumber | nullmtimenumber | nulldependentsMap<PathId, Disknode>dependenciesMap<PathId, Disknode>"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" SHA-256 hash of empty string, used for configs without build_cache_config. This ensures consistent cache behavior when no custom config is provided.
{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } sveltekit_shim_app_forms.ts view source
<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(form_element: HTMLFormElement, submit?: SubmitFunction<Success, Failure> | undefined): { ...; } form_elementHTMLFormElementsubmit?SubmitFunction<Success, Failure> | undefined{ destroy(): void; } esbuild_plugin_external_worker.ts view source
({ dev, build_options, dir, svelte_compile_options, svelte_compile_module_options, svelte_preprocessors, alias, base_url, assets_url, public_prefix, private_prefix, env_dir, env_files, ambient_env, log, }: EsbuildPluginExternalWorkerOptions): Plugin __0Plugin esbuild_plugin_svelte.ts view source
(options: EsbuildPluginSvelteOptions): Plugin optionsPlugin esbuild_plugin_sveltekit_local_imports.ts view source
(): Plugin Adds support for imports to both .ts and .js,
as well as imports without extensions that resolve to .js or .ts.
Prefers .ts over any .js, and falls back to .ts if no file is found.
Plugin esbuild_plugin_sveltekit_shim_alias.ts view source
({ dir, alias, }: EsbuildPluginSveltekitShimAliasOptions): Plugin __0Plugin esbuild_plugin_sveltekit_shim_app.ts view source
({ dev, base_url, assets_url, }: EsbuildPluginSveltekitShimAppOptions): Plugin __0Plugin esbuild_plugin_sveltekit_shim_env.ts view source
({ dev, public_prefix, private_prefix, env_dir, env_files, ambient_env, }: EsbuildPluginSveltekitShimEnvOptions): Plugin __0Plugin esbuild_plugin_external_worker.ts view source
EsbuildPluginExternalWorkerOptions devbooleanbuild_optionsesbuild.BuildOptionsdirstringsvelte_compile_optionsCompileOptionssvelte_compile_module_optionsModuleCompileOptionssvelte_preprocessorsPreprocessorGroup | Array<PreprocessorGroup>aliasRecord<string, string>base_urlParsedSvelteConfig['base_url']assets_urlParsedSvelteConfig['assets_url']public_prefixstringprivate_prefixstringenv_dirstringenv_filesArray<string>ambient_envRecord<string, string>logLoggeresbuild_plugin_sveltekit_shim_alias.ts view source
EsbuildPluginSveltekitShimAliasOptions dirstringaliasRecord<string, string>esbuild_plugin_sveltekit_shim_app.ts view source
EsbuildPluginSveltekitShimAppOptions devbooleanbase_urlParsedSvelteConfig['base_url']assets_urlParsedSvelteConfig['assets_url']esbuild_plugin_sveltekit_shim_env.ts view source
EsbuildPluginSveltekitShimEnvOptions devbooleanpublic_prefixstringprivate_prefixstringenv_dirstringenv_filesArray<string>ambient_envRecord<string, string>esbuild_plugin_svelte.ts view source
EsbuildPluginSvelteOptions devbooleanbase_urlParsedSvelteConfig['base_url']dirstringsvelte_compile_optionsCompileOptionssvelte_compile_module_optionsModuleCompileOptionssvelte_preprocessorsPreprocessorGroup | Array<PreprocessorGroup>ts_transform_optionsesbuild.TransformOptionsis_ts(filename: string) => booleanRegExp ExportDeclaration RegExp (package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }): PackageJsonDep[] package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }PackageJsonDep[] root_dirtype PathId
filestype Map<PathId, Disknode>
constructortype new (options?: FilerOptions): Filer
optionsEMPTY_OBJECTget_by_idget_or_createfiltertype (predicate: (disknode: Disknode) => boolean): Disknode[] | null
predicate(disknode: Disknode) => booleanDisknode[] | nullinitInitialize the filer to populate files without watching. Safe to call multiple times - subsequent calls are no-ops. Used by gen files to access the file graph.
type (): Promise<void>
Promise<void>watchtype (listener: OnFilerChange): Promise<() => void>
listenerPromise<() => void>closetype (): Promise<void>
Promise<void>FilerOptions watch_dirtypeof watch_dirwatch_dir_optionsPartial<OmitStrict<WatchDirOptions, 'on_change'>>package_json_cacheRecord<string, PackageJson>logLogger(disknode: Disknode, get_by_id: (id: PathId) => Disknode | undefined, filter?: FileFilter | undefined, results?: Set<PathId>, searched?: Set<...>, log?: Logger | undefined): Set<...> disknodeget_by_id(id: PathId) => Disknode | undefinedfilter?FileFilter | undefinedresultsSet<PathId>new Set()searchedSet<PathId>new Set()log?Logger | undefinedSet<PathId> (name: string, cwd?: string | URL, options?: SpawnOptions | undefined): Promise<Cli | null> Searches the filesystem for the CLI name, first local to the cwd and then globally.
namestringcwdstring | URLprocess.cwd()options?SpawnOptions | undefinedPromise<Cli | null> null if not found locally or globally
(input_paths: InputPath[], root_dirs: PathId[], config: GroConfig, timings?: Timings | undefined): Promise<FindGenfilesResult> Finds modules from input paths. (see src/lib/input_path.ts for more)
input_pathsInputPath[]root_dirsPathId[]configtimings?Timings | undefinedPromise<FindGenfilesResult> (input_paths: InputPath[], task_root_dirs: PathId[], config: GroConfig, timings?: Timings | undefined): Promise<FindTasksResult> Finds modules from input paths. (see src/lib/input_path.ts for more)
input_pathsInputPath[]task_root_dirsPathId[]configtimings?Timings | undefinedPromise<FindTasksResult> FindGenfilesFailure FindGenfilesResult FindModulesFailure FindTasksResult format_directory.ts view source
(log: Logger, dir: string, check?: boolean, extensions?: string, root_paths?: string, prettier_cli?: string | Cli, pm_cli?: string): Promise<SpawnResult> Formats a directory on the filesystem.
If the source directory is given, it also formats all of the root directory files.
This is separated from ./format_file to avoid importing all of the prettier code
inside modules that import this one. (which has a nontrivial cost)
logLoggerdirstringcheckbooleanfalseextensionsstringEXTENSIONS_DEFAULTroot_pathsstringROOT_PATHS_DEFAULTprettier_clistring | CliPRETTIER_CLI_DEFAULTpm_clistringPM_CLI_DEFAULTPromise<SpawnResult> (content: string, options: Options, base_options?: Options | null | undefined): Promise<string> Formats a file with Prettier.
contentstringoptionsOptionsbase_options- defaults to the the cwd's package.json prettier value
Options | null | undefinedcached_base_optionsPromise<string> FoundGenfiles resolved_input_filesArray<ResolvedInputFile>resolved_input_files_by_root_dirMap<PathId, Array<ResolvedInputFile>>resolved_input_pathsArray<ResolvedInputPath>FoundTask input_pathidPathIdtask_root_dirPathIdFoundTasks resolved_input_filesArray<ResolvedInputFile>resolved_input_files_by_root_dirMap<PathId, Array<ResolvedInputFile>>resolved_input_pathsArray<ResolvedInputPath>input_pathsArray<InputPath>task_root_dirsArray<PathId>Gen string "gen" "gen runs only during development" GenConfig generatedependenciesGenContext configsvelte_configfilerlogLoggertimingsTimingsinvoke_taskorigin_idSame as import.meta.url but in path form.
PathIdorigin_pathThe origin_id relative to the root dir.
stringchanged_file_idThe file that triggered dependency checking.
Only available when resolving dependencies dynamically.
undefined during actual generation.
PathId | undefinedGenDependencies GenDependenciesConfig patternsArray<RegExp>filesArray<PathId>GenDependenciesResolver GenFile idPathIdcontentstringorigin_idPathIdformatbooleanGenfileModule genGenfileModuleMeta GenfileModuleResult GenfileModuleResultFailure okfalseidPathIdreasonstringerrorErrorelapsednumberGenfileModuleResultSuccess oktrueidPathIdfilesArray<GenFile>elapsednumberGenFunction GenResult origin_idPathIdfilesArray<GenFile>GenResults resultsArray<GenfileModuleResult>successesArray<GenfileModuleResultSuccess>failuresArray<GenfileModuleResultFailure>input_countnumberoutput_countnumberelapsednumber(input_path: InputPath, root_dirs: PathId[], extensions: string[]): Promise<PossiblePath[]> Gets a list of possible source ids for each input path with extensions,
duplicating each under root_dirs, without checking the filesystem.
input_pathroot_dirsPathId[]extensionsstring[]Promise<PossiblePath[]> ".git" 7 Length of git commit hash when displayed in logs (standard git convention).
".github" (owner: string, repo: string, commit_sha: string, token?: string | undefined, log?: Logger | undefined, cache?: Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | undefined, api_version?: string | undefined): Promise<...> ownerstringrepostringcommit_shastringtoken?string | undefinedlog?Logger | undefinedcache?Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | undefinedapi_version?string | undefinedPromise<{ [x: string]: unknown; url: string; id: number; html_url: string; number: number; user: { [x: string]: unknown; login: string; }; }[] | null> RegExp ZodObject<{ url: ZodString; id: ZodNumber; html_url: ZodString; number: ZodNumber; user: ZodObject<{ login: ZodString; }, $loose>; }, $loose> sveltekit_shim_app_navigation.ts view source
(url: string | URL, opts?: { replaceState?: boolean | undefined; noScroll?: boolean | undefined; keepFocus?: boolean | undefined; invalidateAll?: boolean | undefined; invalidate?: (string | ... 1 more ... | ((url: URL) => boolean))[] | undefined; state?: PageState | undefined; } | undefined) => Promise<...> "gro.config.ts" string string string ".gro" string "dist_" "gro/" Paths Paths for the Gro package being used by the user repo.
({ input_paths, root_dirs, flush_debounce_delay, }?: GroPluginGenOptions): Plugin<PluginContext<object>> __0EMPTY_OBJECTPlugin<PluginContext<object>> gro_plugin_server.ts view source
({ entry_points, dir, outpaths, env_files, ambient_env, svelte_config, target, esbuild_build_options, rebuild_throttle_delay, cli_command, run, }?: GroPluginServerOptions): Plugin<PluginContext<object>> __0{}Plugin<PluginContext<object>> gro_plugin_sveltekit_app.ts view source
({ host_target, well_known_package_json, well_known_source_json, well_known_src_files, vite_cli, }?: GroPluginSveltekitAppOptions): Plugin<PluginContext<object>> __0{}Plugin<PluginContext<object>> gro_plugin_sveltekit_library.ts view source
({ svelte_package_options, svelte_package_cli, }?: GroPluginSveltekitLibraryOptions): Plugin<PluginContext<object>> __0{}Plugin<PluginContext<object>> GroConfig The config that users can extend via gro.config.ts.
This is exposed to users in places like tasks and genfiles.
pluginsmap_package_jsonMaps the project's package.json before writing it to the filesystem.
The package_json argument may be mutated, but the return value is what's used by the caller.
Returning null is a no-op for the caller.
PackageJsonMapper | nulltask_root_dirsThe root directories to search for tasks given implicit relative input paths.
Defaults to ./src/lib, then the cwd, then the Gro package dist.
Array<PathId>search_filtersWhen searching the filsystem for tasks and genfiles, directories and files are included if they pass all of these filters.
Array<PathFilter>js_cliThe CLI to use that's compatible with node.
stringpm_cliThe CLI to use that's compatible with npm install and npm link. Defaults to 'npm'.
stringsvelte_config_filenamestringbuild_cache_config_hashSHA-256 hash of the user's build_cache_config from gro.config.ts.
This is computed during config normalization and the raw value is immediately deleted.
If no build_cache_config was provided, this is the hash of an empty string.
stringGroConfigModule defaultRawGroConfig | CreateGroConfigGroPluginGenOptions input_pathsArray<string>root_dirsArray<string>flush_debounce_delaynumbergro_plugin_server.ts view source
GroPluginServerOptions entry_pointssame as esbuild's entryPoints
Array<string>dirstringoutpathsReturns the Outpaths given a dev param. Decoupling this from plugin creation allows it to be created generically, so the build and dev tasks can be the source of truth for dev.
env_filesArray<string>ambient_envRecord<string, string>svelte_configSvelteConfigtargetstringesbuild_build_optionsOptionally map the esbuild options.
(base_options: esbuild.BuildOptions) => esbuild.BuildOptionsrebuild_throttle_delayMilliseconds to throttle rebuilds. Should be longer than it takes to build to avoid backpressure.
numbercli_commandThe CLI command to run the server, like 'node' or 'bun' or 'deno'.
Receives the path to the server js file as its argument.
stringrunWhether to run the server or not after building.
booleangro_plugin_sveltekit_app.ts view source
GroPluginSveltekitAppOptions host_targetUsed for finalizing a SvelteKit build like adding a .nojekyll file for GitHub Pages.
well_known_package_jsonIf truthy, adds /.well-known/package.json to the static output.
If a function, maps the value.
boolean | PackageJsonMapperwell_known_source_jsonIf truthy, adds /.well-known/source.json and /.well-known/src/ to the static output.
If a function, maps the value.
boolean | SourceJsonMapperwell_known_src_filesIf truthy, copies src/ to /.well-known/src/ to the static output.
Pass a function to customize which files get copied.
boolean | CopyFileFiltervite_cliThe Vite CLI to use.
stringgro_plugin_sveltekit_library.ts view source
GroPluginSveltekitLibraryOptions svelte_package_optionsThe options passed to the SvelteKit packaging CLI.
svelte_package_cliThe SvelteKit packaging CLI to use. Defaults to svelte-package.
string(dep_name: string, package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; ... 25 more ...; exports?: string | ... 2 more ... | undefined; }): boolean dep_namestringpackage_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }boolean gro_plugin_server.ts view source
(path?: PathId): Promise<Result<object, { message: string; }>> pathPathIdSERVER_SOURCE_IDPromise<Result<object, { message: string; }>> sveltekit_helpers.ts view source
(svelte_config_path?: string): Promise<Result<object, { message: string; }>> svelte_config_pathstringSVELTE_CONFIG_FILENAMEPromise<Result<object, { message: string; }>> sveltekit_helpers.ts view source
(package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }, svelte_config?: ParsedSvelteConfig, dep_name?: string): Promise<...> package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }svelte_configdefault_svelte_configdep_namestringSVELTE_PACKAGE_DEP_NAMEPromise<Result<object, { message: string; }>> gro_plugin_sveltekit_app.ts view source
HostTarget ImportSpecifier (file_path: PathId, declarations?: ExportDeclaration[]): ExportDeclaration[] file_pathPathIddeclarationsExportDeclaration[][]ExportDeclaration[] (id: PathId): Paths idPathIdPaths ZodString sveltekit_shim_app_navigation.ts view source
(resource: string | URL | ((url: URL) => boolean)) => Promise<void> sveltekit_shim_app_navigation.ts view source
() => Promise<void> (task_name: RawInputPath, args: Args | undefined, config: GroConfig, initial_filer?: Filer | undefined, initial_timings?: Timings | null | undefined, parent_log?: Logger | undefined): Promise<...> Invokes Gro tasks by name using the filesystem as the source.
When a task is invoked,
Gro first searches for tasks in the current working directory.
and falls back to searching Gro's directory, if the two are different.
See src/lib/input_path.ts for info about what "task_name" can refer to.
If it matches a directory, all of the tasks within it are logged,
both in the current working directory and Gro.
This code is particularly hairy because we're accepting a wide range of user input and trying to do the right thing. Precise error messages are especially difficult and there are some subtle differences in the complex logical branches. The comments describe each condition.
task_name- The name of the task to invoke.
args- The CLI args to pass to the task.
Args | undefinedconfig- The Gro configuration.
initial_filer?Filer | undefinedinitial_timings?- The timings to use for the top-level task, null for composed tasks.
Timings | null | undefinedparent_log?Logger | undefinedPromise<void> InvokeTask (config: GroConfig, log: Logger, git_commit?: string | null | undefined): Promise<boolean> Main function to check if the build cache is valid. Returns true if the cached build can be used, false if a fresh build is needed.
configGro config
logLogger
Loggergit_commit?Optional pre-computed git commit hash (optimization)
string | null | undefinedPromise<boolean> (module_name: string): boolean module_namestringboolean (path: string): boolean pathstringboolean (id: PathId): boolean idPathIdboolean (key: string, public_prefix: string, private_prefix: string): boolean keystringpublic_prefixstringprivate_prefixstringboolean (key: string, public_prefix: string, private_prefix: string): boolean keystringpublic_prefixstringprivate_prefixstringboolean (path: string): boolean pathstringboolean boolean "node" RegExp RegExp string string string (): Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; } | null> Loads build cache metadata from .gro/ directory. Invalid or corrupted cache files are automatically deleted.
Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; } | null> (dev: boolean, visibility: "public" | "private", public_prefix: string, private_prefix: string, env_dir?: string | undefined, env_files?: string[], ambient_env?: ProcessEnv): Record<...> devbooleanvisibility"public" | "private"public_prefixstringprivate_prefixstringenv_dir?string | undefinedenv_filesstring[]['.env', '.env.' + (dev ? 'development' : 'production')]ambient_envProcessEnvprocess.envRecord<string, string> (key: string, paths?: string[]): string | undefined Loads a single env value without merging it into process.env.
By default searches process.env, then a local .env if one exists, then ../.env if it exists.
Empty strings are semantically the same as undefined for more ergonomic fallbacks.
keystringpathsstring[]['.env', '../.env']string | undefined (found_genfiles: FoundGenfiles, timings?: Timings | undefined): Promise<LoadGenfilesResult> found_genfilestimings?Timings | undefinedPromise<LoadGenfilesResult> (dir?: string): Promise<GroConfig> dirstringpaths.rootPromise<GroConfig> (): Promise<{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }> Promise<{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }> <TModule extends Record<string, any>>(id: PathId, validate?: ((mod: Record<string, any>) => mod is TModule) | undefined, bust_cache?: boolean | undefined): Promise<LoadModuleResult<TModule>> idPathIdvalidate?((mod: Record<string, any>) => mod is TModule) | undefinedbust_cache?boolean | undefinedPromise<LoadModuleResult<TModule>> <TModule extends Record<string, any>, TModuleMeta extends ModuleMeta<TModule>>(resolved_input_files: ResolvedInputFile[], validate: (mod: any) => mod is TModule, map_module_meta: (resolved_input_file: ResolvedInputFile, mod: TModule) => TModuleMeta, timings?: Timings | undefined): Promise<...> resolved_input_filesResolvedInputFile[]validate(mod: any) => mod is TModulemap_module_meta(resolved_input_file: ResolvedInputFile, mod: TModule) => TModuleMetatimings?Timings | undefinedPromise<LoadModulesResult<TModuleMeta>> (dir?: string, cache?: Record<string, { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; ... 25 more ...; exports?: string | ... 2 more ... | undefined; }> | undefined, parse?: boolean, log?: Logger | undefined): Promise<...> dirstringIS_THIS_GRO ? gro_paths.root : paths.rootcache?Record<string, { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }> | undefinedparsebooleantruelog?Logger | undefinedPromise<{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }> ({ dir, config_filename, }?: { dir?: string | undefined; config_filename?: string | undefined; }): Promise<Config | null> Loads a SvelteKit config at dir.
__0{ dir?: string | undefined; config_filename?: string | undefined; }EMPTY_OBJECTPromise<Config | null> null if no config is found
(found_tasks: FoundTasks, root_path?: PathId): Promise<LoadTasksResult> found_tasksroot_pathPathIdprocess.cwd()Promise<LoadTasksResult> LoadedGenfiles modulesArray<GenfileModuleMeta>found_genfilesLoadedTasks modulesArray<TaskModuleMeta>found_tasksLoadGenfilesFailure LoadGenfilesResult LoadModuleFailure LoadModuleResult<TModule> TModuleLoadModulesFailure<TModuleMeta> TModuleMetatype'load_module_failures'load_module_failuresArray<LoadModuleFailure>reasonsArray<string>modulesArray<TModuleMeta>LoadModulesResult<TModuleMeta> TModuleMetaLoadTasksFailure LoadTasksResult "package-lock.json" (log: Logger, reasons: string[]): void logLoggerreasonsstring[]void (log: Logger, meta: TaskModuleMeta): void logLoggermetavoid (log: Logger, loaded_tasks: LoadedTasks, log_intro?: boolean): void logLoggerloaded_taskslog_introbooleantruevoid child_process_logging.ts view source
(child_process: ChildProcess, transform: (data: string) => string): void Maps child process output through a transform function.
child_processChildProcesstransform(data: string) => stringvoid sveltekit_helpers.ts view source
(specifier: string, aliases: [string, string][]): string Map an import specifier with the SvelteKit aliases.
specifierstringaliases[string, string][]string (envs: Record<string, string | undefined>[], visibility: "public" | "private", public_prefix: string, private_prefix: string): Record<string, string> envsRecord<string, string | undefined>[]visibility"public" | "private"public_prefixstringprivate_prefixstringRecord<string, string> string string ModuleMeta<TModule> TModuleRecord<string, any>Record<string, any>idPathIdmodTModulesveltekit_shim_app_state.ts view source
Navigation | { from: null; to: null; type: null; willUnload: null; delta: null; complete: null; } "node_modules" (gen: Gen): GenConfig genGenConfig OnFilerChange gro_plugin_server.ts view source
Outpaths outdirstringoutbasestringoutnamestring"package.json" PackageJsonDep namestringversionstringPackageJsonMapper sveltekit_shim_app_state.ts view source
Page<{ module_path?: string | undefined; }, "/" | "/about" | "/docs" | "/docs/api" | "/docs/api/[...module_path]" | "/docs/library" | "/history" | null> <TOutput extends Record<string, ArgValue> = Args, TInput extends Record<string, ArgValue> = Args>(unparsed_args: TInput, schema: ZodType<TOutput, TInput, $ZodTypeInternals<TOutput, TInput>>): ZodSafeParseResult<...> Parses user input args with a Zod schema.
Sets the correct source of truth for no- versions of args,
to the opposite of the unprefixed versions when not included in unparsed_args.
This is needed because CLI args don't have a normal way of setting falsy values,
so instead the args parser mri will pass through the truthy versions of args
without the no- prefix.
When we declare task args schemas,
we need include both versions with their defaults to get correct --help output.
Parsing like this also ensures data consistency for both versions because mri only creates one.
A simpler implementation could replace mri, but it handles some finicky details well.
unparsed_argsTInputschemaZodType<TOutput, TInput, $ZodTypeInternals<TOutput, TInput>>ZodSafeParseResult<TOutput> (id: PathId, program?: Program | undefined, declarations?: ExportDeclaration[], log?: Logger | undefined): ExportDeclaration[] Parse exports from a file based on its file type and content.
idPathIdprogram?Program | undefineddeclarationsExportDeclaration[][]log?Logger | undefinedExportDeclaration[] (id: PathId, contents: string, ignore_types?: boolean): ImportSpecifier[] idPathIdcontentsstringignore_typesbooleantrueImportSpecifier[] (package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }): { ...; } | undefined package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }{ owner: string; repo: string; } | undefined ({ dir_or_config, config_filename, }?: { dir_or_config?: string | Config | undefined; config_filename?: string | undefined; }): Promise<ParsedSvelteConfig> Returns Gro-relevant properties of a SvelteKit config as a convenience wrapper around load_svelte_config. Needed because SvelteKit doesn't expose its config resolver.
__0{ dir_or_config?: string | Config | undefined; config_filename?: string | undefined; }EMPTY_OBJECTPromise<ParsedSvelteConfig> ParsedSvelteConfig A subset of SvelteKit's config in a form that Gro uses
because SvelteKit doesn't expose its config resolver.
Flattens things out to keep them simple and easy to pass around,
and doesn't deal with most properties, but includes the full svelte_config.
The base and assets in particular are renamed for clarity with Gro's internal systems,
so these properties become first-class vocabulary inside Gro.
svelte_configSvelteConfig | nullaliasRecord<string, string>base_url'' | `/${string}` | undefinedassets_url'' | `http://${string}` | `https://${string}` | undefinedassets_pathSame as the SvelteKit files.assets.
stringlib_pathSame as the SvelteKit files.lib.
stringroutes_pathSame as the SvelteKit files.routes.
stringenv_dirstring | undefinedprivate_prefixstring | undefinedpublic_prefixstring | undefinedsvelte_compile_optionsCompileOptionssvelte_compile_module_optionsModuleCompileOptionssvelte_preprocessorsPreprocessorGroup | Array<PreprocessorGroup> | undefinedparse_exports_context.ts view source
A class to track export context and determine export kinds.
logtype Logger | undefined
debugconstructortype new (program: Program, log?: Logger | undefined): ParseExportsContext
programProgramlog?Logger | undefinedanalyze_source_fileAnalyze a source file to prepare for export processing.
type (source_file: SourceFile): void
source_fileSourceFilevoidprocess_exportsProcess a list of exported symbols and identify their kinds.
type (source_file: SourceFile, exports: Symbol[], declarations?: ExportDeclaration[]): ExportDeclaration[]
source_fileSourceFileexportsSymbol[]declarationsExportDeclaration[][]ExportDeclaration[](path_id: PathId, p?: Paths): string path_idPathIdpinfer_paths(path_id)string Paths Paths for the user repo.
Paths rootstringsourcestringlibstringbuildstringbuild_devstringconfigstringPlugin<TPluginContext> Gro Plugins enable custom behavior during gro dev and gro build.
In contrast, Adapters use the results of gro build to produce final artifacts.
TPluginContextnamestringsetup(ctx: TPluginContext) => void | Promise<void>adapt(ctx: TPluginContext) => void | Promise<void>teardown(ctx: TPluginContext) => void | Promise<void>PluginContext<TArgs> TArgsobjectTaskContext<TArgs>devbooleanwatchbooleanSee Plugins.create for a usage example.
TPluginContextctxtype TPluginContext
instancestype Array<Plugin<TPluginContext>>
constructortype new <TPluginContext extends PluginContext>(ctx: TPluginContext, instances: Plugin<PluginContext<object>>[]): Plugins<TPluginContext>
ctxTPluginContextinstancesPlugin<PluginContext<object>>[]createtype <TPluginContext extends PluginContext>(ctx: TPluginContext): Promise<Plugins<TPluginContext>>
ctxTPluginContextPromise<Plugins<TPluginContext>>setuptype (): Promise<void>
Promise<void>adapttype (): Promise<void>
Promise<void>teardowntype (): Promise<void>
Promise<void>"npm" PossiblePath idPathIdinput_pathroot_dirPathIdsveltekit_shim_app_navigation.ts view source
(pathname: string) => Promise<void> sveltekit_shim_app_navigation.ts view source
(href: string) => Promise<{ type: "loaded"; status: number; data: Record<string, any>; } | { type: "redirect"; location: string; }> "prettier" esbuild_helpers.ts view source
(log: Logger, build_result: BuildResult<BuildOptions>): void logLoggerbuild_resultBuildResult<BuildOptions>void (serialized_args: string[]): string serialized_argsstring[]string (path: string, p?: Paths): string pathstringpinfer_paths(path)string (source_file: SourceFile, program: Program, exports: Symbol[], declarations?: ExportDeclaration[], log?: Logger | undefined): ExportDeclaration[] Process TypeScript exports, identifying their kinds.
source_fileSourceFileprogramProgramexportsSymbol[]declarationsExportDeclaration[][]log?Logger | undefinedExportDeclaration[] RawGenFile contentstringfilenamestringformatbooleanRawGenResult RawGroConfig pluginsmap_package_jsonPackageJsonMapper | nulltask_root_dirsArray<string>search_filtersPathFilter | Array<PathFilter> | nulljs_clistringpm_clistringbuild_cache_configOptional object defining custom build inputs for cache invalidation. This value is hashed during config normalization and used to detect when builds need to be regenerated due to non-source changes.
Use cases:
- Environment variables baked into build: {api_url: process.env.PUBLIC_API_URL}
- External data files: {data: fs.readFileSync('data.json', 'utf-8')}
- Build feature flags: {enable_analytics: true}
Can be a static object or an async function that returns an object.
IMPORTANT: It's safe to include secrets here because they are hashed and deleted
during config normalization. The raw value is never logged or persisted.
| Record<string, unknown>
| (() => Record<string, unknown> | Promise<Record<string, unknown>>)ZodString "README.md" sveltekit_shim_env.ts view source
(dev: boolean, mode: "static" | "dynamic", visibility: "public" | "private", public_prefix?: string, private_prefix?: string, env_dir?: string | undefined, env_files?: string[] | undefined, ambient_env?: Record<...> | undefined): string Generates a module shim for SvelteKit's $env imports.
devbooleanmode"static" | "dynamic"visibility"public" | "private"public_prefixstring'PUBLIC_'private_prefixstring''env_dir?string | undefinedenv_files?string[] | undefinedambient_env?Record<string, string | undefined> | undefinedstring sveltekit_shim_app.ts view source
(dev: boolean): string devbooleanstring sveltekit_shim_app.ts view source
(base_url?: "" | `/${string}` | undefined, assets_url?: "" | `http://${string}` | `https://${string}` | undefined): string base_url"" | `/${string}` | undefined''assets_url"" | `http://${string}` | `https://${string}` | undefined''string (path: string, new_extension: string): string pathstringnew_extensionstringstring (plugins: Plugin<PluginContext<object>>[], new_plugin: Plugin<PluginContext<object>>, name?: string): Plugin<PluginContext<object>>[] Replaces a plugin by name in plugins without mutating the param.
Throws if the plugin name cannot be found.
plugins- accepts the same types as the return value of CreateConfigPlugins
Plugin<PluginContext<object>>[]new_pluginPlugin<PluginContext<object>>name-
stringnew_plugin.namePlugin<PluginContext<object>>[] plugins with new_plugin at the index of the plugin with name
sveltekit_shim_app_paths.ts view source
<T extends RouteId | Pathname>(...args: ResolveArgs<T>): "/" | "/about" | "/docs" | "/docs/api" | "/docs/library" | "/history" | `${`/docs/api/${string}` & {}}` | `${`/docs/api/${string}/` & {}}` | ... 12 more ... | `/${string}/history/` argsResolveArgs<T>"/" | "/about" | "/docs" | "/docs/api" | "/docs/library" | "/history" | `${`/docs/api/${string}` & {}}` | `${`/docs/api/${string}/` & {}}` | `/${string}/` | `/${string}/about` | `/${string}/docs` | `/${string}/docs/api` | `/${string}/docs/library` | `/${string}/history` | ... 6 more ... | `/${string}/history/` (name_or_cli: string | Cli, args: string[] | undefined, cwd: string | URL | undefined, log?: Logger | undefined, options?: SpawnOptions | undefined): Promise<...> name_or_clistring | Cliargsstring[][]cwdstring | URL | undefinedlog?Logger | undefinedoptions?SpawnOptions | undefinedPromise<Cli | undefined> (path?: string): string Resolves a path to an internal Gro file. Prefers any local installation of Gro and falls back to the current CLI context.
Uses heuristics to find path, so may fail in some rare corner cases.
Currently looks for gro.js as a sibling to the path arg for detection.
If this fails for your usecases, rename gro.js or open an issue/PR!
Used by the CLI and gro run.
case 1:
We're in a directory that has a local installation of Gro at node_modules/.bin/gro.
Use this local version instead of the global.
case 2:
We're running Gro inside the Gro repo itself.
In this case, we use the build directory instead of dist.
There's a paradox here for using Gro inside itself -
ideally we use the dist directory because that's what's shipped,
but the build directory has all of the tests,
and loading two instances of its modules causes problems
like instanceof checks failing.
For now we'll just run from build and see if it causes any problems.
There's probably a better design in here somewhere.
case 3:
Fall back to invoking Gro from wherever the CLI is being executed. When using the global CLI, this uses the global Gro installation.
pathstring''string (resolved_input_paths: ResolvedInputPath[], search?: (dir: string) => Promise<ResolvedPath[]>): Promise<ResolvedInputFiles> Finds all of the matching files for the given input paths. De-dupes source ids.
resolved_input_pathsResolvedInputPath[]search(dir: string) => Promise<ResolvedPath[]>fs_searchPromise<ResolvedInputFiles> (input_paths: InputPath[], root_dirs: PathId[], extensions: string[]): Promise<ResolvedInputPaths> Gets the path data for each input path, checking the filesystem for the possibilities
and stopping at the first existing file or falling back to the first existing directory.
If none is found for an input path, it's added to unmapped_input_paths.
input_pathsInputPath[]root_dirsPathId[]extensionsstring[]Promise<ResolvedInputPaths> resolve_specifier.ts view source
(specifier: string, dir: string): Promise<ResolvedSpecifier> Maps an import specifier relative to dir,
and infer the correct extension following Vite conventions.
If no .js file is found for the specifier on the filesystem, it assumes .ts.
specifierstringdirstringPromise<ResolvedSpecifier> ResolvedInputFile idPathIdinput_pathresolved_input_pathResolvedInputFiles resolved_input_filesArray<ResolvedInputFile>resolved_input_files_by_root_dirMap<PathId, Array<ResolvedInputFile>>input_directories_with_no_filesArray<InputPath>ResolvedInputPath input_pathidPathIdis_directorybooleanroot_dirPathIdResolvedInputPaths resolved_input_pathsArray<ResolvedInputPath>possible_paths_by_input_pathMap<InputPath, Array<PossiblePath>>unmapped_input_pathsArray<InputPath>resolve_specifier.ts view source
ResolvedSpecifier path_idThe resolved filesystem path for the specifier.
PathIdpath_id_with_querystringSame as path_id but includes ?raw and other querystrings. (currently none)
stringspecifierstringmapped_specifierstringnamespaceundefined | 'sveltekit_local_imports_ts' | 'sveltekit_local_imports_js'rawbooleansveltekit_shim_app_paths.ts view source
<T extends RouteId | Pathname>(...args: ResolveArgs<T>) => "/" | "/about" | "/docs" | "/docs/api" | "/docs/library" | "/history" | `${`/docs/api/${string}` & {}}` | `${`/docs/api/${string}/` & {}}` | ... 12 more ... | `/${string}/history/` string (gen_modules: GenfileModuleMeta[], config: GroConfig, filer: Filer, log: Logger, timings: Timings, invoke_task: InvokeTask, format_file?: ((content: string, options: Options, base_options?: Options | ... 1 more ... | undefined) => Promise<...>) | undefined): Promise<...> gen_modulesGenfileModuleMeta[]configfilerlogLoggertimingsTimingsinvoke_taskformat_file?((content: string, options: Options, base_options?: Options | null | undefined) => Promise<string>) | undefinedPromise<GenResults> sveltekit_helpers.ts view source
(package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }, options: SveltePackageOptions | undefined, cli: string | Cli, log: Logger, pm_cli: string): Promise<...> package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }optionsSveltePackageOptions | undefinedclistring | ClilogLoggerpm_clistringPromise<void> (task_meta: TaskModuleMeta, unparsed_args: Args, invoke_task: (task_name: RawInputPath, args: Args | undefined, config: GroConfig, initial_filer?: Filer | undefined, initial_timings?: Timings | ... 1 more ... | undefined, parent_log?: Logger | undefined) => Promise<...>, config: GroConfig, filer: Filer, log: Logger, timings: Timings): Promise<...> task_metaunparsed_argsinvoke_task(task_name: RawInputPath, args: Args | undefined, config: GroConfig, initial_filer?: Filer | undefined, initial_timings?: Timings | null | undefined, parent_log?: Logger | undefined) => Promise<...>configfilerlogLoggertimingsTimingsPromise<RunTaskResult> RunTaskResult (metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }, log?: Logger | undefined): Promise<...> Saves build cache metadata to .gro/ directory. Errors are logged but don't fail the build (cache is optional).
metadata{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }log?Logger | undefinedPromise<void> RegExp The regexp used by default to exclude directories and files
when searching the filesystem for tasks and genfiles.
Customize via search_filters in the GroConfig.
See the test cases for the exact behavior.
(args: Args): string[] Serializes parsed Args for CLI commands.
argsstring[] (package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }): string package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }string "dist_server" gro_plugin_server.ts view source
PathId (gen_file_id: PathId, changed_file_id: PathId, config: GroConfig, filer: Filer, log: Logger, timings: Timings, invoke_task: InvokeTask): Promise<...> Check if a file change should trigger a gen file.
gen_file_idPathIdchanged_file_idPathIdconfigfilerlogLoggertimingsTimingsinvoke_taskPromise<boolean> This is used to tell Gro to exit silently, usually still with with a non-zero exit code. Using it means error logging is handled by the code that threw it.
Errorstring "src" (package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }, lib_path?: string | undefined, log?: Logger | undefined): Promise<...> package_json{ [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }lib_path?string | undefinedlog?Logger | undefinedPromise<{ [x: string]: unknown; name: string; version: string; modules?: { [x: string]: unknown; path: string; declarations?: { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; ... 19 more ...; alias_of?: { ...; } | undefined; }[] | ... (source_json: { [x: string]: unknown; name: string; version: string; modules?: { [x: string]: unknown; path: string; declarations?: { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; ... 19 more ...; alias_of?: { ...; } | undefined; }[] | undefined; module_comment?: string | undefined; dependencies?: string[] | undefined; dependents?: string[] | undefined; }[] | undefined; }): string source_json{ [x: string]: unknown; name: string; version: string; modules?: { [x: string]: unknown; path: string; declarations?: { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; ... 19 more ...; alias_of?: { ...; } | undefined; }[] | undefine...string (exports: string | Record<string, unknown> | null | undefined, lib_path?: string, log?: Logger | undefined): Promise<{ [x: string]: unknown; path: string; declarations?: { [x: string]: unknown; ... 21 more ...; alias_of?: { ...; } | undefined; }[] | undefined; module_comment?: string | undefined; dependencies?: string[] | undefined; dependents?: string[] | undefined; }[] | undefined> exportsstring | Record<string, unknown> | null | undefinedlib_pathstringpaths.liblog?Logger | undefinedPromise<{ [x: string]: unknown; path: string; declarations?: { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; doc_comment?: string | undefined; ... 18 more ...; alias_of?: { ...; } | undefined; }[] | undefined; module_comment?: str... SourceJsonMapper (name_or_cli: string | Cli, args?: string[], log?: Logger | undefined, options?: SpawnOptions | undefined): Promise<SpawnResult | undefined> Spawns a CLI if available using Belt's spawn.
If a string is provided for name_or_cli, it checks first local to the cwd and then globally.
name_or_clistring | Cliargsstring[][]log?Logger | undefinedoptions?SpawnOptions | undefinedPromise<SpawnResult | undefined> undefined if no CLI is found, or the spawn result
(name_or_cli: string | Cli, args?: string[], log?: Logger | undefined, options?: SpawnOptions | undefined): Promise<SpawnedProcess | undefined> Spawns a CLI if available using Belt's spawn_process.
If a string is provided for name_or_cli, it checks first local to the cwd and then globally.
name_or_clistring | Cliargsstring[][]log?Logger | undefinedoptions?SpawnOptions | undefinedPromise<SpawnedProcess | undefined> undefined if no CLI is found, or the spawn result
(loader_path: string, invoke_path: string, argv: string[], js_cli?: string): Promise<SpawnResult> Runs a file using the Gro loader.
Uses conditional exports to correctly set up esm-env as development by default,
so if you want production set NODE_ENV=production.
loader_pathpath to loader
stringinvoke_pathpath to file to spawn with node
stringargvstring[]js_clistringJS_CLI_DEFAULTPromise<SpawnResult> "svelte-check" "svelte.config.js" RegExp "svelte-package" "@sveltejs/package" RegExp RegExp Extracts the script content from Svelte files.
"build" "svelte-kit" ".svelte-kit" "dist" RegExp RegExp sveltekit_shim_app.ts view source
RegExp sveltekit_shim_app.ts view source
RegExp sveltekit_shim_app.ts view source
Map<string, string> Maps SvelteKit $app specifiers to their Gro shims.
sveltekit_helpers.ts view source
(sveltekit_cli?: string | Cli, pm_cli?: string): Promise<void> sveltekit_clistring | CliSVELTEKIT_CLIpm_clistringPM_CLI_DEFAULTPromise<void> sveltekit_helpers.ts view source
(sveltekit_cli?: string | Cli): Promise<void> If the SvelteKit CLI is found and its .svelte-kit directory is not, run svelte-kit sync.
sveltekit_clistring | CliSVELTEKIT_CLIPromise<void> sveltekit_helpers.ts view source
(sveltekit_cli?: string | Cli): Promise<void> If the SvelteKit CLI is found and its .svelte-kit directory is not, run svelte-kit sync.
sveltekit_clistring | CliSVELTEKIT_CLIPromise<void> string sveltekit_helpers.ts view source
SveltePackageOptions Options to the SvelteKit packaging CLI.
watchWatch files in src/lib for changes and rebuild the package
booleanwAlias for watch.
booleaninputThe input directory which contains all the files of the package. Defaults to src/lib
stringiAlias for input.
stringoutputThe output directory where the processed files are written to. Your package.json's exports should point to files inside there, and the files array should include that folder. Defaults to dist
stringoAlias for output.
stringtypesWhether or not to create type definitions (d.ts files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to true
booleantAlias for types.
booleantsconfigThe path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.
string(map_package_json: PackageJsonMapper, log: Logger, write?: boolean, dir?: string, exports_dir?: string): Promise<{ package_json: { [x: string]: unknown; name: string; version: string; ... 29 more ...; exports?: string | ... 2 more ... | undefined; } | null; changed: boolean; }> map_package_jsonlogLoggerwritebooleantruedirstringpaths.rootexports_dirstringpaths.libPromise<{ package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; ... 25 more ...; exports?: string | ... 2 more ... | undefined; } | null; changed: boolean; }> Task<TArgs, TArgsSchema, TReturn> TArgsTArgsSchemaz.ZodType<Args, Args>z.ZodType<Args, Args>TReturnunknownrun(ctx: TaskContext<TArgs>) => TReturn | Promise<TReturn>summarystringArgsTArgsSchema".task.js" ".task.ts" string[] TaskArgs watchbooleanTaskContext<TArgs> TArgsobjectargsTArgsconfigsvelte_configfilerlogLoggertimingsTimingsinvoke_taskThis is used by tasks to signal a known failure. It's useful for cleaning up logging because we usually don't need their stack trace.
ErrorTaskModule taskTaskModuleMeta ModuleMeta<TaskModule>namestring(cli: string | Cli): string clistring | Clistring ({ dev, generate, filename, rootDir, warningFilter, }: CompileOptions): ModuleCompileOptions __0CompileOptionsModuleCompileOptions esbuild_helpers.ts view source
(dev: boolean, base_url: "" | `/${string}` | undefined, ssr?: boolean, mode?: string): Record<string, string> Creates an esbuild define shim for Vite's import.meta\.env.
devbooleanbase_url- best-effort shim from SvelteKit's base to Vite's import.meta\.env.BASE_URL
"" | `/${string}` | undefinedssrbooleantruemodestringdev ? 'development' : 'production'Record<string, string> (command: string, raw_rest_args?: string[] | undefined, cache?: Record<string, Args | undefined>): Args Parses process.argv for the specified command, so given
gro taskname arg1 --arg2 -- eslint eslintarg1 --eslintarg2 -- tsc --tscarg1 --tscarg2
the command 'eslint' returns eslintarg1 --eslintarg2
and 'tsc' returns --tscarg1 and --tscarg2.
commandstringraw_rest_args?string[] | undefinedcacheRecord<string, Args | undefined>to_forwarded_args_by_command(raw_rest_args)Args (raw_rest_args?: string[]): Record<string, Args | undefined> raw_rest_argsstring[]to_raw_rest_args()Record<string, Args | undefined> (origin_id: PathId, raw_result: RawGenResult): GenResult origin_idPathIdraw_resultGenResult (data: BufferSource, algorithm?: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512"): Promise<string> dataBufferSourcealgorithm"SHA-1" | "SHA-256" | "SHA-384" | "SHA-512"'SHA-256'Promise<string> (command_to_strip?: string | undefined, raw_rest_args?: string[]): Args Gets all args after the first -- without assuming a command name.
This is useful for tasks that want to forward args directly to a tool
without requiring users to specify the tool name explicitly.
Optionally strips a specific command name if present for backward compatibility.
command_to_strip?string | undefinedraw_rest_argsstring[]to_raw_rest_args()Args (raw_input_path: RawInputPath, root_path?: string): InputPath Raw input paths are paths that users provide to Gro to reference files for tasks and gen.
A raw input path can be to a file or directory in the following forms:
- an absolute path, preserved
- an explicit relative path, e.g. ./src/foo, resolved to root_path which defaults to the cwd
- an implicit relative path, e.g. src/foo, preserved
- an implicit relative path prefixed with gro/, transformed to absolute in the Gro directory
Thus, input paths are either absolute or implicitly relative.
raw_input_pathroot_pathstringprocess.cwd()InputPath (raw_input_paths: RawInputPath[], root_path?: string | undefined): InputPath[] raw_input_pathsRawInputPath[]root_path?string | undefinedInputPath[] (filename: string): string filenamestringstring (paths: string[]): string | Record<string, unknown> | null pathsstring[]string | Record<string, unknown> | null (argv?: string[]): string[] Gets the array of raw string args starting with the first --, if any.
argvstring[]process.argvstring[] (id: PathId, p?: Paths): string idPathIdpinfer_paths(id)string (argv?: string[]): { task_name: string; args: Args; } Parses task_name and args from process.argv using mri,
ignoring anything after any --.
argvstring[]process.argv{ task_name: string; args: Args; } (id: PathId, task_root_dir: PathId, input_path: InputPath, root_path: PathId): string idPathIdtask_root_dirPathIdinput_pathroot_pathPathIdstring RegExp "tsconfig.json" (owner: string, repo: string, path?: string, token?: string | undefined, log?: Logger | undefined, cache?: Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }>): Promise<...> Updates a changelog produced by @changesets/changelog-git with better links and formatting.
It's similar to @changesets/changelog-github but doesn't require a token for light usage.
This may be better implemented as a standalone dependency
as an alternative to @changesets/changelog-git.
ownerstringrepostringpathstring'CHANGELOG.md'token?string | undefinedlog?Logger | undefinedcacheMap<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }>new Map()Promise<boolean> boolean indicating if the changelog changed
(update: (package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }) => { ...; } | ... 1 more ... | null, dir?: string, write?: boolean): Promise<...> Updates package.json. Writes to the filesystem only when contents change.
update(package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }) => { ...; } | ... 1 more ... ...dirstringpaths.rootwritebooleantruePromise<{ package_json: { [x: string]: unknown; name: string; version: string; private?: boolean | undefined; public?: boolean | undefined; description?: string | undefined; motto?: string | undefined; ... 25 more ...; exports?: string | ... 2 more ... | undefined; } | null; changed: boolean; }> sveltekit_shim_app_state.ts view source
{ readonly current: boolean; check(): Promise<boolean>; } (metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }): Promise<...> Validates that a cached build is still valid by checking stats and hashing outputs. Uses size as a fast negative check before expensive hashing. This is comprehensive validation to catch manual tampering or corruption.
metadata{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }Promise<boolean> (mod: Record<string, any>): mod is GenfileModule modRecord<string, any>boolean (config_module: any, config_path: string): asserts config_module is GroConfigModule config_moduleanyconfig_pathstringvoid (mod: Record<string, any>): mod is TaskModule modRecord<string, any>boolean sveltekit_shim_app_environment.ts view source
"TODO" "vite" "vite.config.ts" "vitest" ({ dir, on_change, filter, absolute, chokidar, ignored, }: WatchDirOptions): WatchNodeFs Watch for changes on the filesystem using chokidar.
__0WatchNodeFs WatchDirOptions dirstringon_changefilterPathFilter | null | undefinedchokidarChokidarOptionsabsoluteWhen false, returns the path relative to dir.
booleanignoredPattern to ignore files, merged into chokidar.ignored if also provided.
- undefined (default) ignores files matching .tmp. pattern
- null sets no default ignore pattern
- or some custom pattern
Matcher | nullWatcherChange typepathstringis_directorybooleanWatcherChangeCallback WatcherChangeType WatchNodeFs init() => Promise<void>close() => Promise<void>(gen_results: GenResults, analyzed_gen_results: AnalyzedGenResult[], log: Logger): Promise<void> gen_resultsanalyzed_gen_resultsAnalyzedGenResult[]logLoggerPromise<void> (serialized_package_json: string): Promise<void> serialized_package_jsonstringPromise<void>