2.2.0 • Published 11 months ago

google-closure-library-bundler v2.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
11 months ago

Google Closure Library Bundler

Library for generating a Google Closure Library bundle, based on this demo.

Read more about the Google Closure Library here.

Install

npm install google-closure-library-bundler

Usage

  1. Create entry.js:
// for example
goog.require('goog.html.sanitizer.HtmlSanitizer.Builder')
goog.require('goog.html.sanitizer.unsafe')
  1. Create build.js:
const { bundle } = require('google-closure-library-bundler')
const { join } = require('path')

bundle('./entry.js', {
  path: join(__dirname, 'dist'),
  filename: 'goog.js',
  hashFunction: 'md5' // required for node 17+
}).then(() => {
  console.log('All bundled up!')
})
  1. Run build.js to create a bundle in dist/goog.js
  2. Include the bundle in your build:
import goog from './dist/goog'

// for example
const htmlSanitizerBuilder = new goog.html.sanitizer.HtmlSanitizer.Builder()

API

bundle(entry, output) => Promise<string>