Use updated polygerrit_plugin BUILD rule

Change-Id: Iec7e603a0736cb4ca75a4afbb8b524f684346d91
diff --git a/BUILD b/BUILD
index 306479a..e40a615 100644
--- a/BUILD
+++ b/BUILD
@@ -15,29 +15,30 @@
 
 genrule2(
     name = "cm-static",
-    srcs = [":cm", ":cm-dep"],
+    srcs = [":codemirror_editor"],
     outs = ["cm-static.jar"],
     cmd = " && ".join([
         "mkdir $$TMP/static",
-        "cp -rp $(locations :cm) $$TMP/static",
-        "cp -rp $(locations :cm-dep) $$TMP/static",
-        "mv $$TMP/static/cm-dep.html $$TMP/static/codemirror-assets.html",
+        "cp -r $(locations :codemirror_editor) $$TMP/static",
         "cd $$TMP",
         "zip -Drq $$ROOT/$@ -g .",
     ]),
 )
 
-polygerrit_plugin(
-    name = "cm",
-    srcs = glob(["**/*.html", "**/*.js"]),
-    app = "plugin.html",
+vulcanize(
+    name = "codemirror-assets",
+    srcs = glob(["gr-editor/codemirror-assets.html"]),
+    app = "gr-editor/codemirror-assets.html",
+    split = False,
     deps = ["//lib/js:codemirror-minified"],
 )
 
-vulcanize(
-    name = "cm-dep",
-    srcs = glob(['gr-editor/codemirror-assets.html']),
-    app = "gr-editor/codemirror-assets.html",
-    deps = ["//lib/js:codemirror-minified"],
-    split = False,
+polygerrit_plugin(
+    name = "codemirror_editor",
+    srcs = glob([
+        "gr-editor/*.html",
+        "gr-editor/*.js",
+    ]),
+    app = "plugin.html",
+    assets = [":codemirror-assets"],
 )
diff --git a/gr-editor/gr-editor.js b/gr-editor/gr-editor.js
index a7eff27..322eb10 100644
--- a/gr-editor/gr-editor.js
+++ b/gr-editor/gr-editor.js
@@ -46,7 +46,7 @@
         this._importCodeMirror().then(() => {
           const params = this.getCodeMirrorParams(this.fileType,
               this.fileContent, this.prefs);
-          this.mirror = CodeMirror(this.$.wrapper, params);
+          this.mirror = window.CodeMirror(this.$.wrapper, params);
           this.async(() => {
             this.mirror.refresh();
             this.mirror.focus();