diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 00000000000..5d256adf48f
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,40 @@
+version: 2
+jobs:
+ build:
+ working_directory: ~/repo
+ docker:
+ - image: circleci/openjdk:8-jdk-stretch
+ environment:
+ MAVEN_OPTS: -Xmx3200m
+ _JAVA_OPTIONS: "-Xms1g -Xmx1g"
+ steps:
+ - checkout
+ - run:
+ name: environment check
+ command: |
+ java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
+ env MAVEN_OPTS="-XX:+PrintFlagsFinal" mvn -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
+ mvn -version
+
+ # Download and cache dependencies
+ - restore_cache:
+ keys:
+ - v1-dependencies-{{ checksum "pom.xml" }}
+ # fallback to using the latest cache if no exact match is found
+ - v1-dependencies-
+
+ - run: mvn deploy -s .circleci/settings.xml -Dartifactory.username=$ARTIFACTORY_USER -Dartifactory.password=$ARTIFACTORY_APIKEY
+
+ - save_cache:
+ paths:
+ - ~/.m2
+ key: v1-dependencies-{{ checksum "pom.xml" }}
+
+
+
+workflows:
+ version: 2
+ ci_build:
+ jobs:
+ - build:
+ context: deploy-keys
\ No newline at end of file
diff --git a/.circleci/settings.xml b/.circleci/settings.xml
new file mode 100644
index 00000000000..74a7c1cf2da
--- /dev/null
+++ b/.circleci/settings.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ vertispan-snapshots
+ ${artifactory.username}
+ ${artifactory.password}
+
+
+
+
diff --git a/.github/ci_support/test_closure-compiler-npm.sh b/.github/ci_support/test_closure-compiler-npm.sh
index 779ff6c4566..57544008df4 100755
--- a/.github/ci_support/test_closure-compiler-npm.sh
+++ b/.github/ci_support/test_closure-compiler-npm.sh
@@ -20,7 +20,7 @@
# - PWD = closure-compiler-npm repo root
#
# Params:
-# 1. File name of compiler_unshaded_deploy.jar
+# 1. File name of compiler_uberjar_deploy.jar
function main() {
local compiler_jar="$1"
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index baac2f86164..8ff9cd4234e 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -51,7 +51,7 @@ jobs:
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
# https://github.com/bazelbuild/setup-bazelisk
- uses: bazelbuild/setup-bazelisk@v2
@@ -63,7 +63,7 @@ jobs:
# upload-artifact doesn't support paths with symlinks
run: |
mkdir -p ${{ env.UNSYMLINK_DIR }}
- cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/compiler_unshaded_deploy.jar
+ cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/compiler_uberjar_deploy.jar
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/*_bundle.jar
# Share the following files with other jobs in this workflow. They can be grabbed using ID
@@ -74,7 +74,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: unshaded_compiler
- path: ${{ env.UNSYMLINK_DIR }}/compiler_unshaded_deploy.jar
+ path: ${{ env.UNSYMLINK_DIR }}/compiler_uberjar_deploy.jar
if-no-files-found: error
# If this build will be uploadaded as a SNAPSHOT, share the Sonatype bundles with the other
@@ -104,7 +104,7 @@ jobs:
# Clone closure-compiler-npm repo from master into the current directory.
- name: Checkout Current closure-compiler-npm Commit
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
repository: google/closure-compiler-npm
ref: master
@@ -113,7 +113,7 @@ jobs:
# submodule
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
path: compiler
@@ -128,7 +128,7 @@ jobs:
path: compiler/bazel-bin
- name: Test closure-compiler-npm
- run: compiler/.github/ci_support/test_closure-compiler-npm.sh compiler/bazel-bin/compiler_unshaded_deploy.jar
+ run: compiler/.github/ci_support/test_closure-compiler-npm.sh compiler/bazel-bin/compiler_uberjar_deploy.jar
deploy-snapshots:
name: Deploy Snapshot Bundles to Sonatype
@@ -152,7 +152,7 @@ jobs:
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
diff --git a/BUILD.bazel b/BUILD.bazel
index 952a851ebde..a70d1dda7e5 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -44,9 +44,9 @@ sonatype_artifact_bundle(
sonatype_artifact_bundle(
name = "compiler_unshaded_bundle",
artifact_id = "closure-compiler-unshaded",
- jar = ":compiler_unshaded_deploy.jar",
+ jar = ":compiler_unshaded",
javadoc = ":compiler_lib_no_runtime_libs.javadoc",
- pom = "maven/closure-compiler-unshaded.pom.xml",
+ pom = ":compiler_unshaded-pom",
sources = ":compiler_lib_no_runtime_libs.sources",
)
@@ -71,16 +71,28 @@ sonatype_artifact_bundle(
jar_jar(
name = "compiler_shaded",
- input_jar = ":compiler_unshaded_deploy.jar",
+ input_jar = ":compiler_uberjar_deploy.jar",
rules = "rules.jarjar",
)
java_binary(
- name = "compiler_unshaded",
+ name = "compiler_uberjar",
main_class = "com.google.javascript.jscomp.CommandLineRunner",
runtime_deps = [":compiler_lib"],
)
+# Produce an unshaded export jar based on :compiler_lib
+load("@rules_jvm_external//:defs.bzl", "java_export")
+version = "$(COMPILER_VERSION)" or "1.0-SNAPSHOT"
+java_export(
+ name = "compiler_unshaded",
+ maven_coordinates = "com.google.javascript:closure-compiler-unshaded:{0}".format(version),
+ runtime_deps = [
+ "//:compiler_lib",
+ ],
+ pom_template = "maven/closure-compiler-unshaded.pom.xml.tpl"
+)
+
java_binary(
name = "linter",
main_class = "com.google.javascript.jscomp.LinterMain",
@@ -173,7 +185,7 @@ oss_java_library(
"@com_google_errorprone_error_prone_annotations",
"@com_google_guava_failureaccess//jar",
"@com_google_guava_guava//jar",
- "@com_google_protobuf//:protobuf_java",
+ "@maven//:com_google_protobuf_protobuf_java",
"@com_google_re2j_re2j",
"@google_bazel_common//third_party/java/auto:value",
"@org_apache_ant_ant",
@@ -238,7 +250,7 @@ gen_java_tests(
"@com_google_guava_guava//jar",
"@com_google_guava_guava_testlib//jar",
"@com_google_jimfs_jimfs",
- "@com_google_protobuf//:protobuf_java",
+ "@maven//:com_google_protobuf_protobuf_java",
"@com_google_re2j_re2j",
"@com_google_truth_extensions_truth_liteproto_extension",
"@com_google_truth_extensions_truth_proto_extension",
diff --git a/README.md b/README.md
index 0f755a3bea5..3b11a852310 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,33 @@ analyzes it, removes dead code and rewrites and minimizes what's left. It also
checks syntax, variable references, and types, and warns about common JavaScript
pitfalls.
+---
+
+This is Vertispan LLC's fork of the Closure Compiler targeted to support J2CL,
+which includes a few changes from Google's original repository, including:
+
+ * Externs that specifically match various stable versions of Elemental2.
+ * Sourcemap support for BUNDLE optimization levels.
+ * Include defines in BUNDLE output.
+ * Restore the `PersistentInputStore` API - note that with the introduction of
+ the (experimental) `TypedAst` feature, we may drop this soon.
+
+As the upstream project undergoes regular tagged releases, the Vertispan
+releases in turn will be versioned and tagged to match them, following a pattern
+of `-`, where the `` is the tag that
+Google released, followed by ``, an integer to increment for each
+tagged release - when a new Closure Compiler release is released, the release
+count will reset to `1`. Note that not all upstream tags will necessarily get an
+associated Vertispan release. Later releases off of the same upstream tag will
+then increment that count, should they be needed.
+
+The release process is to rebase this set of commits, then update the version in
+the poms appropriately. When a release is pushed to Maven Central, a tag will
+be pushed to our git repository with a matching version. Snapshot releases will
+use a `-SNAPSHOT` suffix after the release count.
+
+---
+
## Getting Started
The easiest way to install the compiler is with [NPM](https://npmjs.com) or
@@ -232,7 +259,7 @@ you're most comfortable with.
### Building from a terminal
```bash
-$ bazelisk build //:compiler_unshaded_deploy.jar
+$ bazelisk build //:compiler_uberjar_deploy.jar
# OR to build everything
$ bazelisk build :all
```
@@ -265,7 +292,7 @@ directory. You can access it with a call to `java -jar ...` or by using the
package.json script:
```bash
-# java -jar bazel-bin/compiler_unshaded_deploy.jar [...args]
+# java -jar bazel-bin/compiler_uberjar_deploy.jar [...args]
yarn compile [...args]
```
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index cbaa888b0be..261a572de97 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -12,6 +12,12 @@ http_archive(
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)
+load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
+rules_jvm_external_deps()
+
+load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
+rules_jvm_external_setup()
+
#
# To update google_bazel_common, locate the git commit to depend on and
# use something like the following to determine the sha256
@@ -164,3 +170,15 @@ http_archive(
load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories")
jar_jar_repositories()
+
+# Declare protobuf-java from maven central, so the unshaded maven jar can recognize external dependencies
+load("@rules_jvm_external//:defs.bzl", "maven_install")
+maven_install(
+ artifacts = [
+ "com.google.protobuf:protobuf-java:3.19.3",
+ ],
+ repositories = [
+ "https://repo1.maven.org/maven2",
+ ],
+ strict_visibility = True,
+)
diff --git a/bazel/sonatype_artifact_bundle.bzl b/bazel/sonatype_artifact_bundle.bzl
index 703d1a4608b..b13f3e91a82 100644
--- a/bazel/sonatype_artifact_bundle.bzl
+++ b/bazel/sonatype_artifact_bundle.bzl
@@ -35,18 +35,18 @@ Returns:
_bundle.jar: The bundle JAR
"""
-_SNAPSHOT = "1.0-SNAPSHOT"
+_SNAPSHOT = "0.3-SNAPSHOT"
def _sonatype_artifact_bundle(ctx):
version = ctx.var.get("COMPILER_VERSION", _SNAPSHOT)
password = None
generate_signatures = True
- if version == _SNAPSHOT:
+ if version.endswith("-SNAPSHOT"):
# A SNAPSHOT version can't be uploaded as a release
# and thus doesn't need to be signed
generate_signatures = False
- elif not version.startswith("v") or not version[1:].isdigit():
+ elif not version.startswith("v"):
fail("--define=COMPILER_VERSION was malformed; got '{0}'".format(version))
else:
password = _fail_missing_define(ctx, "CLEARTEXT_GPG_PASSPHRASE")
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 00000000000..c8a6df51ed6
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Deployment script modeled roughly after upstream's js deployment wiring,
+# this file runs the bazel command to produce bundles, then immediately
+# unbundles the zip and deploys each artifact. This script differs slightly
+# in that it uses gpg:sign-and-deploy-file to handle attaching signatures,
+# and only uploads the artifacts that Vertispan is presently interested in.
+
+set -e
+
+DEFAULT_DEPLOY_URL=https://repo.vertispan.com/j2cl/
+DEFAULT_DEPLOY_REPO_ID=vertispan-snapshots
+
+VERSION=${1:-HEAD-SNAPSHOT}
+DEPLOY_URL=${2:-$DEFAULT_DEPLOY_URL}
+DEPLOY_REPO_ID=${3:-$DEFAULT_DEPLOY_REPO_ID}
+
+#TODO Find another way to pass in gpg passphrase - apparently
+# this is the only way bazel can work with parameters passed
+# in? Also, it is unnecessary, since we have to call sign-and-deploy-file
+# anyway to let maven upload without manually pushing a
+# bundle, so it is unnecessary.
+# It might be easier to modify the .bzl instead of supporting
+# this, and just have bazel produce the jars+poms.
+bazel build //:sonatype_bundles --define=COMPILER_VERSION=$VERSION --define=CLEARTEXT_GPG_PASSPHRASE=$CLEARTEXT_GPG_PASSPHRASE
+
+
+if [ -z "$CLEARTEXT_GPG_PASSPHRASE" ]; then
+ GOAL="deploy:deploy-file"
+else
+ GOAL="gpg:sign-and-deploy-file"
+fi
+
+mkdir tmp
+cd tmp
+
+mkdir parent
+unzip -n ../bazel-bin/closure-compiler-parent_bundle.jar -d parent
+mvn $GOAL -Dfile=parent/pom.xml -DpomFile=parent/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID
+
+
+mkdir main
+unzip -n ../bazel-bin/closure-compiler-main_bundle.jar -d main
+mvn $GOAL -Dfile=main/pom.xml -DpomFile=main/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID
+
+
+mkdir unshaded
+unzip -n ../bazel-bin/closure-compiler-unshaded_bundle.jar -d unshaded
+mvn $GOAL -Dfile=unshaded/closure-compiler-unshaded-${VERSION}.jar -Djavadoc=unshaded/closure-compiler-unshaded-${VERSION}-javadoc.jar -Dsources=unshaded/closure-compiler-unshaded-${VERSION}-sources.jar -DpomFile=unshaded/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID
+
+
+cd -
+rm -rf tmp
\ No newline at end of file
diff --git a/externs/browser/cspviolationobserver_externs.js b/externs/browser/cspviolationobserver_externs.js
new file mode 100644
index 00000000000..77ce701059f
--- /dev/null
+++ b/externs/browser/cspviolationobserver_externs.js
@@ -0,0 +1,86 @@
+/**
+ * @license
+ * Copyright The Closure Library Authors.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/**
+ * @fileoverview Externs used by cspviolationobserver.js that are not available
+ * in the open-source Closure compiler release. This file should be deleted
+ * once w3c_reporting_observer.js is available in open-source externs.
+ *
+ * @externs
+ */
+
+// TODO(user): Remove this file once w3c_reporting_observer.js is
+// available in the open-source Closure compiler.
+
+/**
+ * https://w3c.github.io/reporting/#interface-reporting-observer
+ * @constructor
+ * @param {!ReportingObserverCallback} callback
+ * @param {!ReportingObserverOptions} opts
+ */
+function ReportingObserver2(callback, opts) {}
+/** @return {void} */
+ReportingObserver2.prototype.observe = function() {};
+/** @return {void} */
+ReportingObserver2.prototype.disconnect = function() {};
+/** @return {!Array} */
+ReportingObserver2.prototype.takeRecords = function() {};
+
+/**
+ * @typedef {ReportingObserver2|ReportingObserver}
+ * @suppress {duplicate}
+ */
+var ReportingObserver;
+
+
+/**
+ * @typedef {!function(!Array, !ReportingObserver): void}
+ * @suppress {duplicate}
+ */
+var ReportingObserverCallback;
+
+
+/**
+ * @constructor
+ */
+function ReportingObserverOptions2() {}
+/** @type {undefined|!Array} */
+ReportingObserverOptions2.prototype.types;
+/** @type {boolean} */
+ReportingObserverOptions2.prototype.buffered;
+
+/**
+ * @typedef {ReportingObserverOptions2|ReportingObserverOptions}
+ * @suppress {duplicate}
+ */
+var ReportingObserverOptions;
+
+
+/**
+ * @constructor
+ * @suppress {duplicate}
+ */
+function Report2() {}
+/** @type {string} */ Report2.prototype.type;
+/** @type {string} */ Report2.prototype.url;
+/** @type {?ReportBody} */ Report2.prototype.body;
+
+/**
+ * @typedef {Report2|Report}
+ * @suppress {duplicate}
+ */
+var Report;
+
+
+/**
+ * @constructor
+ */
+function ReportBody2() {}
+
+/**
+ * @typedef {ReportBody2|ReportBody2}
+ * @suppress {duplicate}
+ */
+var ReportBody;
diff --git a/externs/browser/elemental2-1.1.0-hack.js b/externs/browser/elemental2-1.1.0-hack.js
new file mode 100644
index 00000000000..d8abbfaf674
--- /dev/null
+++ b/externs/browser/elemental2-1.1.0-hack.js
@@ -0,0 +1,54 @@
+/**
+ * @fileoverview Describes types present in elemental2 1.1.0 that are not in closure-compiler, since they aren't
+ * real browser types. Presently this only contains the `WebWorker` type which never existed as a browser type,
+ * but showed up in closure-compiler as a typo or early draft or something. As long as elemental2 1.1.0 is
+ * supported, we must keep this file in our closure-compiler fork.
+ *
+ * TODO Remove this once elemental2 1.1.0 is considered to be unsupported by j2cl - this day may not come soon,
+ * if ever, as it is a "stable" release.
+ *
+ * @externs
+ */
+
+/**
+ * @see http://dev.w3.org/html5/workers/
+ * @constructor
+ * @implements {EventTarget}
+ */
+function WebWorker() {}
+
+/** @override */
+WebWorker.prototype.addEventListener = function(type, listener, opt_options) {};
+
+/** @override */
+WebWorker.prototype.removeEventListener = function(
+ type, listener, opt_options) {};
+
+/** @override */
+WebWorker.prototype.dispatchEvent = function(evt) {};
+
+/**
+ * Stops the worker process
+ * @return {undefined}
+ */
+WebWorker.prototype.terminate = function() {};
+
+/**
+ * Posts a message to the worker thread.
+ * @param {string} message
+ * @return {undefined}
+ */
+WebWorker.prototype.postMessage = function(message) {};
+
+/**
+ * Sent when the worker thread posts a message to its creator.
+ * @type {?function(!MessageEvent<*>): void}
+ */
+WebWorker.prototype.onmessage;
+
+/**
+ * Sent when the worker thread encounters an error.
+ * @type {?function(!ErrorEvent): void}
+ */
+WebWorker.prototype.onerror;
+
diff --git a/externs/browser/w3c_dom1.js b/externs/browser/w3c_dom1.js
index cb0537cefed..bb46db33918 100644
--- a/externs/browser/w3c_dom1.js
+++ b/externs/browser/w3c_dom1.js
@@ -390,6 +390,14 @@ Document.prototype.createDocumentFragment = function() {};
*/
Document.prototype.createElement = function(tagName, opt_typeExtension) {};
+/**
+ * @param {string} name
+ * @return {!EntityReference}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createEntityReference
+ * @nosideeffects
+ */
+Document.prototype.createEntityReference = function(name) {};
+
/**
* @param {string} target
* @param {string} data
@@ -795,12 +803,75 @@ function CDATASection() {}
*/
function DocumentType() {}
+/**
+ * @type {NamedNodeMap}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1788794630
+ */
+DocumentType.prototype.entities;
+
/**
* @type {string}
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1844763134
*/
DocumentType.prototype.name;
+/**
+ * @type {NamedNodeMap}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D46829EF
+ */
+DocumentType.prototype.notations;
+
+/**
+ * @constructor
+ * @extends {Node}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-5431D1B9
+ */
+function Notation() {}
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-54F2B4D0
+ */
+Notation.prototype.publicId;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-E8AAB1D0
+ */
+Notation.prototype.systemId;
+
+/**
+ * @constructor
+ * @extends {Node}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-527DCFF2
+ */
+function Entity() {}
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D7303025
+ */
+Entity.prototype.publicId;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D7C29F3E
+ */
+Entity.prototype.systemId;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-6ABAEB38
+ */
+Entity.prototype.notationName;
+
+/**
+ * @constructor
+ * @extends {Node}
+ * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-11C98490
+ */
+function EntityReference() {}
+
/**
* @constructor
* @extends {Node}
diff --git a/externs/browser/w3c_dom3.js b/externs/browser/w3c_dom3.js
index c87a840ebed..4912b04fb85 100644
--- a/externs/browser/w3c_dom3.js
+++ b/externs/browser/w3c_dom3.js
@@ -72,6 +72,52 @@ DOMStringList.prototype.contains = function(str) {};
*/
DOMStringList.prototype.item = function(index) {};
+/**
+ * @constructor
+ * @implements {IArrayLike}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList
+ */
+function NameList() {}
+
+/**
+ * @type {number}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList-length
+ */
+NameList.prototype.length;
+
+/**
+ * @param {string} str
+ * @return {boolean}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList-contains
+ * @nosideeffects
+ */
+NameList.prototype.contains = function(str) {};
+
+/**
+ * @param {?string} namespaceURI
+ * @param {string} name
+ * @return {boolean}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList-containsNS
+ * @nosideeffects
+ */
+NameList.prototype.containsNS = function(namespaceURI, name) {};
+
+/**
+ * @param {number} index
+ * @return {string}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList-getName
+ * @nosideeffects
+ */
+NameList.prototype.getName = function(index) {};
+
+/**
+ * @param {number} index
+ * @return {string}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#NameList-getNamespaceURI
+ * @nosideeffects
+ */
+NameList.prototype.getNamespaceURI = function(index) {};
+
/**
* @constructor
* @implements {IArrayLike}
@@ -553,3 +599,21 @@ DocumentType.prototype.publicId;
* @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-Core-DocType-systemId
*/
DocumentType.prototype.systemId;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#Entity3-inputEncoding
+ */
+Entity.prototype.inputEncoding;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#Entity3-encoding
+ */
+Entity.prototype.xmlEncoding;
+
+/**
+ * @type {string}
+ * @see http://www.w3.org/TR/DOM-Level-3-Core/core.html#Entity3-version
+ */
+Entity.prototype.xmlVersion;
diff --git a/externs/browser/w3c_rtc.js b/externs/browser/w3c_rtc.js
index f68a5ae96bc..7febd88508c 100644
--- a/externs/browser/w3c_rtc.js
+++ b/externs/browser/w3c_rtc.js
@@ -1821,6 +1821,43 @@ RTCIceServerInterface_.prototype.credential;
*/
var RTCIceServer;
+//WORKAROUND for elemental2 - we need to keep these externs around as long as elemental2-dom 1.1.0 is a going concern
+/**
+ * @typedef {{
+ * iceServers: !Array,
+ * iceTransportPolicy: (string|undefined),
+ * sdpSemantics: (string|undefined)
+ * }}
+ * @private
+ */
+var RTCConfigurationRecord_;
+
+/**
+ * @interface
+ * @private
+ */
+function RTCConfigurationInterface_() {}
+/**
+ * @type {!Array}
+ */
+RTCConfigurationInterface_.prototype.iceServers;
+
+/**
+ * Allows specifying the ICE transport policy. Valid values are "all" and
+ * "relay", with "all" being the default.
+ * @type {string|undefined}
+ */
+RTCConfigurationInterface_.prototype.iceTransportPolicy;
+/**
+ * Allows specifying the SDP semantics. Valid values are "plan-b" and
+ * "unified-plan".
+ *
+ * @see {@link https://webrtc.org/web-apis/chrome/unified-plan/}
+ * @type {string|undefined}
+ */
+RTCConfigurationInterface_.prototype.sdpSemantics;
+//END WORKAROUND
+
/**
* @record
* @see https://www.w3.org/TR/webrtc/#dom-rtcconfiguration
diff --git a/maven/closure-compiler-externs.pom.xml b/maven/closure-compiler-externs.pom.xml
index 9c9c062368a..3e7ac7594cd 100644
--- a/maven/closure-compiler-externs.pom.xml
+++ b/maven/closure-compiler-externs.pom.xml
@@ -19,17 +19,17 @@
>
4.0.0
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-externs
jar
Closure Compiler Externs
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-parent
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
closure-compiler-parent.pom.xml
diff --git a/maven/closure-compiler-main.pom.xml b/maven/closure-compiler-main.pom.xml
index a685a4cb3b8..7de576e8900 100644
--- a/maven/closure-compiler-main.pom.xml
+++ b/maven/closure-compiler-main.pom.xml
@@ -19,12 +19,12 @@
>
4.0.0
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-main
pom
Closure Compiler Main
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
https://developers.google.com/closure/compiler/
@@ -38,9 +38,9 @@
2009
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-parent
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
closure-compiler-parent.pom.xml
diff --git a/maven/closure-compiler-parent.pom.xml b/maven/closure-compiler-parent.pom.xml
index 3e7bf54b6a4..e44fee94365 100644
--- a/maven/closure-compiler-parent.pom.xml
+++ b/maven/closure-compiler-parent.pom.xml
@@ -18,14 +18,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
4.0.0
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-parent
pom
Closure Compiler Parent
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
- https://github.com/google/closure-compiler/
+ https://github.com/vertispan/closure-compiler/
Closure Compiler is a JavaScript optimizing compiler. It parses your
JavaScript, analyzes it, removes dead code and rewrites and minimizes
@@ -33,6 +33,11 @@
warns about common JavaScript pitfalls. It is used in many of Google's
JavaScript apps, including Gmail, Google Web Search, Google Maps, and
Google Docs.
+ This distribution is slightly modified from the original for easier use
+ with J2CL outside of Bazel by Vertispan LLC. The links and references in
+ this pom.xml will reference the Vertispan fork, to ensure that any error
+ introduced by our changes are not incorrectly blamed on the upstream
+ Google repository.
2009
@@ -42,31 +47,32 @@
- scm:git:https://github.com/google/closure-compiler.git
+ scm:git:https://github.com/vertispan/closure-compiler.git
- scm:git:git@github.com:google/closure-compiler.git
+ scm:git:git@github.com:vertispan/closure-compiler.git
- https://github.com/google/closure-compiler
+ https://github.com/vertispan/closure-compiler
- code.google.com
- http://github.com/google/closure-compiler/issues
+ GitHub Issues
+ http://github.com/vertispan/closure-compiler/issues
-
- Google
- http://www.google.com
-
-
closure-compiler-authors
Closure Compiler Authors
- closure-compiler-discuss@googlegroups.com
+ closure-compiler-discuss@googlegroups.com
+
+
+ Colin Alworth
+ colin@vertispan.com
+ Vertispan LLC
+ https://www.vertispan.com/
diff --git a/maven/closure-compiler-unshaded.pom.xml b/maven/closure-compiler-unshaded.pom.xml.tpl
similarity index 88%
rename from maven/closure-compiler-unshaded.pom.xml
rename to maven/closure-compiler-unshaded.pom.xml.tpl
index 84b5fdb3cf1..ca5ea5bfb4a 100644
--- a/maven/closure-compiler-unshaded.pom.xml
+++ b/maven/closure-compiler-unshaded.pom.xml.tpl
@@ -19,12 +19,12 @@
>
4.0.0
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-unshaded
jar
Closure Compiler Unshaded
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
https://developers.google.com/closure/compiler/
@@ -38,9 +38,12 @@
2009
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-main
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
closure-compiler-main.pom.xml
+
+{dependencies}
+
diff --git a/maven/closure-compiler.pom.xml b/maven/closure-compiler.pom.xml
index 00fd1057d77..d816d534ffb 100644
--- a/maven/closure-compiler.pom.xml
+++ b/maven/closure-compiler.pom.xml
@@ -19,12 +19,12 @@
>
4.0.0
- com.google.javascript
+ com.vertispan.javascript
closure-compiler
jar
Closure Compiler
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
https://developers.google.com/closure/compiler/
@@ -38,9 +38,9 @@
2009
- com.google.javascript
+ com.vertispan.javascript
closure-compiler-main
- 1.0-SNAPSHOT
+ 0.3-SNAPSHOT
closure-compiler-main.pom.xml
diff --git a/package.json b/package.json
index 78ec64adf40..dd6e9516adc 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,6 @@
"jsdom": "^16.3.0"
},
"scripts": {
- "compile": "java -jar bazel-bin/compiler_unshaded_deploy.jar"
+ "compile": "java -jar bazel-bin/compiler_uberjar_deploy.jar"
}
}
diff --git a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
index 8f0ab2c012e..8a80603aca2 100644
--- a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
@@ -49,6 +49,7 @@
import com.google.javascript.jscomp.deps.SourceCodeEscapers;
import com.google.javascript.jscomp.ijs.IjsErrors;
import com.google.javascript.jscomp.parsing.Config;
+import com.google.javascript.rhino.IR;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.StaticSourceFile.SourceKind;
import com.google.javascript.rhino.TokenStream;
@@ -77,6 +78,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
@@ -285,7 +287,7 @@ protected CommandLineConfig getCommandLineConfig() {
*/
@GwtIncompatible("Unnecessary")
protected abstract void prepForBundleAndAppendTo(
- Appendable out, CompilerInput input, String content) throws IOException;
+ Appendable out, CompilerInput input, String content, String outputPath) throws IOException;
/** Writes whatever runtime libraries are needed to bundle. */
@GwtIncompatible("Unnecessary")
@@ -1644,6 +1646,7 @@ int processResults(Result result, List modules, B options) throws IOExc
outputManifest();
outputBundle();
outputModuleGraphJson();
+ outputSourceMap(options, config.jsOutputFile);
return 0;
} else if (options.outputJs != OutputJs.NONE && result.success) {
outputModuleGraphJson();
@@ -2272,17 +2275,19 @@ private void outputManifestOrBundle(List outputFiles, boolean isManifest
// Generate per-module manifests or bundles.
Iterable modules = compiler.getModuleGraph().getAllChunks();
for (JSChunk module : modules) {
- try (Writer out = fileNameToOutputWriter2(expandCommandLinePath(output, module))) {
+ String outputPath = expandCommandLinePath(output, module);
+ try (Writer out = fileNameToOutputWriter2(outputPath)) {
if (isManifest) {
printManifestTo(module, out);
} else {
- printBundleTo(module, out);
+ printBundleTo(module, out, outputPath);
}
}
}
} else {
// Generate a single file manifest or bundle.
- try (Writer out = fileNameToOutputWriter2(expandCommandLinePath(output, null))) {
+ String outputPath = expandCommandLinePath(output, null);
+ try (Writer out = fileNameToOutputWriter2(outputPath)) {
if (config.module.isEmpty()) {
// For a single-module compilation, generate a single headerless manifest or bundle
// containing only the strong files.
@@ -2290,11 +2295,11 @@ private void outputManifestOrBundle(List outputFiles, boolean isManifest
if (isManifest) {
printManifestTo(module, out);
} else {
- printBundleTo(module, out);
+ printBundleTo(module, out, outputPath);
}
} else {
// For a multi-module compilation, generate a single manifest file with module headers.
- printModuleGraphManifestOrBundleTo(compiler.getModuleGraph(), out, isManifest);
+ printModuleGraphManifestOrBundleTo(compiler.getModuleGraph(), out, isManifest, outputPath);
}
}
}
@@ -2321,7 +2326,7 @@ void printModuleGraphJsonTo(Appendable out) throws IOException {
/** Prints a set of modules to the manifest or bundle file. */
@VisibleForTesting
@GwtIncompatible("Unnecessary")
- void printModuleGraphManifestOrBundleTo(JSChunkGraph graph, Appendable out, boolean isManifest)
+ void printModuleGraphManifestOrBundleTo(JSChunkGraph graph, Appendable out, boolean isManifest, String outputPath)
throws IOException {
Joiner commas = Joiner.on(",");
boolean requiresNewline = false;
@@ -2344,7 +2349,7 @@ void printModuleGraphManifestOrBundleTo(JSChunkGraph graph, Appendable out, bool
"{%s%s}\n", module.getName(), dependencies.isEmpty() ? "" : ":" + dependencies));
printManifestTo(module, out);
} else {
- printBundleTo(module, out);
+ printBundleTo(module, out, outputPath);
}
requiresNewline = true;
}
@@ -2378,7 +2383,7 @@ void printManifestTo(JSChunk module, Appendable out) throws IOException {
*/
@VisibleForTesting
@GwtIncompatible("Unnecessary")
- void printBundleTo(JSChunk module, Appendable out) throws IOException {
+ void printBundleTo(JSChunk module, Appendable out, String outputPath) throws IOException {
ImmutableList inputs = module.getInputs();
// Prebuild ASTs before they're needed in getLoadFlags, for performance and because
// StackOverflowErrors can be hit if not prebuilt.
@@ -2396,6 +2401,18 @@ void printBundleTo(JSChunk module, Appendable out) throws IOException {
}
}
+ // First, print all defines passed in
+ Set> defines = compiler.getOptions().getDefineReplacements().entrySet();
+ if (!defines.isEmpty()) {
+ Node[] defineNodes = defines.stream()
+ .map((entry) -> IR.propdef(IR.stringKey(entry.getKey()), entry.getValue()))
+ .toArray(Node[]::new);
+
+ Node wrapper = IR.objectlit(defineNodes);
+ Node assign = IR.assign(IR.getprop(IR.thisNode(), "CLOSURE_UNCOMPILED_DEFINES"), wrapper);
+ out.append(new CodePrinter.Builder(assign).setPrettyPrint(true).build());
+ }
+
for (CompilerInput input : inputs) {
String name = input.getName();
String code = input.getSourceFile().getCode();
@@ -2414,7 +2431,7 @@ void printBundleTo(JSChunk module, Appendable out) throws IOException {
out.append(displayName);
out.append("\n");
- prepForBundleAndAppendTo(out, input, code);
+ prepForBundleAndAppendTo(out, input, code, outputPath);
out.append("\n");
}
diff --git a/src/com/google/javascript/jscomp/CommandLineRunner.java b/src/com/google/javascript/jscomp/CommandLineRunner.java
index d999e1504c3..75e8a4a1643 100644
--- a/src/com/google/javascript/jscomp/CommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java
@@ -75,6 +75,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
@@ -2092,9 +2093,24 @@ private ClosureBundler getBundler() {
}
@Override
- protected void prepForBundleAndAppendTo(Appendable out, CompilerInput input, String content)
+ protected void prepForBundleAndAppendTo(Appendable out, CompilerInput input, String content, String outputPath)
throws IOException {
- getBundler().withPath(input.getName()).appendTo(out, input, content);
+ Path pathToInput = Paths.get(new File(input.getName()).getCanonicalPath());
+ Path pathToOutput = Paths.get(new File(outputPath).getParentFile().getCanonicalPath());
+ final ClosureBundler bundler;
+ if (Objects.equals(pathToInput.getRoot(), pathToOutput.getRoot())) {
+ String relativePath = pathToOutput.relativize(pathToInput).toString();
+ if (!relativePath.startsWith("..")) {
+ bundler = getBundler().useEval(true).withSourceUrl(relativePath);
+ } else {
+ bundler = getBundler();
+ }
+ } else {
+ // Didn't share a root (such as two different windows drives), must not relativize
+ bundler = getBundler();
+ }
+
+ bundler.withPath(input.getName()).appendTo(out, input, content);
}
@Override
diff --git a/test/com/google/javascript/jscomp/CommandLineRunnerTest.java b/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
index 605cf7d968b..e2108742b83 100644
--- a/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
+++ b/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
@@ -1785,7 +1785,7 @@ public void testChainModuleManifest() throws Exception {
StringBuilder builder = new StringBuilder();
lastCommandLineRunner.printModuleGraphManifestOrBundleTo(
- lastCompiler.getModuleGraph(), builder, true);
+ lastCompiler.getModuleGraph(), builder, true, null);
assertThat(builder.toString())
.isEqualTo(
Joiner.on('\n')
@@ -1813,7 +1813,7 @@ public void testStarModuleManifest() throws Exception {
StringBuilder builder = new StringBuilder();
lastCommandLineRunner.printModuleGraphManifestOrBundleTo(
- lastCompiler.getModuleGraph(), builder, true);
+ lastCompiler.getModuleGraph(), builder, true, null);
assertThat(builder.toString())
.isEqualTo(
Joiner.on('\n')