npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-closure-library-webpack-plugin

v2.2.5

Published

Webpack plugin for google-closure-library, inspired from closure-webpack-plugin

Downloads

321

Readme

google-closure-library-webpack-plugin

Webpack5 plugin for google-closure-library, inspired from closure-webpack-plugin.

This plugin transpile the Closure module to ES and CommonJS module, no need to install google-closure-compiler.

Now support google-closure-library@<=20220502.0.0, webpack@>=5.21.0, Webpack watch mode and these goog APIs:

🎉🎉🎉This plugin is still maintained, welcom to create issue if you find bugs or has any expectant feature🎉🎉🎉

Install

npm install google-closure-library-webpack-plugin --save-dev

Examples

Here are many examples that can download, build and run it.

Options

base : optional string type, defaults to node_modules/google-closure-library/closure/goog/base.js

Path to Closure library base.js file, must be absolute or relative from the Webpack context.

sources : required string or array type

List of absolute patterns, or relative from the Webpack context. You can use the negative patterns(start with !) ignore files or directories.
Supported glob features see minimatch#features.

target : optional "esm" or "commonjs", defaults to "esm"

Closure module transform target, "esm" or "commonjs", defaults to "esm".

defs : optional array type

List of string and value to override the goog.define expression in Closure library, e.g. source goog.LOCALE = goog.define('goog.LOCALE', 'en'); will be converted to goog.LOCALE = 'zh'; with defs option defs: [["goog.LOCALE", "zh"]].
If the value part is omitted, its value will be true, the value could be string, boolean and number.
Because limited with my programming skills, i cannot make the defaultValue parameter support more data types, so this functionality will be disallowed outside Closure library modules, but you can still use this option overwrite the goog.* names, recommend the same functionality Webpack DefinePlugin.

warningLevel: optional "hide", "hideLib", "hideUser" and "hide", defaults to "hideLib"

"show" show all warnings, "hidelib" hide warnings in Closure library modules and show warnings in user modules, "hideUser" opposite to "hideLib", "hide" hide all warnings, defualts to "hideLib".

debug.logTransformed : optional boolean type, defaults to false

Enable log transformed Closure module to build directory, defaults to false.

Something important

💊Speedup the Webpack building process with deps file

Everytime when start the building process by the Webpack build command, this plugin will search and parse all files found in the sources options. Obviously, it's very expensive and unnecessary, but if you specific a deps file like the deps.js in Closure library, this plugin will make a quick through and skip the parsing work until its requied by the goog.require statement.
How speedup building process with deps file, see example deps.

💊How test your code, is the goog.testing still work?

No, but you can still use it with goog.addDependency load and execute JsUnit tests in an unbundled, uncompiled browser environment, see example test.
Also you can directly test the Webpack bundle file with mocha and other tools.

💊Influenced symbols in compiled base.js file

  • COMPILED will be stripped and replaced with constant true, e.g. this code if(!COMPILED) { } will be converted to if(!true) { };
  • goog.DEBUG defaults to false;
  • Replace goog.global with Webpack options.output.globalObject;

Error case

TODO: add error case.

TODOS

These features will add to next version.

  • ✔ ClosureTree.check;
  • More test, test more Closure library modules;
  • Check whether unexposed namespace(except Closure library modules) outside PROVIDE and legacy GOOG module has dot serparator, like this:
    // X: in this GOOG module, namespace "a.b.c" not exposed but has dot separator, should error.
    goog.module("a.b.c");
  • Check whether unexposed namespce(except Closure library modules) outside PROVIDE and legacy GOOG module duplicate with other exposed namespace, like this:
    // a.js
    // In this GOOG module, namespace "a" not exposed.
    goog.module("a");
    
    // b.js
    // X: in this PROVIDE module, namespace "a.b" exposed and will construct a duplicated implicit namespace "a", should error.
    goog.provide("a.b");
  • ClosureModuleParserPlugin support JS/TS/JSX;
  • Export ClosureModuleLoader, remove the injection from LoaderPlugin;
  • Support soy template?
  • Parse annotations?

News