@kitschpatrol/tweakpane-plugin-essentials
v0.2.2-fork.3
Published
Fork of @tweakpane/plugin-essentials with build optimizations.
Maintainers
Readme
@kitschpatrol/tweakpane-plugin-essentials
Fork of @tweakpane/plugin-essentials with build optimizations.
Overview
This is a fork of Hiroki Kokubun's @tweakpane/plugin-essentials with externalized dependencies.
This allows for smaller bundled file sizes in projects using multiple Tweakpane plugins.
It is published to NPM primarily for the Svelte Tweakpane UI project, with minimal changes beyond dependency externalization and the fixes listed below.
See the upstream readme for details on the original plugin and its usage.
Fork changes
- Publishes as
@kitschpatrol/tweakpane-plugin-essentialsinstead of@tweakpane/plugin-essentials. - Adds a
/liteexport that imports@tweakpane/coreinstead of bundling it so projects can share one copy ofcoreacross multiple plugins. - Exports public parameter types.
- Migrates the repository structure to align with the Tweakpane plugin template provided by @kitschpatrol/create-project, which includes:
- Incorporates a CubicBezier performance fix.
Getting started
Dependencies
The plugin requires Tweakpane 4.
The /lite export path imports @tweakpane/core rather than bundling it. It is installed as a dependency of this plugin, so only projects without a bundler need to provide it directly.
If you're using Svelte 4 or 5 as a front-end library, take a look at Svelte Tweakpane UI, which wraps Tweakpane in a set of Svelte-friendly components, including the <ButtonGrid>, <CubicBezier>, <IntervalSlider>, <RadioGrid>, and <FpsGraph> controls from this plugin.
Installation
Add it to your project:
npm install @kitschpatrol/tweakpane-plugin-essentialsUsage
import * as TweakpanePluginEssentials from '@kitschpatrol/tweakpane-plugin-essentials'
import { Pane } from 'tweakpane'
const pane = new Pane()
pane.registerPlugin(TweakpanePluginEssentials)
const parameters = { range: { min: 20, max: 80 } }
pane.addBinding(parameters, 'range', { min: 0, max: 100 })See the upstream usage examples for the other controls and their options.
To share core through your bundler, import @kitschpatrol/tweakpane-plugin-essentials/lite instead.
Implementation notes
The Rollup configuration provided in the Tweakpane plugin template does not externalize @tweakpane/core as a production dependency.
Instead, it gets built into the single-file plugin artifact, which is what's published to NPM and imported by plugin consumers. This makes it easy to import as an ES module from a URL, but means that larger projects importing multiple Tweakpane plugins end up with duplicate copies of the @tweakpane/core code, adding about ~100 Kb to the final minified build for each plugin after the first.
Externalizing this dependency allows build tools like vite to share a single instance of the @tweakpane/core code across multiple plugins.
If you're not using a bundler, direct ESM imports from URLs can still work by defining the @tweakpane/core dependency in an importmap.
Versioning
In addition to the dependency externalization change, this fork also includes dependency updates. In an effort to stay in sync with future upstream versions, release version numbers are tagged with a "fork" suffix and an incrementing number.
Contributing
Issues are welcome and appreciated.
Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs are unlikely to be merged.
This repository uses ksc to handle linting and formatting with the usual tools, plus mdat for readme placeholder expansion, and chagent to maintain the changelog.
License
Original plugin: MIT © Hiroki Kokubun
