Registry / web-framework / google-closure-library

google-closure-library

JSON →
library20230802.0.0jsnpmunverified

Google Closure Library is a comprehensive, low-level JavaScript library developed by Google for building complex, highly performant, and scalable web applications. It serves as the foundation for many of Google's own web properties, including Gmail, Google Docs, and Google Maps. The library is not a typical npm package with standard ES module exports but rather provides its own module system (`goog.require`, `goog.provide`) built around a global `goog` object. It ships with a vast array of utilities covering DOM manipulation, UI components, networking, internationalization, data structures, and more. The current stable version is 20230802.0.0, and it follows a roughly monthly to bi-monthly release cadence, providing continuous updates and improvements, often tied to internal Google development cycles. Its key differentiators include its robust type system (when used with Closure Compiler), extensive cross-browser compatibility layers, and a strong emphasis on performance and security, making it suitable for large-scale enterprise applications.

npm install google-closure-library
INSTALL
IMPORT
SIG · GOOGLE-CLOSURE-LIB
G
google-closure-library
web-frameworkjavascriptv20230802.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

goog
require('google-closure-library');
import goog from 'google-closure-library';
In Node.js, `google-closure-library` is primarily consumed by requiring the package, which sets up the global `goog` object and its module system. Direct ES module imports for the `goog` object itself are not supported.
goog.crypt.Sha1
require('google-closure-library'); goog.require('goog.crypt.Sha1');
import { Sha1 } from 'google-closure-library/goog/crypt/sha1';
Closure Library components are exposed through the `goog.require` mechanism after the base library has been loaded. They are not designed for direct file-path based ES module or CommonJS imports.
goog.ui.Dialog
require('google-closure-library'); goog.require('goog.ui.Dialog');
const Dialog = require('google-closure-library/goog/ui/dialog');
Accessing specific Closure Library components requires using `goog.require` after initializing the library. Attempting to directly CommonJS `require` internal paths will fail as they rely on the Closure compiler's dependency management.

This quickstart demonstrates how to initialize Closure Library in a Node.js environment, load specific components using `goog.require`, and use them to perform a SHA-1 hash operation.

require('google-closure-library'); goog.require('goog.crypt.Sha1'); goog.require('goog.array'); const sha1 = new goog.crypt.Sha1(); const data = 'Hello, Closure Library!'; sha1.update(data); const hash = sha1.digest(); console.log(`SHA-1 hash of '${data}': ${goog.array.map(hash, byte => byte.toString(16).padStart(2, '0')).join('')}`); // Example of a utility that might not be available directly in Node.js // goog.require('goog.dom'); // console.log(goog.dom.getWindow()); // This would typically only work in a browser environment
Debug
Known issues
breakingThe debug loader no longer downlevels sources in the browser, and `transpile.js` has been deleted. This affects development workflows that relied on in-browser transpilation.
fix
Migrate to a downleveling development server (e.g., using Babel or TypeScript compilation) for transpilation during development. Do not rely on the Closure Library's debug loader for this functionality.
affects: >=20220803
breakingSupport for Internet Explorer 10 (IE10) has been officially dropped.
fix
Ensure your target browsers exclude IE10. Applications requiring IE10 compatibility should stick to older versions of Closure Library or implement polyfills independently.
affects: >=20221102
deprecated`SafeHtml.create`, `SafeHtml.createScript`, `SafeHtml.setObjectData`, and `SafeHtml.setFrameSrc` methods are deprecated due to security considerations and to encourage safer templating practices.
fix
It is strongly recommended to use a dedicated and secure templating system like Lit or an alternative approach that avoids direct string concatenation for HTML generation. Review and update existing code to use safer alternatives.
affects: >=20221102
breakingThe `defaultImpl` parameter has been removed from Closure Delegates helper methods, which may break existing delegate implementations.
fix
Update delegate helper method calls to no longer pass the `defaultImpl` parameter. Review the Closure Library documentation for updated usage patterns.
affects: >=20230228
breakingThe `closure/html` types' constructors have been made private, preventing direct instantiation.
fix
Instead of direct constructor calls, use static factory methods or other provided mechanisms to create instances of `closure/html` types. Refer to the specific API documentation for the correct instantiation patterns.
affects: >=20230502
deprecated`goog.dom.safe.setImageSrc` has been deleted.
fix
Directly assign to `imageElement.src` instead: `imageElement.src = url;`.
affects: >=20220905
Errors
Common errors & fixes
ReferenceError: goog is not defined
The base Closure Library file (and thus the global `goog` object) has not been loaded or initialized.
fix
In Node.js, ensure you have `require('google-closure-library');` at the top of your script. In a browser, ensure `base.js` is loaded via a `<script>` tag before any code that uses `goog`.
Error: 'goog.some.Component' not found
The specified Closure Library component has not been loaded using `goog.require`, or there's a typo in the component path, or the component doesn't exist.
fix
Verify the component name and path. Ensure `goog.require('goog.some.Component');` is called before attempting to use the component. If using the Closure Compiler, ensure the component is part of your compiled output.
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax with Closure Library components, which are not exposed as standard ES modules.
fix
Use the Closure Library's native `goog.require()` system after loading the base library via CommonJS `require('google-closure-library');` in Node.js, or a script tag for `base.js` in browsers.
Upgrade
Version history
20230802.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
google-closure-library — npm install google-closure-library · libregistry