KitQL Documentation
repository·main·Indexed 19 days ago
https://github.com/jycouet/kitqlA collection of standalone libraries and Vite plugins designed to accelerate WebApp development. KitQL includes specialized packages such as @kitql/sveltekit, @kitql/helpers, @kitql/handles, and @kitql/eslint-config, as well as Vite plugins like vite-plugin-kit-routes, vite-plugin-watch-and-run, and vite-plugin-stripper. It features a modular architecture allowing developers to install only the specific tools they need, including a kitql-lint tool that orchestrates eslint, prettier, oxlint, and oxfmt.
What's inside KitQL
- KitQL is not a single monolithic library, but rather a collection of standalone libraries and tools designed to speed up WebApp development. Developers can pick and choose specific packages based on their needs rather than installing the entire suite.
Overview of @kitql/handles
mainThe@kitql/handlespackage is part of the KitQL ecosystem. KitQL is not a single monolithic library, but rather a collection of standalone libraries designed to work together.@kitql/handlesprovides specific functionality related to 'Handles' within this ecosystem.Overview of vite-plugin-stripper
mainvite-plugin-stripperis a Vite plugin designed to strip specific content from your code during the build process. It is part of the KitQL ecosystem, which is a collection of standalone libraries rather than a single monolithic framework.Compatibility with non-GraphQL projects
mainKitQL is not strictly tied to GraphQL. While the name might suggest a connection, most KitQL packages are independent of GraphQL and can be used in other types of projects. The 'QL' in KitQL is flexible and can stand for 'Quick Libraries', 'Quick Layer', or 'Quality of Life'.Configure kitql-lint tools and orchestration
mainThe
kitql-linttool orchestrates four optional tools. By default, it runseslintandprettier. You can customize the toolset using the-tflag.Available Tools:
eslint: Linter (handles Svelte rules, pnpm catalog rules, and custom rules).prettier: Formatter (supports all file types, including.svelte).oxlint: A faster Rust-based linter that covers most JS/TS rules.oxfmt: A faster Rust-based formatter (Note: does not support.sveltefiles yet).
Tool Selection Patterns:
- Default:
eslint+prettier. - Pure oxc (No Svelte support): Use
oxlintandoxfmt. - Recommended (Svelte + Full oxc): Use
oxlint,tsgolint,oxfmt,eslint, andprettier. When using this combo, enableoxlintintegration in your ESLint config to prevent duplicate work on.ts/.jsfiles. - Automatic Prettier Restriction: If
oxfmtis included in your toolset,prettierautomatically restricts its scope to**/*.sveltefiles, leaving all other file types tooxfmt.
# Default (eslint + prettier) kitql-lint # Recommended for Svelte (full oxc + svelte support) kitql-lint -t oxlint,tsgolint,oxfmt,eslint,prettier # Pure oxc (no .svelte support) kitql-lint -t oxlint,tsgolint,oxfmtConfigure watch patterns with absolute paths and globs
mainThe
watchproperty can be configured in several ways to target specific files or directories:- Glob patterns: Use globs to watch files under the root directory. Always use
path.resolveto ensure the pattern matches against the absolute path. - Specific files: Use
path.resolvewith a relative path to watch files outside the current project root (e.g., in a monorepo). - Dynamic matching: Provide a function as
watchthat is called with the filepath, allowing for custom logic to determine if a file should trigger the command.
// Watch all TypeScript files in the project { watch: path.resolve('**/*.ts') } // Watch a specific file outside the project root { watch: path.resolve('../../README.md') }- Glob patterns: Use globs to watch files under the root directory. Always use
How vite-plugin-stripper works
mainThe plugin leverages Vite'simport.meta.env.SSRconstant. By wrapping code inif (import.meta.env.SSR) { ... }, the client-side tree-shaker can drop the block during build.vite-plugin-stripperautomates this wrapping for decorator-based code (e.g., Remult's@BackendMethodor@Entityserver-only callbacks) so you don't have to manually wrap every method.Understanding the KitQL multi-package architecture
mainKitQL is distributed as a monorepo containing multiple specialized packages rather than a single monolithic library. This design allows you to install only the specific tools you need without pulling in unnecessary dependencies. Despite being split, all packages are designed to work together seamlessly using common principles.Install vite-plugin-watch-and-run
mainYou can install
vite-plugin-watch-and-runvia npm. This plugin is designed to work with Vite to provide watch-and-run capabilities.npm install vite-plugin-watch-and-runView @kitql/sveltekit documentation
mainDetailed documentation for the@kitql/sveltekitpackage, including usage guides and API references, can be found at the official KitQL documentation site.Configure vite-plugin-kit-routes in Vite
mainTo enable the plugin, import
kitRoutesfromvite-plugin-kit-routesand add it to thepluginsarray in yourvite.config.js(or equivalent configuration file).import { sveltekit } from '@sveltejs/kit/vite' import { kitRoutes } from 'vite-plugin-kit-routes' /** @type {import('vite').UserConfig} */ export default config = { plugins: [ sveltekit(), // ✅ Add the plugin kitRoutes(), ], }Install vite-plugin-stripper
mainInstall
vite-plugin-stripperas a development dependency to automate the removal of server-only code (like decorators) from your client-side browser bundle.npm i -D vite-plugin-stripper