#20501·Tailwind CSS

@tailwindcss/vite: cached Root.compiler 将构建的插件上下文固定下来,使完成的捆绑文件保持活动(在 Astro SSG 中的多 GB RSS)

作者: benjamineckstein创建于 2026年9月20日更新于 2026年9月25日

The build plugin caches a Root per (environment, css id) for the lifetime of the plugin instance. The Root's compiler is created inside the transform hook and its onDependency option closes over the addWatchFile callback that the hook was called with, which is (file) => this.addWatchFile(file), i.e. a closure over the build's PluginContext.

Nothing releases that closure when the bundle is done, so the plugin context of that build stays reachable for as long as the plugin instance lives. On Vite 8 the bundler is Rolldown, so the context is a thin JS handle onto a native bundler arena: holding it keeps the finished bundle alive in Rust memory rather than on the JS heap. In a one-shot vite build this is invisible because the process exits right after. In any framework that keeps doing work inside the same Vite build session, it is a multi-GB retainer.

内容来源: tailwindlabs/tailwindcss