Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created October 23, 2023 07:22
Show Gist options
  • Save v6ak/4b8c57e9e2c50b3def0f2dfc341bfeae to your computer and use it in GitHub Desktop.
Save v6ak/4b8c57e9e2c50b3def0f2dfc341bfeae to your computer and use it in GitHub Desktop.
#!/bin/bash
# safety settings
set -u
set -e
set -o pipefail
function run {
version="$1"
if [ "$version" == "" ]; then
version_spec=""
version_spec_u=""
version_human="the newest version"
else
version_spec="@$version"
version_spec_u="_$version"
version_human="$version"
fi
echo "Running for $version_human"
npx google-closure-compiler$version_spec \
-O ADVANCED \
--language_in=ES_NEXT \
--language_out=ES_NEXT \
--module_resolution=NODE \
--dependency_mode=PRUNE \
--chunk_output_type=ES_MODULES \
--js other-module.js --chunk om$version_spec_u:1 \
--js main.js --chunk mainopt$version_spec_u:1:om$version_spec_u \
--entry_point main.js \
--js_output_file opt$version_spec.js
# --js some-module.js --chunk sm$version_spec_u:1 \
echo "DONE: opt$version_spec.js ($version_human)"
}
if [ $# == 0 ]; then
# Run in the newest version + version currently used in Scala.js
for version_spec in v20220202 "" ; do
run "$version_spec"
done
else
# Run in the specified versions
for version_spec in "$@"; do
run "$version_spec"
done
fi
// just a stub of an imported module
/**
* @type {Object}
*/
var bar;
export { bar };
//import * as foo = from "./other-module.js";
(async () => {
const foo = await import("./other-module.js");
foo["bar"]();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment