thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.25k stars 177 forks source link

Application works fine with shadow-cljs versions 2.9.6 and earlier. Fails differently for 2.9.7 onward #734

Closed rberger closed 4 years ago

rberger commented 4 years ago

We have a somewhat complex webapp using AWS Amplify and Appsync. All was working fine with shadow-cljs 2.8.110.

When I noticed we were running with such an old version, I upgraded to 2.10.8 which worked fine in dev mode locally.

But the application stopped working when we did the release with the error in the chrome debugger (the following was from a run that was built with shadow-cljs -A:prod release app --debug):

js.js:74 shadow-cljs - failed to load 144
js.js:74 shadow-cljs - failed to load 173
js.js:74 shadow-cljs - failed to load 174
js.js:74 shadow-cljs - failed to load 179
js.js:74 shadow-cljs - failed to load 180
js.js:74 shadow-cljs - failed to load 184
CognitoIdentityClient.js:28 Uncaught TypeError: $jscomp.inherits is not a function
    at Object.shadow$provide.<computed> (CognitoIdentityClient.js:28)
    at $shadow$js$jsRequire$$ (js.js:66)
    at Object.shadow$provide.<computed> (index.js:5)
    at $shadow$js$jsRequire$$ (js.js:66)
    at Object.shadow$provide.<computed> (fromCognitoIdentity.js:6)
    at $shadow$js$jsRequire$$ (js.js:66)
    at Object.shadow$provide.<computed> (index.js:5)
    at $shadow$js$jsRequire$$ (js.js:66)
    at Object.shadow$provide.<computed> (Credentials.js:57)
    at $shadow$js$jsRequire$$ (js.js:66)

Not sure if its related but the release builds would give warnings:

------ WARNING #1 -  -----------------------------------------------------------
 Resource: 
 unknown @define variable day8.re_frame.tracing.trace_enabled_QMARK_
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
------ WARNING #3 -  -----------------------------------------------------------
 File: /root/visx-dashboard/src/visx/dashboard/core.cljs:50:16
--------------------------------------------------------------------------------
  47 |   (rf/clear-subscription-cache!)
  48 |   (let [dispatch-fn #(rf/dispatch [:show-container (:handler %)])]
  49 |     (router/init! routes dispatch-fn))
  50 |   (config/init! awsmobile)
----------------------^---------------------------------------------------------
 variable module$aws_exports is undeclared
--------------------------------------------------------------------------------
  51 |   (auth/init!)
  52 |   (rest/init!)
  53 |   (graphql/init! {:queries   queries
  54 |                   :mutations mutations
--------------------------------------------------------------------------------
------ WARNING #4 -  -----------------------------------------------------------
 File: /root/visx-dashboard/src/visx/dashboard/core.cljs:55:33
--------------------------------------------------------------------------------
  52 |   (rest/init!)
  53 |   (graphql/init! {:queries   queries
  54 |                   :mutations mutations
  55 |                   :subscriptions subscriptions})
---------------------------------------^----------------------------------------
 variable module$graphql$queries is undeclared
--------------------------------------------------------------------------------
  56 |   (>>! [:init-hub-listener])
  57 |   ;; (>> [:get-audio-inputs])
  58 |   ;; (>> [:get-video-inputs])
  59 |   ;; (>> [:get-audio-outputs])
--------------------------------------------------------------------------------
------ WARNING #5 -  -----------------------------------------------------------
 File: /root/visx-dashboard/src/visx/dashboard/core.cljs:55:33
--------------------------------------------------------------------------------
  52 |   (rest/init!)
  53 |   (graphql/init! {:queries   queries
  54 |                   :mutations mutations
  55 |                   :subscriptions subscriptions})
---------------------------------------^----------------------------------------
 variable module$graphql$mutations is undeclared
--------------------------------------------------------------------------------
  56 |   (>>! [:init-hub-listener])
  57 |   ;; (>> [:get-audio-inputs])
  58 |   ;; (>> [:get-video-inputs])
  59 |   ;; (>> [:get-audio-outputs])
--------------------------------------------------------------------------------
------ WARNING #6 -  -----------------------------------------------------------
 File: /root/visx-dashboard/src/visx/dashboard/core.cljs:55:33
--------------------------------------------------------------------------------
  52 |   (rest/init!)
  53 |   (graphql/init! {:queries   queries
  54 |                   :mutations mutations
  55 |                   :subscriptions subscriptions})
---------------------------------------^----------------------------------------
 variable module$graphql$subscriptions is undeclared
--------------------------------------------------------------------------------
  56 |   (>>! [:init-hub-listener])
  57 |   ;; (>> [:get-audio-inputs])
  58 |   ;; (>> [:get-video-inputs])
  59 |   ;; (>> [:get-audio-outputs])
--------------------------------------------------------------------------------

All of those are defined in imported javascript files:

   ["/aws-exports.js" :default awsmobile]
   ["/graphql/queries" :as queries]
   ["/graphql/mutations" :as mutations]
   ["/graphql/subscriptions" :as subscriptions]

The first one is local to the repo in src/aws-exports.js The other three are in a dependency repo/jar (omnypay/visx-schema).

Warnings 1 and 2 are not relavent, but the others only show up with shadow-cljs 2.9.7 onward and it seems to not work with 2.9.7 onward. 2.9.6 and earlier would not give these errors and the ones I sampled would function correctly without errors.

The other strange thing is with 2.9.7 page wouldn't load at all. Unfortunately I didn't record the error. It was a one liner about missing a parenthesis.

2.9.8 would fail with:

parser.js:10 
Uncaught TypeError: Must provide Source. Received: undefined
    at Object.b.parse (parser.js:10)
    at b.graphql (GraphQLAPI.js:269)
    at b.graphql (index.js:1)
    at $amplitude$graphql$subscribe_BANG_$cljs$0core$0IFn$0_invoke$0arity$03$$ (graphql.cljs:194)
    at api.cljs:281
    at fx.cljc:51
    at $re_frame$interceptor$invoke_interceptors$$ (interceptor.cljc:69)
    at $re_frame$events$handle$$ (events.cljc:61)
    at $JSCompiler_StaticMethods_re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1$$ (router.cljc:180)
    at $JSCompiler_StaticMethods_re_frame$router$IEventQueue$_run_queue$arity$1$$ (router.cljc:199)

My shadow-cljs.edn is:

{:deps true
 :nrepl {:port 8777}
 :builds {:app {:target     :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules    {:app {:init-fn  visx.dashboard.core/init
                                   :preloads [devtools.preload
                                              day8.re-frame-10x.preload]}}
                :dev        {:compiler-options
                             {:closure-defines
                              {re-frame.trace.trace-enabled?        true
                               day8.re-frame.tracing.trace-enabled? true}}}
                :devtools   {:http-root "resources/public"
                             :http-port 8280}
                :release    {:compiler-options
                             {:closure-defines
                              {re-frame.trace.trace-enabled?        false
                               day8.re-frame.tracing.trace-enabled? false}}
                             :infer-extern :auto
                             :output-dir "dist/js/compiled"}}}}

deps.edn:

{:aliases
 {:dev
  {:extra-deps
   {binaryage/devtools {:mvn/version "1.0.0"},
    day8.re-frame/re-frame-10x {:mvn/version "0.6.5"},
    day8.re-frame/tracing {:mvn/version "0.5.5"}},
   :extra-paths ["src" "dev"]},
  :prod
  {:extra-deps {day8.re-frame/tracing-stubs {:mvn/version "0.5.5"}}},
  :run {:jvm-opts ["-Xmx1G"]}},
 :deps
 {re-catch {:mvn/version "0.1.4"},
  re-frame {:mvn/version "1.0.0-rc2"},
  reagent {:mvn/version "0.10.0"},
  alandipert/storage-atom {:mvn/version "2.0.1"},
  cider/cider-nrepl {:mvn/version "0.22.0"},
  day8.re-frame/http-fx {:mvn/version "v0.2.0"},
  omnypay/amplitude
  {:git/url "git@github.com:omnypay/amplitude.git",
   :sha "9382ec38351f688be0b878ff56f77fabe63443de",
   :tag "0.1.38",
   :time "2020-06-14T16:00:58.000+0000"},
  omnypay/re-view
  {:git/url "git@github.com:omnypay/re-view.git",
   :sha "a303886033f5f4dd665ea024112dd706743144b5",
   :tag "0.1.34",
   :time "2020-06-15T12:03:44.000+0000"},
  omnypay/visx-schema
  {:git/url "git@github.com:omnypay/visx-schema.git",
   :sha "7572615e6ccd90afe20997f82011338841c6393c",
   :tag "0.1.58",
   :time "2020-06-15T18:59:19.000+0000"},
  org.clojure/clojure {:mvn/version "1.10.1"},
  org.clojure/clojurescript
  {:exclusions
   [com.google.javascript/closure-compiler-unshaded
    org.clojure/google-closure-library
    org.clojure/google-closure-library-third-party],
   :mvn/version "1.10.741"},
  thheller/shadow-cljs {:mvn/version "2.10.8"}},
 :paths ["src" "resources"]}

Any suggestions? Thanks

thheller commented 4 years ago

Please try 2.10.9. I think that should fix it.

You may want to look into :ns-aliases for the re-frame-tracing stuff so you can get rid of the :dev/:prod aliases. See https://github.com/day8/re-frame-debux#option-2-namespace-aliases-with-shadow-cljs

rberger commented 4 years ago

Just to formally say that moving to the more recent version did fix the issue if you want to close this

zilti commented 3 years ago

I am adding this here because this issue is what pops up first when googling the error:

Check if you have a shadow-cljs version mismatch between package.json and your deps.edn/project.clj dependencies. That was it for me. Happy coding!