~benaiah/fennel-openresty

992db6cd1e81df23370a05800852717439d83468 — Benaiah Mischenko 2 years ago 4905ad1
Add React to app and use a second makefile for the app
7 files changed, 87 insertions(+), 13 deletions(-)

A app/makefile
A app/modules
M app/package.json
M app/src/app.fnl
M app/yarn.lock
M makefile
M server/server.fnl
A app/makefile => app/makefile +13 -0
@@ 0,0 1,13 @@
.PHONY: all
all: dist/main.js

.PHONY: clean
clean:
	rm -f dist/*
	rm -f src/*.lua
	rm -rf node_modules

dist/main.js: src/app.lua src/index.js
	yarn && yarn run build
src/app.lua: src/app.fnl
	modules/fennel/fennel --compile $^ > $@

A app/modules => app/modules +1 -0
@@ 0,0 1,1 @@
../modules
\ No newline at end of file

M app/package.json => app/package.json +3 -1
@@ 13,6 13,8 @@
    "webpack-cli": "^3.2.3"
  },
  "dependencies": {
    "fengari-web": "^0.1.4"
    "fengari-web": "^0.1.4",
    "react": "^16.8.1",
    "react-dom": "^16.8.1"
  }
}

M app/src/app.fnl => app/src/app.fnl +9 -0
@@ 1,1 1,10 @@
(require-macros :src.react-macros)

(local React (require "react"))
(local ReactDOM (require "react-dom"))

(: ReactDOM :render
   (c! [:h1 {} "Hello from React!"])
   (: js.global.document :getElementById :react-root))

(print "Hello world!")

M app/yarn.lock => app/yarn.lock +54 -1
@@ 1452,6 1452,11 @@ isobject@^3.0.0, isobject@^3.0.1:
  resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
  integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

"js-tokens@^3.0.0 || ^4.0.0":
  version "4.0.0"
  resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
  integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

json-parse-better-errors@^1.0.2:
  version "1.0.2"
  resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"


@@ 1522,6 1527,13 @@ locate-path@^3.0.0:
    p-locate "^3.0.0"
    path-exists "^3.0.0"

loose-envify@^1.1.0:
  version "1.4.0"
  resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
  integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
  dependencies:
    js-tokens "^3.0.0 || ^4.0.0"

lru-cache@^5.1.1:
  version "5.1.1"
  resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"


@@ 1844,7 1856,7 @@ number-is-nan@^1.0.0:
  resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
  integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=

object-assign@^4.1.0:
object-assign@^4.1.0, object-assign@^4.1.1:
  version "4.1.1"
  resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
  integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=


@@ 2049,6 2061,14 @@ promise-inflight@^1.0.1:
  resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
  integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

prop-types@^15.6.2:
  version "15.7.1"
  resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.1.tgz#2fa61e0a699d428b40320127733ee2931f05d9d1"
  integrity sha512-f8Lku2z9kERjOCcnDOPm68EBJAO2K00Q5mSgPAUE/gJuBgsYLbVy6owSrtcHj90zt8PvW+z0qaIIgsIhHOa1Qw==
  dependencies:
    object-assign "^4.1.1"
    react-is "^16.8.1"

prr@~1.0.1:
  version "1.0.1"
  resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"


@@ 2141,6 2161,31 @@ rc@^1.2.7:
    minimist "^1.2.0"
    strip-json-comments "~2.0.1"

react-dom@^16.8.1:
  version "16.8.1"
  resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.1.tgz#ec860f98853d09d39bafd3a6f1e12389d283dbb4"
  integrity sha512-N74IZUrPt6UiDjXaO7UbDDFXeUXnVhZzeRLy/6iqqN1ipfjrhR60Bp5NuBK+rv3GMdqdIuwIl22u1SYwf330bg==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"
    prop-types "^15.6.2"
    scheduler "^0.13.1"

react-is@^16.8.1:
  version "16.8.1"
  resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.1.tgz#a80141e246eb894824fb4f2901c0c50ef31d4cdb"
  integrity sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA==

react@^16.8.1:
  version "16.8.1"
  resolved "https://registry.yarnpkg.com/react/-/react-16.8.1.tgz#ae11831f6cb2a05d58603a976afc8a558e852c4a"
  integrity sha512-wLw5CFGPdo7p/AgteFz7GblI2JPOos0+biSoxf1FPsGxWQZdN/pj6oToJs1crn61DL3Ln7mN86uZ4j74p31ELQ==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"
    prop-types "^15.6.2"
    scheduler "^0.13.1"

"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6:
  version "2.3.6"
  resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"


@@ 2275,6 2320,14 @@ sax@^1.2.4:
  resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
  integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==

scheduler@^0.13.1:
  version "0.13.1"
  resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.1.tgz#1a217df1bfaabaf4f1b92a9127d5d732d85a9591"
  integrity sha512-VJKOkiKIN2/6NOoexuypwSrybx13MY7NSy9RNt8wPvZDMRT1CW6qlpF5jXRToXNHz3uWzbm2elNpZfXfGPqP9A==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"

schema-utils@^0.4.5:
  version "0.4.7"
  resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"

M makefile => makefile +3 -7
@@ 16,13 16,9 @@ server/html.lua: server/html.fnl ; modules/fennel/fennel --compile $^ > $@
server/wss.lua: server/wss.fnl ; modules/fennel/fennel --compile $^ > $@

.PHONY: app
app: app/dist/main.js
app:
	$(MAKE) -C app all

.PHONY: clean-app
clean-app:
	rm -f dist/*
	rm -f app/src/*.lua
	rm -rf app/node_modules

app/dist/main.js: app/src/app.lua app/src/index.js ; cd app && yarn && yarn run build
app/src/app.lua: app/src/app.fnl ; modules/fennel/fennel --compile $^ > $@
	$(MAKE) -C app clean

M server/server.fnl => server/server.fnl +4 -4
@@ 7,16 7,16 @@
       [:html {}
        [:head {}
         [:meta {:charset "UTF-8"}]
         [:script {} script]
         [:script {:src "app.js"}]]
         [:script {} script]]
        [:body {}
         [:div {:id :react-root}]
         [:div {}
          [:h1 {} "Hello, world!"]
          [:form {:onSubmit "return send();"}
           [:button {:type :button :onClick "return connect();"} :Connect]
           [:button {:type :button :onClick "return disconnect();"} :Disconnect]
           [:input {:id :text :type :text}]
           [:button {:type :submit} :Send]]]
         [:ol {:id :log}]]])
         [:ol {:id :log}]
         [:script {:src "app.js"}]]])

(ngx.say (.. "<!doctype html>\n" (html homepage)))