mirror of https://github.com/status-im/reagent.git
Optimize node modules, remove old stuff
- Removed webpack build for now, not up-to-date, can be added later if needed - Share node modules using symlinks for envs that use the same packages
This commit is contained in:
parent
b81af9308a
commit
c68f5a88f4
145
Makefile
145
Makefile
|
@ -1,145 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
PROF =
|
|
||||||
PORT = 3449
|
|
||||||
|
|
||||||
SITEDIR = outsite/public
|
|
||||||
OUTPUTDIR = $(SITEDIR)/js/out
|
|
||||||
|
|
||||||
|
|
||||||
# convenience shortcuts for continous building
|
|
||||||
##############################################
|
|
||||||
|
|
||||||
# development build with auto-reloading
|
|
||||||
run: figwheel
|
|
||||||
|
|
||||||
# development build with auto-reloading and site generation
|
|
||||||
runsite:
|
|
||||||
@$(MAKE) run PROF=+site,$(PROF)
|
|
||||||
|
|
||||||
# development build with auto-reloading and webpacked source
|
|
||||||
runpack: target/webpack/bundle.js
|
|
||||||
@$(MAKE) run PROF=+webpack,$(PROF)
|
|
||||||
|
|
||||||
# development build with figwheel, but no tests
|
|
||||||
runnotest:
|
|
||||||
@$(MAKE) run PROF=dev-notest,$(PROF)
|
|
||||||
|
|
||||||
# production build with auto-rebuild
|
|
||||||
runprod: clean
|
|
||||||
@$(MAKE) serve-site PROF=prod,$(PROF)
|
|
||||||
|
|
||||||
# production build with auto-rebuild and webpacked source
|
|
||||||
runprodpack: clean target/webpack/bundle.js
|
|
||||||
@$(MAKE) serve-site PROF=prod,webpack,$(PROF)
|
|
||||||
|
|
||||||
# production build with auto-rebuild and testing
|
|
||||||
runprodtest: clean
|
|
||||||
@$(MAKE) serve-site PROF=prod-test,$(PROF)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
lein clean
|
|
||||||
|
|
||||||
|
|
||||||
## Subtargets
|
|
||||||
|
|
||||||
figwheel: trigger-build
|
|
||||||
@echo "Will start figwheel server at: http://127.0.0.1:$(PORT)\n"
|
|
||||||
lein with-profile $(PROF), figwheel
|
|
||||||
|
|
||||||
serve-site: trigger-build
|
|
||||||
@echo "Starting site at: http://127.0.0.1:$(PORT)/public\n"
|
|
||||||
( trap "kill 0" SIGINT SIGTERM EXIT; \
|
|
||||||
( cd $(SITEDIR)/.. && python -m SimpleHTTPServer $(PORT) & ); \
|
|
||||||
lein with-profile $(PROF), cljsbuild auto )
|
|
||||||
|
|
||||||
trigger-build:
|
|
||||||
# always trigger build to make sure page-generation works
|
|
||||||
@echo "(ns empty.generated.ns)" > demo/empty.cljs
|
|
||||||
@(echo "/* Generated, do not modify */\n\n" && \
|
|
||||||
cat examples/todomvc/todos.css examples/simple/example.css) \
|
|
||||||
> site/public/css/examples.css
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## gh-pages support
|
|
||||||
###################
|
|
||||||
|
|
||||||
# build site and push upstream to the gh-pages branch
|
|
||||||
push-gh-pages: build-gh-pages
|
|
||||||
git push origin gh-pages:gh-pages
|
|
||||||
|
|
||||||
# build site and push to reagent-project's doc site
|
|
||||||
push-project-docs: gen-site gen-docs
|
|
||||||
# sanity check
|
|
||||||
test -f $(SITEDIR)/index.html
|
|
||||||
test ! -e $(OUTPUTDIR)
|
|
||||||
rm -fr tmp
|
|
||||||
git clone git@github.com:reagent-project/reagent-project.github.io.git tmp
|
|
||||||
rm -fr tmp/*
|
|
||||||
cp -r $(SITEDIR)/* tmp/
|
|
||||||
mkdir -p tmp/docs/master/
|
|
||||||
cp -r target/doc/* tmp/docs/master/
|
|
||||||
cd tmp && \
|
|
||||||
git add . && git commit -m "Updated" && \
|
|
||||||
git push
|
|
||||||
rm -rf tmp
|
|
||||||
|
|
||||||
# build site into a gh-pages branch
|
|
||||||
build-gh-pages: gen-site gh-pages-add
|
|
||||||
|
|
||||||
gen-site: clean node_modules
|
|
||||||
lein with-profile prerender cljsbuild once
|
|
||||||
node pre-render/main.js
|
|
||||||
|
|
||||||
gen-docs: clean
|
|
||||||
lein codox
|
|
||||||
|
|
||||||
# copy contents of $(SITEDIR) to branch gh-pages
|
|
||||||
gh-pages-add:
|
|
||||||
# sanity check
|
|
||||||
test -f $(SITEDIR)/index.html
|
|
||||||
test ! -e $(OUTPUTDIR)
|
|
||||||
# make sure gh-pages branch exists
|
|
||||||
git show-branch gh-pages || true | git mktree | \
|
|
||||||
xargs git commit-tree | xargs git branch gh-pages
|
|
||||||
# clone gh-pages branch, and commit site to that
|
|
||||||
cd $(SITEDIR) && \
|
|
||||||
rm -rf .git tmp && \
|
|
||||||
git clone ../.. -lnb gh-pages tmp && \
|
|
||||||
mv tmp/.git . && \
|
|
||||||
git add . && git commit -m "Updated" && \
|
|
||||||
git push && rm -rf .git tmp
|
|
||||||
|
|
||||||
|
|
||||||
## Webpack
|
|
||||||
##########
|
|
||||||
|
|
||||||
target/webpack/bundle.js: node_modules lib/modules.js package.json Makefile
|
|
||||||
npm run bundle
|
|
||||||
|
|
||||||
node_modules:
|
|
||||||
npm install
|
|
||||||
|
|
||||||
|
|
||||||
## Misc utilities
|
|
||||||
#################
|
|
||||||
|
|
||||||
show-outdated:
|
|
||||||
lein ancient :all
|
|
||||||
|
|
||||||
VERSION := `sed -n -e '/(defproject reagent/ s/.*"\(.*\)"/\1/p' project.clj`
|
|
||||||
|
|
||||||
setversion:
|
|
||||||
version=$(VERSION); \
|
|
||||||
find . -name project.clj -o -name README.md | \
|
|
||||||
xargs -n1 sed -i "" -e 's,\(reagent "\)\([^"]*\)",\1'"$$version"'"',g
|
|
||||||
|
|
||||||
tag: setversion
|
|
||||||
if git rev-parse v$(VERSION) 2>/dev/null; then \
|
|
||||||
echo "Tag already exists"; \
|
|
||||||
exit 1; \
|
|
||||||
else \
|
|
||||||
git commit --allow-empty -a -v -e -m"Version "$(VERSION) && \
|
|
||||||
git tag v$(VERSION); \
|
|
||||||
fi
|
|
|
@ -14,7 +14,7 @@ Reagent provides a way to write efficient React components using (almost) nothin
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
* [JDK](http://www.azul.com/downloads/zulu/)
|
* Java JDK
|
||||||
* [Leiningen](http://leiningen.org/)
|
* [Leiningen](http://leiningen.org/)
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
@ -36,7 +36,7 @@ To use Reagent in an existing project you add this to your dependencies in `proj
|
||||||
|
|
||||||
This is all you need to do if you want the standard version of React. If you want the version of React with addons, you'd use something like this instead:
|
This is all you need to do if you want the standard version of React. If you want the version of React with addons, you'd use something like this instead:
|
||||||
|
|
||||||
[reagent "0.6.0" :exclusions [cljsjs/react]]
|
[reagent "0.7.0" :exclusions [cljsjs/react]]
|
||||||
[cljsjs/react-with-addons "15.4.2-2"]
|
[cljsjs/react-with-addons "15.4.2-2"]
|
||||||
|
|
||||||
If you want to use your own build of React (or React from a CDN), you have to use `:exclusions` variant of the dependency, and also provide a file named "cljsjs/react.cljs", containing just `(ns cljsjs.react)`, in your project.
|
If you want to use your own build of React (or React from a CDN), you have to use `:exclusions` variant of the dependency, and also provide a file named "cljsjs/react.cljs", containing just `(ns cljsjs.react)`, in your project.
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Reagent development
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
|
||||||
|
To prepare different environments for tests run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./prepare-test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
After this, you can run the full test set:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./run-tests.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Running all the tests can take a while, so while developing Reagent,
|
||||||
|
you might want to focus on one test environment, and use Figwheel to
|
||||||
|
run tests on your browser:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd test-environments/browser-umd-react-16
|
||||||
|
# If build requires e.g. Lein profiles or such,
|
||||||
|
# the folder contains figwheel.sh script:
|
||||||
|
./figwheel.sh
|
||||||
|
# Else, just run figwheel normally:
|
||||||
|
lein figwheel
|
||||||
|
|
||||||
|
# Open http://0.0.0.0:3449 on a browser
|
||||||
|
# Check console for test output
|
||||||
|
```
|
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
|
@ -1,18 +1,7 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
|
||||||
"@cljs-oss/module-deps": "1.1.1",
|
|
||||||
"create-react-class": "^15.6.2",
|
|
||||||
"react": "^15.6.2",
|
|
||||||
"react-dom": "^15.6.2"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"bundle": "webpack && NODE_ENV=production webpack -p"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^5.8.25",
|
|
||||||
"karma": "^1.7.1",
|
"karma": "^1.7.1",
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-cljs-test": "^0.1.0",
|
"karma-cljs-test": "^0.1.0"
|
||||||
"webpack": "^1.12.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,23 @@
|
||||||
#!/bin/bash
|
#!/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
|
for env in test-environments/*; do
|
||||||
|
name=$(basename "$env")
|
||||||
(
|
(
|
||||||
cd "$env"
|
cd "$env"
|
||||||
|
if [[ ! -L node_modules ]]; then
|
||||||
|
echo "Install $name packages"
|
||||||
npm install
|
npm install
|
||||||
|
else
|
||||||
|
echo "$name uses $(readlink node_modules)"
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
|
echo
|
||||||
done
|
done
|
||||||
|
|
50
project.clj
50
project.clj
|
@ -24,32 +24,16 @@
|
||||||
:source-paths ["src"]}
|
:source-paths ["src"]}
|
||||||
|
|
||||||
:profiles {:node-test [:test {:cljsbuild
|
:profiles {:node-test [:test {:cljsbuild
|
||||||
{:builds {:client {:compiler {:target :nodejs}}}}}]
|
{:builds {:client {:compiler {:target :nodejs
|
||||||
|
:process-shim false}}}}}]
|
||||||
|
|
||||||
:test {:cljsbuild
|
:test {:cljsbuild
|
||||||
{:builds {:client {:source-paths ["test"]
|
{:builds {:client {:compiler {:main "reagenttest.runtests"}}}}}
|
||||||
:compiler {:main "reagenttest.runtests"}}}}}
|
|
||||||
|
|
||||||
:react-16 {:dependencies [[cljsjs/react "16.0.0-0"]
|
:react-16 {:dependencies [[cljsjs/react "16.0.0-0"]
|
||||||
[cljsjs/react-dom "16.0.0-0"]
|
[cljsjs/react-dom "16.0.0-0"]
|
||||||
[cljsjs/react-dom-server "16.0.0-0"]]}
|
[cljsjs/react-dom-server "16.0.0-0"]]}
|
||||||
|
|
||||||
:fig [{:dependencies [[figwheel "0.5.14"]
|
|
||||||
[doo "0.1.8"]]
|
|
||||||
:plugins [[lein-figwheel "0.5.14"]]
|
|
||||||
:source-paths ["demo" "test"] ;; for lighttable
|
|
||||||
:resource-paths ["site" "outsite"]
|
|
||||||
:figwheel {:css-dirs ["site/public/css"]}
|
|
||||||
:cljsbuild
|
|
||||||
{:builds
|
|
||||||
{:client
|
|
||||||
{:figwheel true
|
|
||||||
:compiler {:source-map true
|
|
||||||
:optimizations :none
|
|
||||||
;; :recompile-dependents false
|
|
||||||
:output-dir "outsite/public/js/out"
|
|
||||||
:asset-path "js/out"}}}}}]
|
|
||||||
|
|
||||||
:site {:resource-paths ^:replace ["outsite"]
|
:site {:resource-paths ^:replace ["outsite"]
|
||||||
:figwheel {:css-dirs ^:replace ["outsite/public/css"]}}
|
:figwheel {:css-dirs ^:replace ["outsite/public/css"]}}
|
||||||
|
|
||||||
|
@ -71,20 +55,23 @@
|
||||||
:output-to "pre-render/main.js"
|
:output-to "pre-render/main.js"
|
||||||
:output-dir "pre-render/out"}}}}}]
|
:output-dir "pre-render/out"}}}}}]
|
||||||
|
|
||||||
:webpack {:cljsbuild
|
|
||||||
{:builds {:client
|
|
||||||
{:compiler
|
|
||||||
{:foreign-libs
|
|
||||||
[{:file "target/webpack/bundle.js"
|
|
||||||
:file-min "target/webpack/bundle.min.js"
|
|
||||||
:provides ["cljsjs.react.dom"
|
|
||||||
"cljsjs.react.dom.server"
|
|
||||||
"cljsjs.react"]
|
|
||||||
:requires []}]}}}}}
|
|
||||||
|
|
||||||
:prod-test [:prod :test]
|
:prod-test [:prod :test]
|
||||||
|
|
||||||
:dev [:fig]}
|
:dev {:dependencies [[figwheel "0.5.14"]
|
||||||
|
[doo "0.1.8"]]
|
||||||
|
:plugins [[lein-figwheel "0.5.14"]]
|
||||||
|
:source-paths ["demo"] ;; for lighttable
|
||||||
|
:resource-paths ["site" "outsite"]
|
||||||
|
:figwheel {:css-dirs ["site/public/css"]}
|
||||||
|
:cljsbuild
|
||||||
|
{:builds
|
||||||
|
{:client
|
||||||
|
{:figwheel true
|
||||||
|
:compiler {:source-map true
|
||||||
|
:optimizations :none
|
||||||
|
;; :recompile-dependents false
|
||||||
|
:output-dir "outsite/public/js/out"
|
||||||
|
:asset-path "js/out"}}}}}}
|
||||||
|
|
||||||
:clean-targets ^{:protect false} [:target-path :compile-path
|
:clean-targets ^{:protect false} [:target-path :compile-path
|
||||||
"outsite/public/js"
|
"outsite/public/js"
|
||||||
|
@ -98,6 +85,7 @@
|
||||||
:cljsbuild {:builds {:client
|
:cljsbuild {:builds {:client
|
||||||
{:source-paths ["src"
|
{:source-paths ["src"
|
||||||
"demo"
|
"demo"
|
||||||
|
"test"
|
||||||
"examples/todomvc/src"
|
"examples/todomvc/src"
|
||||||
"examples/simple/src"
|
"examples/simple/src"
|
||||||
"examples/geometry/src"]
|
"examples/geometry/src"]
|
||||||
|
|
|
@ -13,7 +13,6 @@ EXIT=0
|
||||||
SUMMARY="$blue##\n## SUMMARY\n##$reset\n\n"
|
SUMMARY="$blue##\n## SUMMARY\n##$reset\n\n"
|
||||||
|
|
||||||
for env in test-environments/*; do
|
for env in test-environments/*; do
|
||||||
FAIL=0
|
|
||||||
name=$(basename "$env")
|
name=$(basename "$env")
|
||||||
(
|
(
|
||||||
cd "$env"
|
cd "$env"
|
||||||
|
@ -23,8 +22,7 @@ for env in test-environments/*; do
|
||||||
echo
|
echo
|
||||||
./test.sh
|
./test.sh
|
||||||
)
|
)
|
||||||
[[ $? != "0" ]] && FAIL=1
|
if [[ $? != "0" ]]; then
|
||||||
if [[ $FAIL != "0" ]]; then
|
|
||||||
echo
|
echo
|
||||||
echo -e "${red}FAIL $name$reset"
|
echo -e "${red}FAIL $name$reset"
|
||||||
SUMMARY="$SUMMARY${red}FAIL $name$reset\n"
|
SUMMARY="$SUMMARY${red}FAIL $name$reset\n"
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
../browser-umd/package-lock.json
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -x
|
||||||
|
lein with-profile dev,react-16 figwheel
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
../browser-umd/package-lock.json
|
|
@ -0,0 +1 @@
|
||||||
|
../../site
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
../../package-lock.json
|
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"devDependencies": {
|
|
||||||
"karma": "^1.7.1",
|
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
|
||||||
"karma-cljs-test": "^0.1.0"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
../../package.json
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
../browser-node/package-lock.json
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@cljs-oss/module-deps": "1.1.1",
|
|
||||||
"create-react-class": "^15.6.2",
|
|
||||||
"react": "^15.6.2",
|
|
||||||
"react-dom": "^15.6.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"karma": "^1.7.1",
|
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
|
||||||
"karma-cljs-test": "^0.1.0"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
../browser-node/package.json
|
|
@ -1,23 +0,0 @@
|
||||||
var path = require('path');
|
|
||||||
var webpack = require('webpack');
|
|
||||||
|
|
||||||
var prod = process.env.NODE_ENV === "production";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: './lib/modules.js',
|
|
||||||
output: {
|
|
||||||
path: "./target/webpack/",
|
|
||||||
filename: prod ? 'bundle.min.js' : 'bundle.js'
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
{ test: /.jsx?$/, loader: 'babel-loader', include: "./lib" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.DefinePlugin(
|
|
||||||
{'process.env': { 'NODE_ENV': prod ? '"production"' : '"development"'}})
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue