Rollup "Missing global variable name" - Fix UMD Externals in CI
For UMD/IIFE output, every external dependency must map to a browser global. When you mark a module external but do not tell Rollup its global name, it warns "Missing global variable name" and guesses - producing a bundle that references the wrong global at runtime.
What this error means
A UMD/IIFE Rollup build prints (!) Missing global variable name for each external (e.g. react), with "Use "output.globals" to specify ... Guessing 'React'". The bundle builds but may break in the browser.
(!) Missing global variable names
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to external modules:
react (guessing "React")
react-dom (guessing "ReactDOM")Common causes
Externals without output.globals
A UMD/IIFE build externalizes dependencies (so they are not bundled) but does not declare the global each maps to, so Rollup cannot reference them correctly.
Wrong global name guessed
Rollup's guess (capitalized package name) is often wrong (e.g. react-dom is ReactDOM, not ReactDom), so the runtime global lookup fails.
How to fix it
Declare output.globals for every external
Map each external to its real browser global name.
// rollup.config.js
export default {
external: ['react', 'react-dom'],
output: {
format: 'umd',
name: 'MyLib',
globals: { react: 'React', 'react-dom': 'ReactDOM' },
},
}Use an output format that does not need globals
- If you do not need UMD/IIFE, build
es/cjswhere externals do not require globals. - For libraries, ship
es+cjsand let consumers bundle, avoiding UMD globals entirely. - Provide
output.namefor the UMD bundle itself when you do keep UMD.
How to prevent it
- Always pair UMD/IIFE externals with
output.globals. - Verify global names against each library's real UMD global.
- Prefer
es/cjsoutputs unless a UMD global is genuinely required.