Fork me on GitHub
#nrepl
<
2022-02-26
>
neilyio01:02:43

I’m working on a minimal ClojureScript setup with https://github.com/nrepl/weasel , but I’m getting a JSC_UNDEFINED_EXTERN_VAR_ERROR upon compilation as soon as I (require ’weasel.repl) from ClojureScript. Here’s a minimal reproduction:

;; src/cljs/user.cljs
(ns cljs.user
  (:require [weasel.repl :as repl]))

;; build.clj (running compiler)
(cljs.build.api/build 
 {:output-dir    ".compiled/cljs",
  :output-to     ".compiled/cljs/prebundle.js",
  :asset-path    "cljs",
  :main          "cljs.user",
  :install-deps  true,
  :optimizations :simple,
  :target        :bundle
  :bundle-cmd    {:default ["esbuild"
                            ".compiled/cljs/prebundle.js"
                            "--bundle"
                            "--outfile=public/js/bundle.js"]}
  :npm-deps
  {"react" "17.0.2", "react-dom" "17.0.2", "@react-spring/web" "9.4.2"}}) 
I’ll post the full error from the Clojure process in the thread below. I realize weasel isn’t very actively maintained, but if anyone can give me a tip on how to go about debugging this, then I’d love to contribute the fix upstream. I’m working on some new ClojureScript tooling that I think weasel would be a great fit for.

neilyio01:02:14

Full error from the build call above:

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:13:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR	] name goog is not defined in the externs.
  13| goog.dependencies_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:14:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  14| goog.dependencies_.nameToPath;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:15:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  15| goog.dependencies_.visited;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:16:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  16| goog.dependencies_.written;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:17:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  17| goog.basePath;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:18:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  18| goog.writeScriptTag_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:19:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  19| goog.require;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:20:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  20| goog.require__;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:21:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  21| goog.writeScriptTag__;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:22:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  22| goog.writeScriptTag__.apply;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:23:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  23| goog.isInModuleLoader_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:24:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  24| goog.module;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:25:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  25| goog.module.getInternal_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:26:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  26| goog.isProvided_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:27:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  27| goog.cljsReloadAll_;
      ^^^^

Feb 25, 2022 5:17:37 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 15 warning(s)
Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:13:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  13| goog.dependencies_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:14:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  14| goog.dependencies_.nameToPath;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:15:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  15| goog.dependencies_.visited;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:16:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  16| goog.dependencies_.written;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:17:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  17| goog.basePath;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:18:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  18| goog.writeScriptTag_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:19:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  19| goog.require;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:20:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  20| goog.require__;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:21:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  21| goog.writeScriptTag__;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:22:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  22| goog.writeScriptTag__.apply;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:23:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  23| goog.isInModuleLoader_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:24:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  24| goog.module;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:25:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  25| goog.module.getInternal_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:26:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  26| goog.isProvided_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: .compiled/cljs/inferred_externs.js:27:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
  27| goog.cljsReloadAll_;
      ^^^^

Feb 25, 2022 5:18:08 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 15 warning(s)

neilyio01:02:51

As additional context, the errors/warnings above don’t actually make my build fail. They just start appearing as soon as I add (:require [weasel.repl :as repl]). The problem really starts when I actually try to use weasel. With the user.cljs below:

(ns cljs.user
  (:require [weasel.repl :as repl]))

(when-not (repl/alive?)
  (repl/connect ""))
I get an error as soon as the browser loads:
{
    "message": "Assertion failed: This browser does not support WebSocket",
    "reportErrorToServer": true,
    "messagePattern": "Assertion failed: This browser does not support WebSocket"
}