Rspack plugin
Configure the Rspack class adapter, aliases, and shared compiler-hook behavior.
Install and configure
pnpm add -D @cookbook/router-rspack-pluginnpm install --save-dev @cookbook/router-rspack-pluginyarn add -D @cookbook/router-rspack-pluginbun add -d @cookbook/router-rspack-pluginimport { CookbookRouterRspackPlugin } from '@cookbook/router-rspack-plugin';
export default {
plugins: [new CookbookRouterRspackPlugin()],
};Exports
class CookbookRouterRspackPlugin implements RspackPluginInstance {
constructor(options?: CookbookRouterRspackPluginOptions);
apply(compiler: Compiler): void;
}
export { CookbookRouterRspackPlugin as CookbookRouterPlugin };
export default CookbookRouterRspackPlugin;CookbookRouterPlugin is an alias, not a second implementation.
Shared build-runner options
All plugins except Vite extend CookbookRouterBuilderPluginOptions from @cookbook/router-cli.
Prop
Type
The runner resolves command options, generates physical artifacts, and then resolves watch paths even after a failure. That last part is the recovery mechanism: a bad config should not make the plugin blind to the file that can repair it.
Generated artifacts
A successful aggregate run writes:
contracts.tsregister.d.tsmanifest.json
It writes routes.ts only when the loaded route input contains statically composable route exports. JSON-only or otherwise non-composable input can still produce contracts and a manifest without producing a runtime route module.
Precedence
- Explicit plugin options
- Values from
cookbook-router.config.* - Framework defaults
An explicit routeFiles or outDir is not merged with the config value. It replaces it.
Lifecycle and recovery
Rspack uses the same exported compiler-hook adapter as Webpack. Normal runs fail on bad generation. Watch runs report the error, keep the previous valid artifacts, register fallback dependencies, and retry after a relevant change.
Where this bites
Examples copied from Webpack are structurally similar, but import from the Rspack package. Mixing the packages can compile as configuration code and still hand the wrong plugin contract to the bundler.