Utility to provide the correct global object for webpack's globalObject configuration, supporting Node.js, browsers, and Web Workers. Current stable version is 1.0.1, released with no updates since 2018. It returns a function that, when called, yields the global object (`global`, `self`, or `this`). Lightweight (no dependencies) and intended for use in webpack configuration to set `output.globalObject` for UMD bundles. Differentiators: simple, focused, and independent of any runtime environment detection library.
npm install webpack-global-object-xVerified import paths — ran on the pinned version, not inferred.
Shows how to use webpack-global-object-x in a webpack config to set the globalObject option for UMD bundles.
Use globalObject() to obtain the actual global object.
Use require() or enable interop (e.g., createRequire/import from CommonJS).
Consider alternatives like using built-in globalThis (available in Node 12+, modern browsers) or the 'global' npm module.
Run npm install webpack-global-object-x --save-dev
Change code to: const globalObject = require('webpack-global-object-x'); const obj = globalObject();Use a bundler that supports CommonJS or pre-compile the package with your build tool.
No dependency data recorded yet.