clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-11-29T05:46:30.032200Z

Does anyone have any idea why I'd be getting a circular deps error on my second build? (The first one is fine).

2020-11-29T05:47:00.032800Z

leif@FEM ~/src/interactive-syntax (main*) $ clojure -A:package
2020-11-29 00:36:21.164:INFO::main: Logging initialized @3122ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build prod to "target/public/cljs-out/prod/main.js"
Nov 29, 2020 12:36:58 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /home/leif/src/interactive-syntax/target/public/cljs-out/prod/cljs/compiler.js:860: WARNING - [JSC_REGEXP_REFERENCE] References to the global RegExp object prevents optimization of regular expressions.
cljs.compiler.emit_constant_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,RegExp,(function (x){
                                                                              ^^^^^^

Nov 29, 2020 12:36:58 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /home/leif/src/interactive-syntax/target/public/cljs-out/prod/interactive_syntax/core.js:47: WARNING - [JSC_PARTIAL_NAMESPACE] Partial alias created for namespace cljs, possibly due to await/yield transpilation.
This may prevent optimization of anything nested under this namespace.
See <https://github.com/google/closure-compiler/wiki/FAQ#i-got-an-incomplete-alias-created-for-namespace-error--what-do-i-do> for more details.
(runner.g = ({"cljs": cljs}));
                      ^^^^

Nov 29, 2020 12:36:58 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 2 warning(s)
[Figwheel] Successfully compiled build prod to "target/public/cljs-out/prod/main.js" in 35.165 seconds.
[Figwheel] Bundling: npx webpack --mode=production src/js/bundle.js ./target/public/cljs-out/prod/main.js --output-path ./target/public/cljs-out/prod --output-filename main_bundle.js
leif@FEM ~/src/interactive-syntax (main*) $ clojure -A:package
2020-11-29 00:41:26.361:INFO::main: Logging initialized @3092ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build prod to "target/public/cljs-out/prod/main.js"
[Figwheel] Failed to compile build prod in 10.046 seconds.
[Figwheel:WARNING] Could not Analyze: Assert failed: Circular dependency detected, cljs.core -&gt; cljs.core
(every? (fn* [p1__2127#] (not (contains? *cljs-dep-set* p1__2127#))) deps)  target/public/cljs-out/prod/cljs/core.cljc   
[Figwheel:SEVERE] failed compiling file:target/public/cljs-out/prod/cljs/core.cljc
Unexpected error (AssertionError) compiling at (REPL:1).
Assert failed: Circular dependency detected, cljs.core -&gt; cljs.core
(every? (fn* [p1__2127#] (not (contains? *cljs-dep-set* p1__2127#))) deps)

Full report at:
/tmp/clojure-5618560910518765653.edn

2020-11-29T05:48:00.033200Z

The command I'm running is clojure -m figwheel.main --build-once --prod

2020-11-29T05:49:21.034100Z

With the following deps:

{:deps {org.clojure/core.match {:mvn/version "1.0.0"}
        org.clojure/tools.reader {:mvn/version "1.3.3"}
        reagent {:mvn/version "0.10.0" :exclusions [cljsjs/react cljsjs/react-dom]}
        alandipert/storage-atom {:mvn/version "1.2.4"}
        com.bhauman/figwheel-main {:mvn/version "0.2.12"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
 :paths ["src" "target" "resources" "env/dev/cljs" "env/prod/cljs"]}}

p-himik 2020-11-29T05:55:38.034400Z

Do not include "target" in your :paths.

2020-11-29T06:05:57.035400Z

@p-himik Ah, okay. FWIW, the figwheel-main tutorial (https://figwheel.org/tutorial) does put target in the paths. Is that wrong, or is there a different reason they do that?

p-himik 2020-11-29T06:28:26.036Z

No idea why they do it but I fail to see how it would be the right thing to do.

p-himik 2020-11-29T06:29:40.037Z

> This directory is automatically added to the > classpath so that the compiled assets can be found and served by the > built-in webserver. Well, if they're mixing the classpath for building CLJS and the classpass for serving compiled files then it's certainly wrong.

2020-11-29T06:39:22.037500Z

I see...that actually makes more sense.

2020-11-29T06:39:41.038Z

(I was left not really understanding what the classpath is used for after reading that tutorial)

zackteo 2020-11-29T10:52:45.039600Z

Hi guys, I'm trying to do an advanced compile and deployment of my webapp into an ec2 instance ... I am getting ...

ubuntu@ip-172-31-71-196:~/dbfrontend-clone/src/dbfrontend$ lein do clean, cljsbuild once min
*** Warning: This project requires Leiningen 2.9.1, but you have 2.8.1 ***

Get the latest version of Leiningen at <https://leiningen.org> or by executing
"lein upgrade".
Compiling ClojureScript...
Compiling ["resources/public/js/compiled/dbfrontend.js"] from ["src"]...
module.js:549
    throw err;
    ^

Error: Cannot find module '@cljs-oss/module-deps'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at [eval]:8:13
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object.&lt;anonymous&gt; ([eval]-wrapper:6:22)
    at Module._compile (module.js:652:30)
    at evalScript (bootstrap_node.js:463:27)

Successfully compiled ["resources/public/js/compiled/dbfrontend.js"] in 25.769 seconds.

zackteo 2020-11-29T10:53:44.040600Z

Is there any issue i should be fixing? Otherwise how do I start my app?

zackteo 2020-11-29T11:09:19.040900Z

This is my repo btw https://github.com/zackteo/dbfrontend-clone Not sure if there's issues with project.clj

2020-11-29T16:17:48.041900Z

I would try upgrading leiningen first: https://leiningen.org/#install

2020-11-29T16:19:02.042400Z

you can see your installed version with: $ lein version

2020-11-29T18:02:46.044300Z

@p-himik Looking at the clojure docs here: https://clojure.org/guides/deps_and_cli#aot_compilation, it seems it would indicate adding traget to the classpath is the right thing to do, is this a difference between clojure and clojurescript?

p-himik 2020-11-29T18:13:16.044400Z

Yes. In Clojure, compiled files take precedence over older sources - they completely replace them. In ClojureScript, there's no such thing (unless we're talking about only CLJS files, but target also has JS files) - all files are added together. Even if it was possible, it would still be detrimental - your CLJS compilation process has absolutely nothing to do with your backend operations. So it doesn't make any sense to pollute the backend classpath with the stuff from the CLJS compilation classpath that, apart from just the sources, can have some third-party dependencies that bring in yet other dependencies.

2020-11-29T18:51:58.044700Z

Ah, okay. This makes sense.

2020-11-29T18:52:15.044900Z

Thank you.

👍 1
2020-11-29T19:03:25.045200Z

@p-himik Hmm...I still am getting circular dependency errors, even after a clean rebuild. Any other ideas?

p-himik 2020-11-29T19:14:37.045500Z

Does the error say anything about the particular set of dependencies?

p-himik 2020-11-29T19:15:03.045700Z

Oh, wait - the docs said that "target" is implicitly added to the paths by Figwheel, I think.

p-himik 2020-11-29T19:16:01.045900Z

If that's indeed the case then it might be better to ask it in #figwheel - I've switched over to shadow-cljs a few years ago.

2020-11-29T19:28:08.046200Z

@p-himik Ugg...I missed that. Thanks for catching it.

2020-11-29T19:28:16.046400Z

And ya, I'll jump into figwheel.

2020-11-29T20:05:40.046800Z

@p-himik So, when I last looked at shadow-cljs, it seemed to include npm packages directly. Does that mean you can't use webpack with shadow-cljs?

zackteo 2020-11-29T21:59:19.047200Z

Is there a way to change the dependency for lein instead?