Skip to content

Commit

Permalink
feat(closure): using new version of the closure compiler
Browse files Browse the repository at this point in the history
And moving towards `@export`ing symbols and other cleanups

fix #65
  • Loading branch information
grantila committed Sep 25, 2021
1 parent 12dce20 commit 99b201c
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 143 deletions.
53 changes: 53 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

BASEDIR=.
CLOSURE_LIBRARY_DIR=${BASEDIR}/node_modules/google-closure-library

COMPILATION_LEVEL=ADVANCED_OPTIMIZATIONS

node_modules/.bin/google-closure-compiler \
--compilation_level=${COMPILATION_LEVEL} \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/array/array.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/asserts/asserts.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/base.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/debug/error.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/asserts.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/htmlelement.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/nodetype.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/safe.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/tagname.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/dom/tags.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/fs/blob.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/fs/url.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/functions/functions.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/safehtml.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/safescript.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/safestyle.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/safestylesheet.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/safeurl.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/trustedresourceurl.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/trustedtypes.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/html/uncheckedconversions.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/i18n/bidi.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/labs/useragent/browser.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/labs/useragent/util.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/object/object.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/descriptor.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/fielddescriptor.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/lazydeserializer.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/message.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/pbliteserializer.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/proto2/serializer.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/string/const.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/string/internal.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/string/string.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/string/stringbuffer.js \
--js=${CLOSURE_LIBRARY_DIR}/closure/goog/string/typedstring.js \
--js="build/libphonenumber/javascript/i18n/phonenumbers/**.js" \
--js="!build/libphonenumber/javascript/i18n/phonenumbers/**_test.js" \
--js="!build/libphonenumber/javascript/i18n/phonenumbers/demo*.js" \
--js="!build/libphonenumber/javascript/i18n/phonenumbers/metadatafortesting.js" \
--js="!build/libphonenumber/javascript/i18n/phonenumbers/metadatalite.js" \
--js="!build/libphonenumber/javascript/i18n/phonenumbers/regioncodefortesting.js" \
--js=src/index.js \
--js_output_file=lib/index.js
16 changes: 5 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const replace = require( 'replace' );
const libphonenumberVersion =
fs.readFileSync( 'libphonenumber.version', 'utf8' ).toString( ).trim( );

const buildRoot = './build';
const rootDir = '.';
const buildRoot = `${rootDir}/build`;
const libphonenumberUrl = 'https://github.com/google/libphonenumber/';
const closureLibraryUrl = 'https://github.com/google/closure-library/';
const closureLinterUrl = 'https://github.com/google/closure-linter';
const pythonGflagsUrl = 'https://github.com/google/python-gflags.git';
const antName = 'apache-ant-1.10.11';
Expand All @@ -34,10 +34,6 @@ gulp.task( 'clone-libphonenumber', gulp.series( 'make-build-dir', ( ) =>
gitClone( libphonenumberUrl, 'libphonenumber', libphonenumberVersion )
) );

gulp.task( 'clone-closure-library', gulp.series( 'make-build-dir', ( ) =>
gitClone( closureLibraryUrl, 'closure-library', 'v20171112' )
) );

gulp.task( 'checkout-closure-linter', gulp.series( 'make-build-dir', ( ) =>
gitClone( closureLinterUrl, 'closure-linter' )
) );
Expand All @@ -64,18 +60,16 @@ gulp.task( 'download-ant', gulp.series(

gulp.task( 'download-deps', gulp.parallel(
'clone-libphonenumber',
'clone-closure-library',
'checkout-closure-linter',
'checkout-python-gflags',
'download-ant'
) );

gulp.task( 'build-deps', gulp.series( 'download-deps' ) );

gulp.task( 'build-libphonenumber', ( ) => {
var args = [ '-f', 'build.xml', 'compile-exports' ];
return runCommand( `${buildRoot}/${antName}/bin/ant`, args, { cwd: '.' } );
} );
gulp.task( 'build-libphonenumber', ( ) =>
runCommand( `${rootDir}/build.sh`, [ ], { cwd: rootDir } )
);

gulp.task( 'build', gulp.series( 'build-deps', 'build-libphonenumber' ) );

Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = require( './lib' ).PhoneNumber;

Object.defineProperty(
Expand Down
Loading

0 comments on commit 99b201c

Please sign in to comment.