An ECMAScript spec-compliant polyfill/shim for the globalThis object.
System.global is an ECMAScript spec-compliant polyfill/shim for the `globalThis` object, which is the standard way to access the global object in JavaScript. It solves the problem of inconsistent global object access across different JavaScript environments (like browsers, Node.js, or older engines) by providing a reliable implementation that works everywhere.
JavaScript developers and library authors who need to write cross-environment code that accesses the global object reliably, especially those supporting older or non-standard environments.
Developers choose System.global because it is the most spec-compliant and reliable polyfill for `globalThis`, with strict adherence to the ECMAScript standard, support for ES3 environments, and integration with the es-shim ecosystem for consistency.
ECMAScript spec-compliant polyfill/shim for globalThis.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements the exact behavior defined in the ECMAScript specification and the globalThis proposal, ensuring reliability and consistency across all JavaScript environments. The README emphasizes it is 'spec-compliant' and follows the proposal closely.
Works in environments that only support ECMAScript 3, making it suitable for legacy browsers and older engines. The README explicitly states it 'works in an ES3-supported environment'.
Follows the es-shim API interface, allowing seamless integration with other shims in the ecosystem for a consistent polyfill experience. The package implements this API as noted in the README.
Provides examples and approaches that consider Content Security Policy restrictions, helping developers write compliant code. The README includes a CSP-related example with a note on compliance.
Some methods used to access the global object, such as Function constructors, may not be CSP-compliant, limiting its use in strict security environments. The README example admits a function is 'not CSP-compliant'.
In modern environments where globalThis is natively supported, using this polyfill adds extra code without benefit, increasing bundle size and potential performance costs.
Patching the global object with a shim can lead to conflicts with other libraries or code that assumes different global access methods, introducing subtle bugs.