Registry / web-framework / webpack-global-object-x

webpack-global-object-x

JSON →
library1.0.1jsnpmunverified

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-x
INSTALL
IMPORT
SIG · WEBPACK-GLOBAL-OBJ
W
webpack-global-object-x
web-frameworkjavascriptv1.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

globalObject
✓ const globalObject = require('webpack-global-object-x');
✗ import { globalObject } from 'webpack-global-object-x';
This package uses CommonJS and does not provide ESM exports. Use require() or enable CJS interop in your bundler.
default
✓ import globalObject from 'webpack-global-object-x';
✗ import { globalObject } from 'webpack-global-object-x';
If using a bundler that can import CommonJS as default, you can use default import. The named export does not exist.
function
✓ const globalObject = require('webpack-global-object-x'); const obj = globalObject();
✗ const obj = require('webpack-global-object-x'); // returns a function, not the object
The module exports a function that returns the global object. You must call it to get the value.

Shows how to use webpack-global-object-x in a webpack config to set the globalObject option for UMD bundles.

// webpack.config.js const globalObject = require('webpack-global-object-x'); module.exports = { output: { globalObject: '(' + globalObject.toString() + '())', library: 'MyLib', libraryTarget: 'umd' } };
Debug
Known issues
gotchaThe module exports a function, not the global object itself. You must call it to get the global object.
fix
Use globalObject() to obtain the actual global object.
affects: >=1.0.0
gotchaNo ESM export; cannot be imported with named import syntax in Node.js without CJS interop.
fix
Use require() or enable interop (e.g., createRequire/import from CommonJS).
affects: >=1.0.0
gotchaThe package is not actively maintained; last release was in 2018. May not support future webpack versions or newer JS environments.
fix
Consider alternatives like using built-in globalThis (available in Node 12+, modern browsers) or the 'global' npm module.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'webpack-global-object-x'
Package not installed or typo in package name.
fix
Run npm install webpack-global-object-x --save-dev
Uncaught TypeError: globalObject is not a function
Using the imported function without calling it.
fix
Change code to: const globalObject = require('webpack-global-object-x'); const obj = globalObject();
Module not found: Error: Can't resolve 'webpack-global-object-x' in ...
Attempting to import in a browser environment where require is not available.
fix
Use a bundler that supports CommonJS or pre-compile the package with your build tool.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
2
Resources
webpack-global-object-x — npm install webpack-global-object-x · libregistry