Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

funte/google-closure-deps-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-closure-deps-webpack-plugin

This plugin not support anymore, all functionality has combine to google-closure-library-webpack-plugin!!

Webpack plugin for generating Google Closure deps, work with google-closure-library-webpack-plugin.

Note: donnot use Google Closure in babel js file(end with jsx)!! But if you stick it, just replace the regex with r'^.+\.jsx?$', this code is under <your project>/node_modules/google-closure-library/closure/bin/build/treescan.py:

# Matches a .js file path.
_JS_FILE_REGEX = re.compile(r'^.+\.js$')

usage

Case these files in your project are written with Google Closure:

// <your project>/src/hello.js
goog.require('goog.dom');
goog.require('goog.dom.TagName');

var ele = goog.dom.createDom(goog.dom.TagName.P, {}, "hello world!!");

export { ele };
// <your project>/src/index.js
import {ele} from './lib/hello.js';

document.body.append(ele);

Config webpack with:

const GCLibraryPlugin = require('google-closure-library-webpack-plugin');
const GCDepsPlugin = require('google-closure-deps-webpack-plugin');

module.exports = {
  // ...
  plugins: [
      new GCDepsPlugin({
        output: '.tmp/deps.js',
        source: {
          roots: ['src'],
        },
        goog: 'node_modules/google-closure-library/closure/goog/base.js',
        python: 'python'
      }),
      new GCLibraryPlugin({
        closureLibraryBase: require.resolve(
          'google-closure-library/closure/goog/base'
        ),
        deps: [
          require.resolve('google-closure-library/closure/goog/deps'),
          // path for generated depenencies file.
          '.tmp/deps.js',
        ],
      })
    ]
}

example

options

  • output
    Full path for Closure deps.js file
  • source
    • roos
      Directories list for search dependencies
    • jsPaths
      JavaScript sources files for search dependencies
    • excludes
      Excludes files list
  • goog
    Path to Closure Library bootstrap file base.js
  • python
    "python3", "/usr/bin/python3" or something

More visit https://developers.google.com/closure/library.

About

Webpack plugin for generating Google Closure deps, work with `closure-webpack-plugin`.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published