浏览代码

fix: publishing app in prod mode

Also fix watch-publishing-frontend which had stopped working awhile back
with shadow-cljs update
Gabriel Horner 2 月之前
父节点
当前提交
182a51a85e

+ 1 - 1
deps/publishing/src/logseq/publishing/export.cljs

@@ -8,7 +8,7 @@
 
 (def ^:api js-files
   "js files from publishing release build"
-  (->> ["main.js" "code-editor.js" "excalidraw.js" "tldraw.js" "db-worker.js"]
+  (->> ["main.js" "code-editor.js" "excalidraw.js" "tldraw.js"]
        ;; Add source maps for all js files as it doesn't affect initial load time
        (mapcat #(vector % (str % ".map")))
        vec))

+ 1 - 0
deps/publishing/src/logseq/publishing/html.cljs

@@ -124,6 +124,7 @@ necessary db filtering"
             [:script {:src "static/js/react.production.min.js"}]
             [:script {:src "static/js/react-dom.production.min.js"}]
             [:script {:src "static/js/ui.js"}]
+            [:script {:src "static/js/main-bundle.js"}]
             [:script {:src "static/js/main.js"}]
             ;; Deferring scripts above results in errors
             [:script {:defer true :src "static/js/interact.min.js"}]

+ 1 - 1
scripts/src/logseq/tasks/dev.clj

@@ -87,7 +87,7 @@
 
 (defn watch-publishing-frontend
   [& _args]
-  (shell "clojure -M:cljs watch publishing"))
+  (shell "npx shadow-cljs watch publishing"))
 
 (defn watch-publishing-backend
   "Builds publishing backend once watch-publishing-frontend has built initial frontend"

+ 7 - 6
shadow-cljs.edn

@@ -187,17 +187,18 @@
 
   :publishing {:target :browser
                :module-loader true
-               :js-options {;; handle `require(xxx.css)`
+               :js-options {:js-provider    :external
+                            :external-index "target/main.js"
+                            :external-index-format :esm
+                            :entry-keys ["module" "browser" "main"]
+                            :export-conditions ["module" "import", "browser" "require" "default"]
                             :ignore-asset-requires true
                             :resolve {"react" {:target :global
                                                :global "React"}
                                       "react-dom" {:target :global
                                                    :global "ReactDOM"}}}
-               :modules {:shared
-                         {:entries []}
-                         :main
-                         {:init-fn frontend.publishing/init
-                          :depends-on #{:shared}}
+               :modules {:main
+                         {:init-fn frontend.publishing/init}
                          :code-editor
                          {:entries [frontend.extensions.code]
                           :depends-on #{:main}}