Split release-js into release-node and release-browser.

Also expand our clean targets, and rewrite our build targets to generate
different code for Node and Firefox.
This commit is contained in:
Richard Newman 2016-09-07 17:00:47 -07:00
parent 9dbda3d9d8
commit e76d7305d1
12 changed files with 160 additions and 41 deletions

View file

@ -11,37 +11,88 @@
[com.taoensso/tufte "1.0.2"]
[jamesmacaulay/cljs-promises "0.1.0"]]
:cljsbuild {:builds {:release {
:source-paths ["src"]
:cljsbuild {:builds
{
:release-node
{
:source-paths ["src-node" "src"]
:assert false
:compiler {:output-to "release-js/datomish.bare.js"
:optimizations :advanced
:pretty-print false
:compiler
{
:elide-asserts true
:output-wrapper false
:parallel-build true}
:notify-command ["release-js/wrap_bare.sh"]}
:advanced {:source-paths ["src"]
:compiler {:output-to "target/advanced/datomish.js"
:hashbang false
:language-in :ecmascript5
:language-out :ecmascript5
:optimizations :advanced
:source-map "target/advanced/datomish.js.map"
:output-dir "release-node"
:output-to "release-node/datomish.bare.js"
:output-wrapper false
:parallel-build true
:pretty-print false
:target :nodejs
}
:notify-command ["release-node/wrap_bare.sh"]}
:release-browser
;; Release builds for use in Firefox must:
;; * Use :optimizations > :none, so that a single file is generated
;; without a need to import Closure's own libs.
;; * Be wrapped, so that a CommonJS module is produced.
;; * Have a preload script that defines what `println` does.
;;
;; There's no point in generating a source map -- it'll be wrong
;; due to wrapping.
{
:source-paths ["src-browser" "src"]
:assert false
:compiler
{
:elide-asserts true
:language-in :ecmascript5
:language-out :ecmascript5
:optimizations :advanced
:output-dir "release-browser"
:output-to "release-browser/datomish.bare.js"
:output-wrapper false
:parallel-build true
:preloads [datomish.preload]
:pretty-print true
:recompile-dependents true
:parallel-build true
}}
:test {
:source-paths ["src" "test"]
:compiler {:output-to "target/test/datomish.js"
:output-dir "target/test"
:main datomish.test
:optimizations :none
:source-map true
:recompile-dependents true
:pseudo-names true
:static-fns true
}
:notify-command ["release-browser/wrap_bare.sh"]}
:advanced
{:source-paths ["src-node" "src"]
:compiler
{
:language-in :ecmascript5
:language-out :ecmascript5
:output-dir "target/advanced"
:output-to "target/advanced/datomish.js"
:optimizations :advanced
:parallel-build true
:pretty-print true
:source-map "target/advanced/datomish.js.map"
:target :nodejs
}}
}
}
:test
{
:source-paths ["src-node" "src" "test"]
:compiler
{
:language-in :ecmascript5
:language-out :ecmascript5
:main datomish.test
:optimizations :none
:output-dir "target/test"
:output-to "target/test/datomish.js"
:parallel-build true
:source-map true
:target :nodejs
}}
}}
:profiles {:dev {:dependencies [[cljsbuild "1.1.3"]
[tempfile "0.2.0"]
@ -59,7 +110,26 @@
:doo {:build "test"}
:clean-targets ^{:protect false} ["target"
"release-js/datomish.bare.js"
"release-js/datomish.js"]
:clean-targets ^{:protect false}
[
"target"
"release-node/cljs/"
"release-node/cljs_promises/"
"release-node/clojure/"
"release-node/datascript/"
"release-node/datomish/"
"release-node/honeysql/"
"release-node/taoensso/"
"release-node/datomish.bare.js"
"release-node/datomish.js"
"release-browser/cljs/"
"release-browser/cljs_promises/"
"release-browser/clojure/"
"release-browser/datascript/"
"release-browser/datomish/"
"release-browser/honeysql/"
"release-browser/taoensso/"
"release-browser/datomish.bare.js"
"release-browser/datomish.js"
]
)

7
release-browser/wrap_bare.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
set -e
(cat release-browser/wrapper.prefix; cat release-browser/datomish.bare.js; cat release-browser/wrapper.suffix) > release-browser/datomish.js
echo "Packed release-browser/datomish.js"

View file

@ -1,7 +0,0 @@
#!/bin/sh
set -e
(cat release-js/wrapper.prefix; cat release-js/datomish.bare.js; cat release-js/wrapper.suffix) > release-js/datomish.js
echo "Packed release-js/datomish.js"

5
release-node/README.md Normal file
View file

@ -0,0 +1,5 @@
# Datomish
Datomish is a persistent, embedded knowledge base. It's written in ClojureScript, and draws heavily on [DataScript](https://github.com/tonsky/datascript) and [Datomic](http://datomic.com).
For more info, check out the [project page](https://github.com/mozila/datomish).

View file

@ -0,0 +1,2 @@
var d = require('./datomish');
console.log(d.q("[:find ?e ?v :where [?e \"name\" ?v] {:x :y}]"));

7
release-node/wrap_bare.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
set -e
(cat release-node/wrapper.prefix && cat release-node/datomish.bare.js && cat release-node/wrapper.suffix) > release-node/datomish.js
echo "Packed release-node/datomish.js"

View file

@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Datomish 0.1.0-SNAPSHOT
(function (definition) {
// This file will function properly as a <script> tag, or a module
// using CommonJS and NodeJS or RequireJS module formats.
// Wrapper gratefully adapted from:
// https://github.com/kriskowal/q/blob/v1/q.js
// https://github.com/swannodette/mori/blob/master/support/wrapper.js
// https://github.com/tonsky/datascript/blob/master/release-js/wrapper.js
// CommonJS
if (typeof exports === "object") {
module.exports = definition();
// RequireJS
} else if (typeof define === "function" && define.amd) {
define(definition);
// <script>
} else {
datomish = definition();
}
})(function () {
return function () {

View file

@ -0,0 +1,6 @@
;return this.datomish.js;
}.call({});
});