Skip to content

Commit

Permalink
feat: upgrade deps, use module.exports (#25)
Browse files Browse the repository at this point in the history
* feat: upgrade deps, use module.exports

* chore: pre-release version 1.142.0-0

* chore: fix repo url

* chore: include changelog in npm package

* chore: abort build if CJS support application fails

* chore: revert version bump
  • Loading branch information
dwbruhn authored Dec 5, 2023
1 parent 270e0f1 commit d4a4aa8
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor
test/output/
package-lock.json
node_modules
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.142.0

* Upgraded to Google Closure Compiler and Library 20230802.0.0
* Client: Replaced global scope modification with proper CJS support using module.exports

## 1.141.0

* Metadata:
Expand Down
16 changes: 16 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e # abort on failure

# Clean files
echo "Removing generated files..."
rm -f client/index.js
Expand Down Expand Up @@ -38,6 +40,8 @@ util/metadataExtractor.js vendor/libphonenumber/javascript/i18n/phonenumbers/met
echo "Compiling with Google Closure Compiler..."
npx google-closure-compiler --version
npx google-closure-compiler \
--isolation_mode=IIFE \
--assume_function_wrapper \
--compilation_level=ADVANCED \
--warning_level=DEFAULT \
--js_output_file=client/index.js \
Expand All @@ -55,6 +59,8 @@ npx google-closure-compiler \
--js=node_modules/google-closure-library/closure/goog/dom/htmlelement.js \
--js=node_modules/google-closure-library/closure/goog/dom/nodetype.js \
--js=node_modules/google-closure-library/closure/goog/dom/safe.js \
--js=node_modules/google-closure-library/closure/goog/asserts/dom.js \
--js=node_modules/google-closure-library/closure/goog/dom/element.js \
--js=node_modules/google-closure-library/closure/goog/dom/tagname.js \
--js=node_modules/google-closure-library/closure/goog/dom/tags.js \
--js=node_modules/google-closure-library/closure/goog/fs/blob.js \
Expand All @@ -70,6 +76,10 @@ npx google-closure-compiler \
--js=node_modules/google-closure-library/closure/goog/html/uncheckedconversions.js \
--js=node_modules/google-closure-library/closure/goog/i18n/bidi.js \
--js=node_modules/google-closure-library/closure/goog/labs/useragent/browser.js \
--js=node_modules/google-closure-library/closure/goog/labs/useragent/useragent.js \
--js=node_modules/google-closure-library/closure/goog/flags/flags.js \
--js=node_modules/google-closure-library/closure/goog/labs/useragent/highentropy/highentropyvalue.js \
--js=node_modules/google-closure-library/closure/goog/labs/useragent/highentropy/highentropydata.js \
--js=node_modules/google-closure-library/closure/goog/labs/useragent/util.js \
--js=node_modules/google-closure-library/closure/goog/object/object.js \
--js=node_modules/google-closure-library/closure/goog/proto2/descriptor.js \
Expand All @@ -84,4 +94,10 @@ npx google-closure-compiler \
--js=node_modules/google-closure-library/closure/goog/string/stringbuffer.js \
--js=node_modules/google-closure-library/closure/goog/string/typedstring.js

# Replace global this modification with module.exports
echo "Patching client code to support CJS module.exports..."
grep '}).call(this);$' client/index.js >/dev/null || (echo "ERROR: Failed to apply CJS support. Please check bin/build.sh" && exit 1)
sed -i.bk 's/}).call(this);$/}).call(module.exports);/' client/index.js
rm client/index.js.bk

echo "Done."
Loading

0 comments on commit d4a4aa8

Please sign in to comment.