sveltekit_helpers.ts

view source

Declarations
#

8 declarations

has_sveltekit_app
#

sveltekit_helpers.ts view source

(package_json: { [x: string]: unknown; name: string; version?: string | undefined; private?: boolean | undefined; description?: string | undefined; tagline?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }): Result<...> import {has_sveltekit_app} from '@fuzdev/gro/sveltekit_helpers.js';

Detected from package.json rather than the Svelte config, because reading the config costs a full Vite config resolution. Peer deps don't count - a package peered on SvelteKit is built to work with one, not to be one, and counting them would run vite build over a library that has no app.

package_json

type PackageJson

returns

Result

has_sveltekit_library
#

sveltekit_helpers.ts view source

(package_json: { [x: string]: unknown; name: string; version?: string | undefined; private?: boolean | undefined; description?: string | undefined; tagline?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }): Promise<...> import {has_sveltekit_library} from '@fuzdev/gro/sveltekit_helpers.js';

package_json

type PackageJson

returns

Promise<Result>

run_svelte_package
#

sveltekit_helpers.ts view source

(package_json: { [x: string]: unknown; name: string; version?: string | undefined; private?: boolean | undefined; description?: string | undefined; tagline?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }, options: SveltePackageOptions | undefined, cli: string | Cli, log: Logger, pm_cli: string): Promise<...> import {run_svelte_package} from '@fuzdev/gro/sveltekit_helpers.js';

package_json

type PackageJson

options

type SveltePackageOptions | undefined

cli

type string | Cli

log

type Logger

pm_cli

type string

returns

Promise<void>

sveltekit_sync
#

sveltekit_helpers.ts view source

(sveltekit_cli?: string | Cli, pm_cli?: string): Promise<void> import {sveltekit_sync} from '@fuzdev/gro/sveltekit_helpers.js';

sveltekit_cli

type string | Cli
default SVELTEKIT_CLI

pm_cli

type string
default PM_CLI_DEFAULT

returns

Promise<void>

sveltekit_sync_if_available
#

sveltekit_helpers.ts view source

(sveltekit_cli?: string | Cli): Promise<void> import {sveltekit_sync_if_available} from '@fuzdev/gro/sveltekit_helpers.js';

If the SvelteKit CLI is found, run svelte-kit sync.

sveltekit_cli

type string | Cli
default SVELTEKIT_CLI

returns

Promise<void>

sveltekit_sync_if_obviously_needed
#

sveltekit_helpers.ts view source

(sveltekit_cli?: string | Cli): Promise<void> import {sveltekit_sync_if_obviously_needed} from '@fuzdev/gro/sveltekit_helpers.js';

If the SvelteKit CLI is found and either its .svelte-kit directory or its generated $app/tsconfig is not, run svelte-kit sync. The tsconfig is checked because it lives in node_modules, which reinstalls wipe.

sveltekit_cli

type string | Cli
default SVELTEKIT_CLI

returns

Promise<void>

sveltekit_tsconfig_is_unsynced
#

sveltekit_helpers.ts view source

(dir: string): Promise<boolean> import {sveltekit_tsconfig_is_unsynced} from '@fuzdev/gro/sveltekit_helpers.js';

Whether dir's tsconfig.json extends SvelteKit's $app/tsconfig while the generated node_modules/$app/tsconfig.json is missing - the project was never synced, or a reinstall wiped node_modules. TypeScript doesn't fail on an unresolved extends, so tools reading such a tsconfig silently run on default compiler options and read external types as any.

Reads the tsconfig as JSONC with TypeScript's own parser and accepts a string or array extends. Only dir's own tsconfig.json is checked, not configs it extends. A missing tsconfig, or one TypeScript's tolerant parser recovers no extends from, returns false, left to whatever reads it next.

dir

absolute path to the project root

type string

returns

Promise<boolean>

true when the project needs svelte-kit sync

SveltePackageOptions
#

sveltekit_helpers.ts view source

SveltePackageOptions import type {SveltePackageOptions} from '@fuzdev/gro/sveltekit_helpers.js';

Options to the SvelteKit packaging CLI.

see also

watch?

Watch files in src/lib for changes and rebuild the package

type boolean

w?

Alias for watch.

type boolean

input?

The input directory which contains all the files of the package. Defaults to src/lib

type string

i?

Alias for input.

type string

output?

The 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

type string

o?

Alias for output.

type string

types?

Whether or not to create type definitions (d.ts files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to true

type boolean

t?

Alias for types.

type boolean

tsconfig?

The path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.

type string

Depends on
#

Imported by
#