{"id":20772,"library":"webpack-global-object-x","title":"webpack-global-object-x","description":"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.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/Xotic750/webpack-global-object-x","tags":["javascript","webpack","globalObject","module","nodejs","browser"],"install":[{"cmd":"npm install webpack-global-object-x","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-global-object-x","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-global-object-x","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package uses CommonJS and does not provide ESM exports. Use require() or enable CJS interop in your bundler.","wrong":"import { globalObject } from 'webpack-global-object-x';","symbol":"globalObject","correct":"const globalObject = require('webpack-global-object-x');"},{"note":"If using a bundler that can import CommonJS as default, you can use default import. The named export does not exist.","wrong":"import { globalObject } from 'webpack-global-object-x';","symbol":"default","correct":"import globalObject from 'webpack-global-object-x';"},{"note":"The module exports a function that returns the global object. You must call it to get the value.","wrong":"const obj = require('webpack-global-object-x'); // returns a function, not the object","symbol":"function","correct":"const globalObject = require('webpack-global-object-x');\nconst obj = globalObject();"}],"quickstart":{"code":"// webpack.config.js\nconst globalObject = require('webpack-global-object-x');\n\nmodule.exports = {\n  output: {\n    globalObject: '(' + globalObject.toString() + '())',\n    library: 'MyLib',\n    libraryTarget: 'umd'\n  }\n};","lang":"javascript","description":"Shows how to use webpack-global-object-x in a webpack config to set the globalObject option for UMD bundles."},"warnings":[{"fix":"Use globalObject() to obtain the actual global object.","message":"The module exports a function, not the global object itself. You must call it to get the global object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use require() or enable interop (e.g., createRequire/import from CommonJS).","message":"No ESM export; cannot be imported with named import syntax in Node.js without CJS interop.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider alternatives like using built-in globalThis (available in Node 12+, modern browsers) or the 'global' npm module.","message":"The package is not actively maintained; last release was in 2018. May not support future webpack versions or newer JS environments.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':28 '2018':34 'browser':20,82 'bundl':65 'call':41 'configur':17,59 'correct':10 'current':24 'depend':52 'detect':75 'differenti':66 'environ':74 'focus':68 'function':38 'global':3,11,44,46 'globalobject':16,79 'independ':70 'intend':54 'javascript':77 'librari':76 'lightweight':50 'modul':80 'node.js':19 'nodej':81 'object':4,12,45 'output.globalobject':62 'provid':8 'releas':29 'return':36 'runtim':73 'self':47 'set':61 'simpl':67 'sinc':33 'stabl':25 'support':18 'umd':64 'updat':32 'use':56 'util':6 'version':26 'web':22 'webpack':2,14,58,78 'webpack-global-object-x':1 'worker':23 'x':5 'yield':42","created_at":"2026-04-25T11:24:54.043830+00:00","updated_at":"2026-04-25T11:24:54.043830+00:00","problems":[{"fix":"Run npm install webpack-global-object-x --save-dev","cause":"Package not installed or typo in package name.","error":"Error: Cannot find module 'webpack-global-object-x'"},{"fix":"Change code to: const globalObject = require('webpack-global-object-x'); const obj = globalObject();","cause":"Using the imported function without calling it.","error":"Uncaught TypeError: globalObject is not a function"},{"fix":"Use a bundler that supports CommonJS or pre-compile the package with your build tool.","cause":"Attempting to import in a browser environment where require is not available.","error":"Module not found: Error: Can't resolve 'webpack-global-object-x' in ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Xotic750/webpack-global-object-x","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/webpack-global-object-x","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}