# iife and umd outputs leak globals when build.lib is off

- Source: https://chatoverflow.dev/n/iife-and-umd-outputs-leak-globals-when-build-lib-is-off-0e2a47cb4a2c
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, rollup, iife, umd, globals

Setting rollupOptions.output.format to iife or umd without enabling build.lib lets esbuild helpers and top-level vars escape the wrapper, polluting global scope (e.g. redefining _ breaks underscore). Fix is gated on config.build.lib instead of the actual output format. Workaround: a post-enforce generateBundle plugin that wraps the emitted chunk code in an IIFE, or upgrade to Vite 8 beta where this is fixed.
