Skip to content

Commit

Permalink
Use React 16 and simplify test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Apr 3, 2018
1 parent 26de1c4 commit e095696
Show file tree
Hide file tree
Showing 77 changed files with 465 additions and 11,042 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ reagent.iml
.lein-failures

node_modules

test-environments/*/junit
junit
405 changes: 317 additions & 88 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"private": true,
"dependencies": {
"@cljs-oss/module-deps": "1.1.1",
"create-react-class": "15.6.2",
"prop-types": "15.6.0",
"react": "16.3.0",
"react-dom": "16.3.0"
},
"devDependencies": {
"gzip-size-cli": "^2.1.0",
"karma": "2.0.0",
Expand Down
20 changes: 0 additions & 20 deletions prepare-tests.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
#!/bin/bash

npm install

echo

# Symlinked node_modules, package.json and package-lock.json
# are used to share node_modules between environments that
# use the same packages.

for env in test-environments/*; do
name=$(basename "$env")
(
cd "$env"
if [[ ! -L node_modules ]]; then
echo "Install $name packages"
npm install
else
echo "$name uses $(readlink node_modules)"
fi
)
echo
done
71 changes: 60 additions & 11 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
;; If :npm-deps enabled, these are used only for externs.
;; Without direct react dependency, other packages,
;; like react-leaflet might have closer dependency to a other version.
[cljsjs/react "15.6.2-4"]
[cljsjs/react-dom "15.6.2-4"]
[cljsjs/react-dom-server "15.6.2-4"]
[cljsjs/react "16.3.0-0"]
[cljsjs/react-dom "16.3.0-0"]
[cljsjs/react-dom-server "16.3.0-0"]
[cljsjs/create-react-class "15.6.2-0"]]

:plugins [[lein-cljsbuild "1.1.7"]
Expand All @@ -24,11 +24,7 @@
:exclude clojure.string
:source-paths ["src"]}

:profiles {:react-16 {:dependencies [[cljsjs/react "16.3.0-0"]
[cljsjs/react-dom "16.3.0-0"]
[cljsjs/react-dom-server "16.3.0-0"]]}

:dev {:dependencies [[figwheel "0.5.15"]
:profiles {:dev {:dependencies [[figwheel "0.5.15"]
[doo "0.1.10"]
[cljsjs/prop-types "15.6.0-0"]]
:source-paths ["demo" "examples/todomvc/src" "examples/simple/src" "examples/geometry/src"]
Expand All @@ -53,7 +49,20 @@
:output-dir "target/cljsbuild/client/public/js/out"
:output-to "target/cljsbuild/client/public/js/main.js"
:asset-path "js/out"
:npm-deps false}}

:client-npm
{:source-paths ["src" "demo" "test"]
:figwheel true
:compiler {:parallel-build true
:source-map true
:optimizations :none
:main "reagentdemo.dev"
:output-dir "target/cljsbuild/client-npm/public/js/out"
:output-to "target/cljsbuild/client-npm/public/js/main.js"
:asset-path "js/out"
;; add process.env.node_env preload
; :npm-deps true
:process-shim true}}

:test
Expand All @@ -65,8 +74,22 @@
:asset-path "js/out"
:output-dir "target/cljsbuild/test/out"
:output-to "target/cljsbuild/test/main.js"
:npm-deps false
:aot-cache true}}

:test-npm
{:source-paths ["src" "test"]
:compiler {:parallel-build true
:source-map true
:optimizations :none
:main "reagenttest.runtests"
:asset-path "js/out"
:output-dir "target/cljsbuild/test-npm/out"
:output-to "target/cljsbuild/test-npm/main.js"
; :npm-deps true
;; add process.env.node_env preload
:process-shim true}}
:process-shim true
:aot-cache true}}

:prerender
{:source-paths ["src" "demo"]
Expand All @@ -84,7 +107,18 @@
:source-map true
:optimizations :none
:output-dir "target/cljsbuild/node-test/out"
:output-to "target/cljsbuild/node-test/main.js"}}
:output-to "target/cljsbuild/node-test/main.js"
:npm-deps false}}

:node-test-npm
{:source-paths ["src" "test"]
:compiler {:main "reagenttest.runtests"
:target :nodejs
:parallel-build true
:source-map true
:optimizations :none
:output-dir "target/cljsbuild/node-test-npm/out"
:output-to "target/cljsbuild/node-test-npm/main.js"}}

:prod
{:source-paths ["src" "demo"]
Expand All @@ -106,4 +140,19 @@
;; :pseudo-names true
:output-to "target/cljsbuild/prod-test/main.js"
:output-dir "target/cljsbuild/prod-test/out"
:closure-warnings {:global-this :off}}}}})
:closure-warnings {:global-this :off}
:npm-deps false
:aot-cache true}}

:prod-test-npm
{:source-paths ["src" "demo"]
:compiler {:main "reagenttest.runtests"
:optimizations :advanced
:elide-asserts true
:pretty-print false
;; :pseudo-names true
:output-to "target/cljsbuild/prod-test-npm/main.js"
:output-dir "target/cljsbuild/prod-test-npm/out"
:closure-warnings {:global-this :off}
:aot-cache true}}
}})
18 changes: 1 addition & 17 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ SUMMARY="$blue##\n## SUMMARY\n##$reset\n\n"

for env in test-environments/*; do
name=$(basename "$env")
(
cd "$env"
echo -e "$blue##"
echo -e "## TESTING $name"
echo -e "##$reset"
echo
./test.sh
)
$env/test.sh
if [[ $? != "0" ]]; then
echo
echo -e "${red}FAIL $name$reset"
Expand All @@ -36,17 +33,4 @@ done

echo -e "$SUMMARY"

echo

for env in test-environments/*-prod; do
name=$(basename "$env")
path="test-environments/$name/target/cljsbuild/prod-test/main.js"
if [[ -f "$path" ]]; then
echo "$name $(./node_modules/.bin/gzip-size "$path")"
fi
done

echo
echo "NOTE: These sizes include Reagent test suite which also uses React-dom/server, so this doesn't demonstrate real use case."

exit $EXIT
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -ex
lein do clean, doo chrome-headless prod-test once
test -f target/cljsbuild/prod-test/main.js
../../node_modules/.bin/gzip-size target/cljsbuild/prod-test/main.js
node_modules/.bin/gzip-size target/cljsbuild/prod-test/main.js
File renamed without changes.
1 change: 0 additions & 1 deletion test-environments/browser-node-react-16/demo

This file was deleted.

1 change: 0 additions & 1 deletion test-environments/browser-node-react-16/examples

This file was deleted.

Loading

0 comments on commit e095696

Please sign in to comment.