Rollup "(!) Missing global variable name" for UMD/IIFE in CI
A UMD or IIFE bundle needs to reference each external dependency by a browser global name. When an external has no entry in output.globals, Rollup warns it is guessing the name, which is usually wrong for the produced bundle.
What this error means
A UMD/IIFE build prints "(!) Missing global variable name" listing externals like react and "Guessing 'React'", and the resulting bundle references the wrong globals.
(!) Missing global variable name
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to
external modules:
react (guessing "react")Common causes
Externals without a globals mapping
A UMD/IIFE output marks packages external but does not tell Rollup the global variable each maps to at runtime.
A new external added without updating globals
A dependency was externalized but output.globals was not extended to include its browser global name.
How to fix it
Provide output.globals for each external
- List the externals named in the warning.
- Map each to the global it exposes on
window. - Re-run so the UMD/IIFE bundle references the correct globals.
// rollup.config.js
export default {
external: ['react', 'react-dom'],
output: {
format: 'umd',
globals: { react: 'React', 'react-dom': 'ReactDOM' },
},
};Bundle the dependency instead
If you do not expect a global at runtime, remove it from external so Rollup includes it in the bundle.
How to prevent it
- Keep
output.globalsin sync with every external for UMD/IIFE. - Decide per dependency whether to externalize or bundle it.
- Use ESM output where browser globals are not required.