Gro's SvelteKit library plugin
uses svelte-package
to build libraries from src/lib/ for publishing to npm.
The default config enables this plugin when all three conditions are met:
svelte.config.jsexists at the project rootsrc/lib/directory exists (or the path configured insvelte.config.js)@sveltejs/packageis listed inpackage.jsondependencies
Install to enable:
npm i -D @sveltejs/packageIn production (gro build), runs svelte-package during setup
to compile src/lib/ into dist/.
In development (gro dev), does nothing — svelte-package is a build-time tool.
During adapt, if package.json has a bin field,
the plugin makes the binaries executable and runs npm link -f
so CLI commands are available locally after building.
// gro.config.ts
import type {CreateGroConfig} from '@fuzdev/gro';
import {gro_plugin_sveltekit_library} from '@fuzdev/gro/gro_plugin_sveltekit_library.js';
const config: CreateGroConfig = async (cfg) => {
cfg.plugins = async () => [
// included in the default config when detection passes
gro_plugin_sveltekit_library({
// svelte_package_options: {output: 'custom_dist'},
// svelte_package_cli: 'svelte-package',
}),
];
return cfg;
};
export default config;Options are forwarded to svelte-package.
See SveltePackageOptions
and the SvelteKit packaging docs.
When this plugin is active, gro sync auto-generates package.json "exports"
using wildcard subpath patterns for .js, .ts, .svelte, .json, and .css files in src/lib/.
Customize via map_package_json in the config.
For the full publishing workflow, see publish.md.