Development
The following method is to improve the Gem development experience.
Language Support
Install extension:
Formatting
Prettier
prettier defaults to support the inline html/css template, but does not supportcss({}), use the following command to install prettier
To support the formatting of this style:
Biome
biome v2 defaults to support the inline html/css template, but does not supportcss({}).
HMR
HMR is available through
unplugin-gem (recommended)
Turn on hot in the bundler when it has a JS HMR host, then enable hmr. The plugin injects @mantou/gem/helper/hmr automatically:
Complete JavaScript HMR still needs a host that implements import.meta.webpackHot (webpack/Rspack) or import.meta.hot (Vite / experimental Rolldown). Rollup and esbuild only get the runtime so class updates stay compatible.
SWC plugin
When using
- Turn on
hotin the build tool, such as Webpack - Add
@mantou/gem/helper/hmrto the bundler entry (it must run before any element class is defined) - Enable
hmrin the SWC plugin config (true/"webpack-hot","import-meta-hot", or"module-hot")