athensresearch / athens

Athens is no longer maintainted. Athens was an open-source, collaborative knowledge graph, backed by YC W21
https://athensresearch.github.io/athens
Other
6.31k stars 398 forks source link

fix: shadow-cljs release doesn't work #653

Closed tangjeff0 closed 3 years ago

tangjeff0 commented 3 years ago

Running shadow-cljs release main renderer fails. Can only build Athens with shadow-cljs compile main renderer, but this builds un-optimized code, and sets athens.config/DEBUG? to true, meaning the environment is always development.

shadow-cljs release main renderer
shadow-cljs - config: /home/code/athens/athens-fork/shadow-cljs.edn
shadow-cljs - connected to server
[:main] Compiling ...
[:main] Build completed. (43 files, 2 compiled, 0 warnings, 8.46s)
[:renderer] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/aframe/dist/aframe-master.js:68448:15
 Malformed Regular Expression: rl\((.+)\)
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 Resource: node_modules/aframe/dist/aframe-master.js:74602:28
 Malformed Regular Expression: rl\((.+)\)
--------------------------------------------------------------------------------
------ WARNING #3 -  -----------------------------------------------------------
 Resource: node_modules/ngraph_DOT_forcelayout/lib/codeGenerators/generateCreateBody.js:19:25
 String continuations are not recommended. See https://google.github.io/styleguide/jsguide.html#features-strings-no-line-continuations
--------------------------------------------------------------------------------
nil
npm package "@sentry/integrations" expected version "@sentry/types@6.1.0" but "5.27.2" is installed.
npm package "@sentry/integrations" expected version "@sentry/utils@6.1.0" but "5.27.2" is installed.
npm package "react-kapsule" expected version "react@>=16.13.1" but "16.9.0" is installed.
Closure compilation failed with 28 errors
--- athens/keybindings.cljs:94
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:98
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:102
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:106
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:159
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:187
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:242
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:258
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:314
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:314
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:347
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:347
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:675
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:675
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:676
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:676
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:677
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:677
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:678
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:680
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:682
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:682
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:705
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:707
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:727
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:729
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:731
Cannot convert ECMASCRIPT_2018 feature "RegExp flag 's'" to targeted output language.
--- athens/keybindings.cljs:732
thheller commented 3 years ago

The default output mode is :es5 but you seem to be using features from ES8 that cannot be transpiled down. You can set :compiler-options {:output-feature-set :es8} so it doesn't try to transpile.

tangjeff0 commented 3 years ago

Getting same error after updating compiler-options for main and renderer scripts. Can see at https://github.com/athensresearch/athens/pull/693/files. @thheller

thheller commented 3 years ago

:es-next seems to work. Guess the Closure Error report wasn't corrent regarding the version. You might also want to upgrade your shadow-cljs version. Just bump that to 2.11.18 and the clojurescript to 1.10.773. You are on a version that has a couple known problems.

Congrats on having by far the scariest project I have seen so far from a build tool perspective. 5928 JS files is very scary. I might use it to do some profiling, things seem to get rather slow in some places.

tangjeff0 commented 3 years ago

I'm pretty sure the majority of these js files is coming https://github.com/vasturiano/react-force-graph. We are importing the entire library when we only need need one of the graphs. :sweat_smile: that will be next, and it's easy to import one sub-package individually.

tangjeff0 commented 3 years ago

Does indeed successfuly build with :es-next.

Upon opening, however, get this error image

Which leads to this line:

c})}var ZWa;ZWa=Ga.document&&TP?UWa():void 0;!UP&&!TP||TP&&9<=Number(ZWa)||UP&&WP("1.9.1");TP&&WP("9");function XP(a){var b=document;return"string"===typeof a?b.getElementById(a):a}function $Wa(a,b){Faa(b,function(c,d){c&&"object"==typeof c&&c.zg&&(c=c.xg());"style"==d?a.style.cssText=c:"class"==d?a.className=c:"for"==d?a.htmlFor=c:aXa.hasOwnProperty(d)?a.setAttribute(aXa[d],c):Eb(d,"aria-")||Eb(d,"data-")?a.setAttribute(d,c):a[d]=c})}

a.style.cssText seems to be the culprit.

Added :es-next to the :app build so now we can test shadow-cljs release app without using electron.

(Also learned to use --verbose to see how many js files. Actually might not be react-force-graph.

thheller commented 3 years ago

The style error you should be able to find by using

npx shadow-cljs release app --debug

You might also want to look at the build report for app or renderer.

npx shadow-cljs run shadow.cljs.build-report app athens-app-report.html

and then open the athens-app-report.html.

tangjeff0 commented 3 years ago

App Report: https://github.com/tangjeff0/athens/blob/shadow-release-es8/athens-app-report.html

Output of npx shadow-cljs release app --debug

shadow-cljs - config: /home/jeff/code/athens/athens-fork/shadow-cljs.edn
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app --debug
[:app] Compiling ...
npm package "@sentry/integrations" expected version "@sentry/types@6.1.0" but "5.27.2" is installed.
npm package "@sentry/integrations" expected version "@sentry/utils@6.1.0" but "5.27.2" is installed.
npm package "react-kapsule" expected version "react@>=16.13.1" but "16.9.0" is installed.

------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 File: ~/.m2/repository/tick/tick/0.4.26-alpha/tick-0.4.26-alpha.jar!/tick/locale_en_us.cljc:5:31
--------------------------------------------------------------------------------
   2 |   #?(:cljs (:require ["@js-joda/locale_en-us" :as js-joda-locale])))
   3 |
   4 | ; doing this for the one-arity tick.format/formatter. (npm users don't get js/JSJodaLocale global automatically)
   5 | #?(:cljs (set! js/JSJodaLocale js-joda-locale))
-------------------------------------^------------------------------------------
 constant JSJodaLocale assigned a value more than once.
Original definition at externs.shadow.js:5
--------------------------------------------------------------------------------
   6 |
   7 |
   8 |
--------------------------------------------------------------------------------
nil
[:app] Build completed. (6260 files, 240 compiled, 0 warnings, 73.17s)

Output of npx shadow-cljs release app --debug:

shadow-cljs - config: /home/jeff/code/athens/athens-fork/shadow-cljs.edn
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release main renderer --debug
[:main] Compiling ...
[:main] Build completed. (43 files, 2 compiled, 0 warnings, 10.45s)
[:renderer] Compiling ...
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[BABEL] Note: The code generator has deoptimised the styling of /home/jeff/code/athens/athens-fork/node_modules/three/build/three.module.js as it exceeds the max of 500KB.
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/aframe/dist/aframe-master.js:68448:15
 Malformed Regular Expression: rl\((.+)\)
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 Resource: node_modules/aframe/dist/aframe-master.js:74602:28
 Malformed Regular Expression: rl\((.+)\)
--------------------------------------------------------------------------------
------ WARNING #3 -  -----------------------------------------------------------
 Resource: node_modules/ngraph_DOT_forcelayout/lib/codeGenerators/generateCreateBody.js:19:25
 String continuations are not recommended. See https://google.github.io/styleguide/jsguide.html#features-strings-no-line-continuations
--------------------------------------------------------------------------------
nil
npm package "@sentry/integrations" expected version "@sentry/types@6.1.0" but "5.27.2" is installed.
npm package "@sentry/integrations" expected version "@sentry/utils@6.1.0" but "5.27.2" is installed.
npm package "react-kapsule" expected version "react@>=16.13.1" but "16.9.0" is installed.
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 File: ~/.m2/repository/tick/tick/0.4.26-alpha/tick-0.4.26-alpha.jar!/tick/locale_en_us.cljc:5:31
--------------------------------------------------------------------------------
   2 |   #?(:cljs (:require ["@js-joda/locale_en-us" :as js-joda-locale])))
   3 |
   4 | ; doing this for the one-arity tick.format/formatter. (npm users don't get js/JSJodaLocale global automatically)
   5 | #?(:cljs (set! js/JSJodaLocale js-joda-locale))
-------------------------------------^------------------------------------------
 constant JSJodaLocale assigned a value more than once.
Original definition at externs.shadow.js:5
--------------------------------------------------------------------------------
   6 |
   7 |
   8 |
--------------------------------------------------------------------------------
nil
[:renderer] Build completed. (6260 files, 6150 compiled, 0 warnings, 112.55s)

Not seeing any insights from these commands :sweat_smile:

Maybe if there was a way to see sourcemaps?

thheller commented 3 years ago

--debug adds :pseudo-names true and :source-map true to your build config temporarily. Need to run the code in the browser and the stacktrace should then be source mapped properly. --debug doesn't do anything regarding the console output.

Regarding the @material-ui/icons you probably want to switch to requiring the ones you actually need directly. A plain @material-ui/icons require will add all. Likely just (:require ["@material-ui/icons/Something" :as Something]) or (:require ["@material-ui/icons/Something" :default Something]). Depends on how its bundled, I didn't check.

tangjeff0 commented 3 years ago

Got it! This is failing because re-frame-10x is removed in the release version. Nice.

image

thheller commented 3 years ago

Odd. That should be source mapped as well. Pseudo-Names are close enough too though.

tangjeff0 commented 3 years ago

I created a separate function that directly changes the DOM styles because 10x was visible on the right when resizing the app. 10x isn't called directly by Athens.

https://github.com/athensresearch/athens/blob/68eb2d8e9364caf6392aa2edef91e19f4c12b903/src/cljs/athens/util.cljs#L223-L247