From a3232f8a76db52563c34f6de820ce53aa7b2f1f0 Mon Sep 17 00:00:00 2001 From: Jon Schoning Date: Fri, 26 Jan 2024 22:14:41 -0600 Subject: [PATCH] esm splitting --- espial.cabal | 53 +++++++++---- package.yaml | 2 + purs/Makefile | 12 +-- purs/package.json | 4 +- purs/src/AccountSettings.purs | 20 +++++ purs/src/Add.purs | 19 +++++ purs/src/Bookmarks.purs | 27 +++++++ purs/src/{ => Core}/App.purs | 0 purs/src/{ => Core}/Globals.js | 0 purs/src/{ => Core}/Globals.purs | 0 purs/src/{ => Core}/Marked.js | 0 purs/src/{ => Core}/Marked.purs | 0 purs/src/{ => Core}/Model.purs | 0 purs/src/{ => Core}/Util.purs | 0 purs/src/Core/ViewRendered.purs | 15 ++++ purs/src/Logout.purs | 11 +++ purs/src/Main.purs | 70 ------------------ purs/src/Note.purs | 27 +++++++ src/Handler/AccountSettings.hs | 2 +- src/Handler/Add.hs | 2 +- src/Handler/Notes.hs | 6 +- src/Handler/User.hs | 2 +- static/js/app.min.js | 66 ----------------- static/js/app.min.js.gz | Bin 79079 -> 0 bytes static/js/app.min.js.map | 7 -- static/js/app.min.js.map.gz | Bin 381265 -> 0 bytes static/js/purs/AccountSettings/index.js | 2 + static/js/purs/AccountSettings/index.js.gz | Bin 0 -> 1097 bytes static/js/purs/AccountSettings/index.js.map | 7 ++ .../js/purs/AccountSettings/index.js.map.gz | Bin 0 -> 2005 bytes static/js/purs/Add/index.js | 2 + static/js/purs/Add/index.js.gz | Bin 0 -> 2821 bytes static/js/purs/Add/index.js.map | 7 ++ static/js/purs/Add/index.js.map.gz | Bin 0 -> 5366 bytes static/js/purs/Bookmarks/index.js | 2 + static/js/purs/Bookmarks/index.js.gz | Bin 0 -> 4926 bytes static/js/purs/Bookmarks/index.js.map | 7 ++ static/js/purs/Bookmarks/index.js.map.gz | Bin 0 -> 11043 bytes static/js/purs/Logout/index.js | 2 + static/js/purs/Logout/index.js.gz | Bin 0 -> 199 bytes static/js/purs/Logout/index.js.map | 7 ++ static/js/purs/Logout/index.js.map.gz | Bin 0 -> 292 bytes static/js/purs/Note/index.js | 4 + static/js/purs/Note/index.js.gz | Bin 0 -> 3169 bytes static/js/purs/Note/index.js.map | 7 ++ static/js/purs/Note/index.js.map.gz | Bin 0 -> 6442 bytes static/js/purs/chunk-C2VZJJ3O.js | 16 ++++ static/js/purs/chunk-C2VZJJ3O.js.gz | Bin 0 -> 37767 bytes static/js/purs/chunk-C2VZJJ3O.js.map | 7 ++ static/js/purs/chunk-C2VZJJ3O.js.map.gz | Bin 0 -> 213118 bytes static/js/purs/chunk-HXAV7WCB.js | 52 +++++++++++++ static/js/purs/chunk-HXAV7WCB.js.gz | Bin 0 -> 19743 bytes static/js/purs/chunk-HXAV7WCB.js.map | 7 ++ static/js/purs/chunk-HXAV7WCB.js.map.gz | Bin 0 -> 60521 bytes static/js/purs/chunk-YZW7HJVL.js | 2 + static/js/purs/chunk-YZW7HJVL.js.gz | Bin 0 -> 15445 bytes static/js/purs/chunk-YZW7HJVL.js.map | 7 ++ static/js/purs/chunk-YZW7HJVL.js.map.gz | Bin 0 -> 89103 bytes templates/default-layout-wrapper.hamlet | 2 +- 59 files changed, 309 insertions(+), 176 deletions(-) create mode 100644 purs/src/AccountSettings.purs create mode 100644 purs/src/Add.purs create mode 100644 purs/src/Bookmarks.purs rename purs/src/{ => Core}/App.purs (100%) rename purs/src/{ => Core}/Globals.js (100%) rename purs/src/{ => Core}/Globals.purs (100%) rename purs/src/{ => Core}/Marked.js (100%) rename purs/src/{ => Core}/Marked.purs (100%) rename purs/src/{ => Core}/Model.purs (100%) rename purs/src/{ => Core}/Util.purs (100%) create mode 100644 purs/src/Core/ViewRendered.purs create mode 100644 purs/src/Logout.purs delete mode 100644 purs/src/Main.purs create mode 100644 purs/src/Note.purs delete mode 100644 static/js/app.min.js delete mode 100644 static/js/app.min.js.gz delete mode 100644 static/js/app.min.js.map delete mode 100644 static/js/app.min.js.map.gz create mode 100644 static/js/purs/AccountSettings/index.js create mode 100644 static/js/purs/AccountSettings/index.js.gz create mode 100644 static/js/purs/AccountSettings/index.js.map create mode 100644 static/js/purs/AccountSettings/index.js.map.gz create mode 100644 static/js/purs/Add/index.js create mode 100644 static/js/purs/Add/index.js.gz create mode 100644 static/js/purs/Add/index.js.map create mode 100644 static/js/purs/Add/index.js.map.gz create mode 100644 static/js/purs/Bookmarks/index.js create mode 100644 static/js/purs/Bookmarks/index.js.gz create mode 100644 static/js/purs/Bookmarks/index.js.map create mode 100644 static/js/purs/Bookmarks/index.js.map.gz create mode 100644 static/js/purs/Logout/index.js create mode 100644 static/js/purs/Logout/index.js.gz create mode 100644 static/js/purs/Logout/index.js.map create mode 100644 static/js/purs/Logout/index.js.map.gz create mode 100644 static/js/purs/Note/index.js create mode 100644 static/js/purs/Note/index.js.gz create mode 100644 static/js/purs/Note/index.js.map create mode 100644 static/js/purs/Note/index.js.map.gz create mode 100644 static/js/purs/chunk-C2VZJJ3O.js create mode 100644 static/js/purs/chunk-C2VZJJ3O.js.gz create mode 100644 static/js/purs/chunk-C2VZJJ3O.js.map create mode 100644 static/js/purs/chunk-C2VZJJ3O.js.map.gz create mode 100644 static/js/purs/chunk-HXAV7WCB.js create mode 100644 static/js/purs/chunk-HXAV7WCB.js.gz create mode 100644 static/js/purs/chunk-HXAV7WCB.js.map create mode 100644 static/js/purs/chunk-HXAV7WCB.js.map.gz create mode 100644 static/js/purs/chunk-YZW7HJVL.js create mode 100644 static/js/purs/chunk-YZW7HJVL.js.gz create mode 100644 static/js/purs/chunk-YZW7HJVL.js.map create mode 100644 static/js/purs/chunk-YZW7HJVL.js.map.gz diff --git a/espial.cabal b/espial.cabal index dd0d9c4..a4f9b17 100644 --- a/espial.cabal +++ b/espial.cabal @@ -1,6 +1,6 @@ -cabal-version: 1.12 +cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.1. +-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack @@ -48,23 +48,48 @@ extra-source-files: static/css/tachyons.min.css static/css/tachyons.min.css.gz static/images/bluepin.gif - static/js/app.min.js - static/js/app.min.js.gz - static/js/app.min.js.map - static/js/app.min.js.map.gz static/js/js.cookie-2.2.0.min.js static/js/js.cookie-2.2.0.min.js.gz + static/js/purs/chunk-C2VZJJ3O.js + static/js/purs/chunk-C2VZJJ3O.js.gz + static/js/purs/chunk-C2VZJJ3O.js.map + static/js/purs/chunk-C2VZJJ3O.js.map.gz + static/js/purs/chunk-HXAV7WCB.js + static/js/purs/chunk-HXAV7WCB.js.gz + static/js/purs/chunk-HXAV7WCB.js.map + static/js/purs/chunk-HXAV7WCB.js.map.gz + static/js/purs/chunk-YZW7HJVL.js + static/js/purs/chunk-YZW7HJVL.js.gz + static/js/purs/chunk-YZW7HJVL.js.map + static/js/purs/chunk-YZW7HJVL.js.map.gz + static/js/purs/AccountSettings/index.js + static/js/purs/AccountSettings/index.js.gz + static/js/purs/AccountSettings/index.js.map + static/js/purs/AccountSettings/index.js.map.gz + static/js/purs/Add/index.js + static/js/purs/Add/index.js.gz + static/js/purs/Add/index.js.map + static/js/purs/Add/index.js.map.gz + static/js/purs/Bookmarks/index.js + static/js/purs/Bookmarks/index.js.gz + static/js/purs/Bookmarks/index.js.map + static/js/purs/Bookmarks/index.js.map.gz + static/js/purs/Logout/index.js + static/js/purs/Logout/index.js.gz + static/js/purs/Logout/index.js.map + static/js/purs/Logout/index.js.map.gz + static/js/purs/Note/index.js + static/js/purs/Note/index.js.gz + static/js/purs/Note/index.js.map + static/js/purs/Note/index.js.map.gz purs/Makefile purs/spago.lock purs/spago.yaml - purs/src/App.purs - purs/src/Globals.js - purs/src/Globals.purs - purs/src/Main.purs - purs/src/Marked.js - purs/src/Marked.purs - purs/src/Model.purs - purs/src/Util.purs + purs/src/AccountSettings.purs + purs/src/Add.purs + purs/src/Bookmarks.purs + purs/src/Logout.purs + purs/src/Note.purs purs/src/Component/AccountSettings.purs purs/src/Component/Add.purs purs/src/Component/BList.purs diff --git a/package.yaml b/package.yaml index c82ac31..2515f5b 100644 --- a/package.yaml +++ b/package.yaml @@ -33,6 +33,8 @@ extra-source-files: - static/css/** - static/images/** - static/js/** +- static/js/purs/** +- static/js/purs/**/** - purs/Makefile - purs/spago.lock - purs/spago.yaml diff --git a/purs/Makefile b/purs/Makefile index dc73281..794900f 100644 --- a/purs/Makefile +++ b/purs/Makefile @@ -9,16 +9,8 @@ build: @npm run spago build bundle: build - @npm run esbuild-bundle - @npm run esbuild-bundle-min - @rm -f dist/*.gz - @gzip -k dist/app.min.js.map - @gzip -k dist/app.min.js - @find dist -type f -printf "%kK\\t%h/%f\\n" | sort -k 2 - @cp dist/app.min.js ../static/js/app.min.js - @cp dist/app.min.js.gz ../static/js/app.min.js.gz - @cp dist/app.min.js.map ../static/js/app.min.js.map - @cp dist/app.min.js.map.gz ../static/js/app.min.js.map.gz + npm run esbuild-bundle-min + cp -R dist ../static/js/purs docs: @rm -Rf generated-docs diff --git a/purs/package.json b/purs/package.json index 471af97..13e68fc 100644 --- a/purs/package.json +++ b/purs/package.json @@ -6,8 +6,8 @@ "purs": "purs", "make-install": "make install", "make-watch": "inotifywait -m -r -q -e close_write --format '%T %w%f' --timefmt '%T' src | while read FILE; do echo $FILE; make; done", - "esbuild-bundle": "esbuild ./output/Main/index.js --bundle --format=esm --target=chrome61,firefox60,edge18 --outfile=dist/app.js", - "esbuild-bundle-min": "esbuild ./output/Main/index.js --bundle --format=esm --target=chrome61,firefox60,edge18 --minify --sourcemap --outfile=dist/app.min.js" + "esbuild-bundle": "esbuild ./output/Note/index.js ./output/Add/index.js ./output/Logout/index.js ./output/Bookmarks/index.js ./output/AccountSettings/index.js --bundle --format=esm --target=chrome61,firefox60,edge18 --outdir=dist --splitting", + "esbuild-bundle-min": "esbuild ./output/Note/index.js ./output/Add/index.js ./output/Logout/index.js ./output/Bookmarks/index.js ./output/AccountSettings/index.js --bundle --format=esm --target=chrome61,firefox60,edge18 --outdir=dist --splitting --minify --sourcemap" }, "devDependencies": { "esbuild": "^0.19.11", diff --git a/purs/src/AccountSettings.purs b/purs/src/AccountSettings.purs new file mode 100644 index 0000000..8f5882f --- /dev/null +++ b/purs/src/AccountSettings.purs @@ -0,0 +1,20 @@ +module AccountSettings where + +import Prelude + +import Component.AccountSettings (usetting) +import Data.Foldable (traverse_) +import Effect (Effect) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) +import Model (AccountSettings) +import Web.DOM.ParentNode (QuerySelector(..)) +import ViewRendered (viewRendered) + + +renderAccountSettings :: String -> AccountSettings -> Effect Unit +renderAccountSettings renderElSelector accountSettings = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (usetting accountSettings) unit el + viewRendered \ No newline at end of file diff --git a/purs/src/Add.purs b/purs/src/Add.purs new file mode 100644 index 0000000..bac987a --- /dev/null +++ b/purs/src/Add.purs @@ -0,0 +1,19 @@ +module Add where + +import Prelude + +import Component.Add (addbmark) +import Data.Foldable (traverse_) +import Effect (Effect) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) +import Model (Bookmark) +import Web.DOM.ParentNode (QuerySelector(..)) +import ViewRendered (viewRendered) + +renderAddForm :: String -> Bookmark -> Effect Unit +renderAddForm renderElSelector bmark = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (addbmark bmark) unit el + viewRendered \ No newline at end of file diff --git a/purs/src/Bookmarks.purs b/purs/src/Bookmarks.purs new file mode 100644 index 0000000..d14f68e --- /dev/null +++ b/purs/src/Bookmarks.purs @@ -0,0 +1,27 @@ +module Bookmarks where + +import Prelude + +import Component.TagCloud (tagcloudcomponent) +import Component.BList (blist) +import Data.Foldable (traverse_) +import Effect (Effect) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) +import Model (Bookmark, TagCloudMode, tagCloudModeToF) +import Web.DOM.ParentNode (QuerySelector(..)) +import ViewRendered (viewRendered) + + +renderBookmarks :: String -> Array Bookmark -> Effect Unit +renderBookmarks renderElSelector bmarks = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (blist bmarks) unit el + viewRendered + +renderTagCloud :: String -> TagCloudMode -> Effect Unit +renderTagCloud renderElSelector tagCloudMode = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (tagcloudcomponent (tagCloudModeToF tagCloudMode)) unit el \ No newline at end of file diff --git a/purs/src/App.purs b/purs/src/Core/App.purs similarity index 100% rename from purs/src/App.purs rename to purs/src/Core/App.purs diff --git a/purs/src/Globals.js b/purs/src/Core/Globals.js similarity index 100% rename from purs/src/Globals.js rename to purs/src/Core/Globals.js diff --git a/purs/src/Globals.purs b/purs/src/Core/Globals.purs similarity index 100% rename from purs/src/Globals.purs rename to purs/src/Core/Globals.purs diff --git a/purs/src/Marked.js b/purs/src/Core/Marked.js similarity index 100% rename from purs/src/Marked.js rename to purs/src/Core/Marked.js diff --git a/purs/src/Marked.purs b/purs/src/Core/Marked.purs similarity index 100% rename from purs/src/Marked.purs rename to purs/src/Core/Marked.purs diff --git a/purs/src/Model.purs b/purs/src/Core/Model.purs similarity index 100% rename from purs/src/Model.purs rename to purs/src/Core/Model.purs diff --git a/purs/src/Util.purs b/purs/src/Core/Util.purs similarity index 100% rename from purs/src/Util.purs rename to purs/src/Core/Util.purs diff --git a/purs/src/Core/ViewRendered.purs b/purs/src/Core/ViewRendered.purs new file mode 100644 index 0000000..00a3788 --- /dev/null +++ b/purs/src/Core/ViewRendered.purs @@ -0,0 +1,15 @@ +module ViewRendered where + +import Prelude + +import Data.Foldable (traverse_) +import Effect.Aff (Aff) +import Effect.Class (liftEffect) +import Halogen.Aff as HA +import Web.DOM.Element (setAttribute) +import Web.DOM.ParentNode (QuerySelector(..)) +import Web.HTML.HTMLElement (toElement) + +viewRendered :: Aff Unit +viewRendered = HA.selectElement (QuerySelector "#content") >>= traverse_ \el -> + liftEffect $ setAttribute "view-rendered" "" (toElement el) diff --git a/purs/src/Logout.purs b/purs/src/Logout.purs new file mode 100644 index 0000000..24b0a80 --- /dev/null +++ b/purs/src/Logout.purs @@ -0,0 +1,11 @@ +module Logout where + +import Prelude + +import App (logout) +import Effect (Effect) +import Effect.Aff (launchAff) +import Web.Event.Event (Event, preventDefault) + +logoutE :: Event -> Effect Unit +logoutE e = void <<< launchAff <<< logout =<< preventDefault e \ No newline at end of file diff --git a/purs/src/Main.purs b/purs/src/Main.purs deleted file mode 100644 index 42139bf..0000000 --- a/purs/src/Main.purs +++ /dev/null @@ -1,70 +0,0 @@ -module Main where - -import Prelude - -import App (logout) -import Component.AccountSettings (usetting) -import Component.Add (addbmark) -import Component.BList (blist) -import Component.NList (nlist) -import Component.NNote (nnote) -import Component.TagCloud (tagcloudcomponent) -import Data.Foldable (traverse_) -import Effect (Effect) -import Effect.Aff (Aff, launchAff) -import Effect.Class (liftEffect) -import Halogen.Aff as HA -import Halogen.VDom.Driver (runUI) -import Model (AccountSettings, Bookmark, Note, TagCloudMode, tagCloudModeToF) -import Web.DOM.Element (setAttribute) -import Web.DOM.ParentNode (QuerySelector(..)) -import Web.Event.Event (Event, preventDefault) -import Web.HTML.HTMLElement (toElement) - -logoutE :: Event -> Effect Unit -logoutE e = void <<< launchAff <<< logout =<< preventDefault e - -renderBookmarks :: String -> Array Bookmark -> Effect Unit -renderBookmarks renderElSelector bmarks = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (blist bmarks) unit el - viewRendered - -renderTagCloud :: String -> TagCloudMode -> Effect Unit -renderTagCloud renderElSelector tagCloudMode = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (tagcloudcomponent (tagCloudModeToF tagCloudMode)) unit el - -renderAddForm :: String -> Bookmark -> Effect Unit -renderAddForm renderElSelector bmark = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (addbmark bmark) unit el - viewRendered - -renderNotes :: String -> Array Note -> Effect Unit -renderNotes renderElSelector notes = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (nlist notes) unit el - viewRendered - -renderNote :: String -> Note -> Effect Unit -renderNote renderElSelector note = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (nnote note) unit el - viewRendered - -renderAccountSettings :: String -> AccountSettings -> Effect Unit -renderAccountSettings renderElSelector accountSettings = do - HA.runHalogenAff do - HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do - void $ runUI (usetting accountSettings) unit el - viewRendered - -viewRendered :: Aff Unit -viewRendered = HA.selectElement (QuerySelector "#content") >>= traverse_ \el -> - liftEffect $ setAttribute "view-rendered" "" (toElement el) diff --git a/purs/src/Note.purs b/purs/src/Note.purs new file mode 100644 index 0000000..72fa6aa --- /dev/null +++ b/purs/src/Note.purs @@ -0,0 +1,27 @@ +module Note where + +import Prelude + +import Component.NList (nlist) +import Component.NNote (nnote) +import Data.Foldable (traverse_) +import Effect (Effect) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) +import Model (Note) +import Web.DOM.ParentNode (QuerySelector(..)) +import ViewRendered (viewRendered) + +renderNotes :: String -> Array Note -> Effect Unit +renderNotes renderElSelector notes = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (nlist notes) unit el + viewRendered + +renderNote :: String -> Note -> Effect Unit +renderNote renderElSelector note = do + HA.runHalogenAff do + HA.selectElement (QuerySelector renderElSelector) >>= traverse_ \el -> do + void $ runUI (nnote note) unit el + viewRendered \ No newline at end of file diff --git a/src/Handler/AccountSettings.hs b/src/Handler/AccountSettings.hs index 466c9d5..7d1eb12 100644 --- a/src/Handler/AccountSettings.hs +++ b/src/Handler/AccountSettings.hs @@ -16,7 +16,7 @@ getAccountSettingsR = do |] toWidget [hamlet|