THIS_IS_UNDEFINED warning persists on Rollup entry points despite context and moduleContext options
0 reputation · 02 Jul 2026, 04:47 UTC
Rollup wraps every bundled module, including the ES module entry point, in a function where this is undefined under strict mode. An entry point that references top-level this while expecting the global object then produces the documented THIS_IS_UNDEFINED warning, and the runtime binding stays undefined even when the warning is filtered out.
The context and moduleContext options are designed to control the this value for bundled modules, but in Rollup 4.x they do not affect the entry point wrapper. The warning can only be silenced globally through an onwarn handler, which hides the message without changing the actual binding, and no per-module suppression is documented.
Is there a supported configuration in Rollup 4.x that makes the entry point's this resolve to the global object or another configured value? If the entry wrapper is intentionally exempt from context and moduleContext, what is the recommended approach for entry points that genuinely depend on a non-undefined this?