Skip to content

CLJS-3372: Vendorize data.json, transit-clj, and tools.reader #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{:paths ["src/main/clojure" "src/main/cljs" "resources"]
:deps
{com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220502"}
com.cognitect/transit-clj {:mvn/version "1.0.329"}
com.cognitect/transit-java {:mvn/version "1.0.362"}
org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/core.specs.alpha {:mvn/version "0.1.24"}
org.clojure/data.json {:mvn/version "2.4.0"}
org.clojure/google-closure-library {:mvn/version "0.0-20211011-0726fdeb"}
org.clojure/spec.alpha {:mvn/version "0.1.143"}
org.clojure/tools.reader {:mvn/version "1.3.6"}
Expand Down
11 changes: 2 additions & 9 deletions pom.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,15 @@
<artifactId>google-closure-library</artifactId>
<version>0.0-20211011-0726fdeb</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>data.json</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.reader</artifactId>
<version>1.3.6</version>
</dependency>
<dependency>
<groupId>com.cognitect</groupId>
<artifactId>transit-clj</artifactId>
<version>1.0.329</version>
<artifactId>transit-java</artifactId>
<version>1.0.362</version>
<exclusions>
<exclusion>
<groupId>org.clojure</groupId>
Expand Down Expand Up @@ -284,8 +279,6 @@
<cleanAOTNamespaces>true</cleanAOTNamespaces>
<namespaces>
<namespace>!clojure.tools.reader.*</namespace>
<namespace>!clojure.data.json.*</namespace>
<namespace>!cognitect.transit.*</namespace>
</namespaces>
</configuration>
</execution>
Expand Down
3 changes: 1 addition & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/spec.alpha "0.1.143"]
[org.clojure/core.specs.alpha "0.1.24"]
[org.clojure/data.json "2.4.0"]
[org.clojure/tools.reader "1.3.6"]
[org.clojure/test.check "1.1.1" :scope "test"]
[com.cognitect/transit-clj "1.0.329"]
[com.cognitect/transit-java "1.0.362"]
[org.clojure/google-closure-library "0.0-20211011-0726fdeb"]
[com.google.javascript/closure-compiler-unshaded "v20220502"]]
:profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
Expand Down
16 changes: 0 additions & 16 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ CLOJURE_RELEASE="1.9.0"
SPEC_ALPHA_RELEASE="0.1.143"
CORE_SPECS_ALPHA_RELEASE="0.1.24"
CLOSURE_RELEASE="20220502"
DJSON_RELEASE="2.4.0"
TRANSIT_RELEASE="1.0.329"
GCLOSURE_LIB_RELEASE="0.0-20211011-0726fdeb"
TREADER_RELEASE="1.3.6"
TEST_CHECK_RELEASE="1.1.1"
Expand Down Expand Up @@ -41,20 +39,6 @@ cp core.specs.alpha-$CORE_SPECS_ALPHA_RELEASE.jar lib/core.specs.alpha-$CORE_SPE
echo "Cleaning up core.specs.alpha..."
rm core.specs.alpha-$CORE_SPECS_ALPHA_RELEASE.jar

echo "Fetching data.json..."
curl --retry 3 -O -s https://repo1.maven.org/maven2/org/clojure/data.json/$DJSON_RELEASE/data.json-$DJSON_RELEASE.jar || { echo "Download failed."; exit 1; }
echo "Copying data.json-$DJSON_RELEASE.jar to lib/data.json-$DJSON_RELEASE.jar..."
cp data.json-$DJSON_RELEASE.jar lib/data.json-$DJSON_RELEASE.jar
echo "Cleaning up data.json..."
rm data.json-$DJSON_RELEASE.jar

echo "Fetching transit-clj..."
curl --retry 3 -O -s https://repo1.maven.org/maven2/com/cognitect/transit-clj/$TRANSIT_RELEASE/transit-clj-$TRANSIT_RELEASE.jar || { echo "Download failed."; exit 1; }
echo "Copying transit-clj-$TRANSIT_RELEASE.jar to lib/transit-clj-$TRANSIT_RELEASE.jar..."
cp transit-clj-$TRANSIT_RELEASE.jar lib/transit-clj-$TRANSIT_RELEASE.jar
echo "Cleaning up transit-clj..."
rm transit-clj-$TRANSIT_RELEASE.jar

echo "Fetching Google Closure library..."
mkdir -p closure/library
cd closure/library
Expand Down
42 changes: 42 additions & 0 deletions script/vendorize_deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -e

mkdir -p src/main/clojure/cljs/vendor
cd src/main/clojure/cljs

DJSON_RELEASE="2.4.0"
TRANSIT_RELEASE="1.0.329"
TREADER_RELEASE="1.3.6"

rm -rf data.json
git clone -b "v$DJSON_RELEASE" --depth 1 [email protected]:clojure/data.json.git
mkdir -p vendor/clojure/data
mv data.json/src/main/clojure/clojure/data/json.clj vendor/clojure/data/
rm -rf data.json
DATA_JSON_FILE=`mktemp /tmp/json.clj.XXXXXXXXXXX`
sed -e 's/clojure.data.json/cljs.vendor.clojure.data.json/' vendor/clojure/data/json.clj > $DATA_JSON_FILE
mv $DATA_JSON_FILE vendor/clojure/data/json.clj

rm -rf transit-clj
git clone -b "v$TRANSIT_RELEASE" --depth 1 [email protected]:cognitect/transit-clj.git
mkdir -p vendor/cognitect
mv transit-clj/src/cognitect/transit.clj vendor/cognitect/
rm -rf transit-clj
TRANSIT_FILE=`mktemp /tmp/transit.clj.XXXXXXXXXXX`
sed -e 's/ns cognitect.transit/ns cljs.vendor.cognitect.transit/' vendor/cognitect/transit.clj > $TRANSIT_FILE
mv $TRANSIT_FILE vendor/cognitect/transit.clj
TRANSIT_FILE=`mktemp /tmp/transit.clj.XXXXXXXXXXX`
sed -e 's/cognitect.transit.WithMeta/cljs.vendor.cognitect.transit.WithMeta/' vendor/cognitect/transit.clj > $TRANSIT_FILE
mv $TRANSIT_FILE vendor/cognitect/transit.clj

rm -rf tools.reader
rm -rf vendor/clojure/tools
git clone -b "v$TREADER_RELEASE" --depth 1 [email protected]:clojure/tools.reader.git
mkdir -p vendor/clojure/tools
mv tools.reader/src/main/clojure/clojure/tools/* vendor/clojure/tools/
rm -rf tools.reader

echo "rewriting tool.reader namespaces"
find vendor/clojure/tools -name '*.clj' -print0 | xargs -0 sed -iBAK 's/clojure.tools/cljs.vendor.clojure.tools/g'
find vendor/clojure/tools -name '*BAK' -delete
2 changes: 1 addition & 1 deletion src/main/cljs/cljs/stacktrace.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ goog.events.getProxy/f<@http://localhost:9000/out/goog/events/events.js:276:16"

(comment
(require '[cljs.closure :as cljsc]
'[clojure.data.json :as json]
'[cljs.vendor.clojure.data.json :as json]
'[cljs.source-map :as sm]
'[clojure.pprint :as pp])

Expand Down
16 changes: 8 additions & 8 deletions src/main/clojure/cljs/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.string :as string]
[clojure.tools.reader :as reader]
[clojure.tools.reader.reader-types :as readers])
[cljs.vendor.clojure.tools.reader :as reader]
[cljs.vendor.clojure.tools.reader.reader-types :as readers])
:cljs (:require [cljs.analyzer.impl :as impl]
[cljs.analyzer.impl.namespaces :as nses]
[cljs.analyzer.passes.and-or :as and-or]
Expand Down Expand Up @@ -77,8 +77,8 @@
#?(:clj
(def transit-read-opts
(try
(require '[cognitect.transit])
(when-some [ns (find-ns 'cognitect.transit)]
(require '[cljs.vendor.cognitect.transit])
(when-some [ns (find-ns 'cljs.vendor.cognitect.transit)]
(let [read-handler @(ns-resolve ns 'read-handler)
read-handler-map @(ns-resolve ns 'read-handler-map)]
{:handlers
Expand All @@ -91,8 +91,8 @@
#?(:clj
(def transit-write-opts
(try
(require '[cognitect.transit])
(when-some [ns (find-ns 'cognitect.transit)]
(require '[cljs.vendor.cognitect.transit])
(when-some [ns (find-ns 'cljs.vendor.cognitect.transit)]
(let [write-handler @(ns-resolve ns 'write-handler)
write-handler-map @(ns-resolve ns 'write-handler-map)]
{:handlers
Expand All @@ -112,8 +112,8 @@
(def transit
(delay
(try
(require '[cognitect.transit])
(when-some [ns (find-ns 'cognitect.transit)]
(require '[cljs.vendor.cognitect.transit])
(when-some [ns (find-ns 'cljs.vendor.cognitect.transit)]
{:writer @(ns-resolve ns 'writer)
:reader @(ns-resolve ns 'reader)
:write @(ns-resolve ns 'write)
Expand Down
4 changes: 1 addition & 3 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
[clojure.reflect]
[clojure.set :as set]
[clojure.string :as string]
[clojure.data.json :as json]
[clojure.tools.reader :as reader]
[clojure.tools.reader.reader-types :as readers]
[cljs.vendor.clojure.data.json :as json]
[cljs.module-graph :as module-graph])
(:import [java.lang ProcessBuilder]
[java.io
Expand Down
4 changes: 2 additions & 2 deletions src/main/clojure/cljs/compiler.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
[cljs.source-map :as sm]
[cljs.tagged-literals :as tags]
[cljs.util :as util]
[clojure.data.json :as json]
[cljs.vendor.clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.string :as string]
[clojure.tools.reader :as reader])
[cljs.vendor.clojure.tools.reader :as reader])
:cljs (:require [cljs.analyzer :as ana]
[cljs.analyzer.impl :as ana.impl]
[cljs.env :as env]
Expand Down
6 changes: 3 additions & 3 deletions src/main/clojure/cljs/core/macros.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(ns cljs.core.macros
(:refer-clojure :exclude [alias])
(:require [clojure.java.io :as io]
[clojure.tools.reader :as reader]
[clojure.tools.reader.reader-types :as readers]
[cljs.vendor.clojure.tools.reader :as reader]
[cljs.vendor.clojure.tools.reader.reader-types :as readers]
[cljs.env :as env]
[cljs.analyzer :as ana]
[cljs.repl :refer [source]])
Expand Down Expand Up @@ -40,4 +40,4 @@
(defmacro alias [[_ ns] [_ alias]]
(swap! env/*compiler* assoc-in
[::namespaces (.getName *ns*) :requires alias] ns)
nil)
nil)
4 changes: 2 additions & 2 deletions src/main/clojure/cljs/core/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

(ns cljs.core.server
(:refer-clojure :exclude [with-bindings resolve-fn prepl io-prepl])
(:require [clojure.tools.reader.reader-types :as readers]
[clojure.tools.reader :as reader]
(:require [cljs.vendor.clojure.tools.reader.reader-types :as readers]
[cljs.vendor.clojure.tools.reader :as reader]
[cljs.env :as env]
[cljs.closure :as closure]
[cljs.analyzer :as ana]
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/cljs/js_deps.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

(ns cljs.js-deps
(:require [cljs.util :as util :refer [distinct-by]]
[clojure.data.json :as json]
[cljs.vendor.clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.string :as string])
(:import [java.io File]
Expand Down
6 changes: 3 additions & 3 deletions src/main/clojure/cljs/repl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
(:require [clojure.java.io :as io]
[clojure.string :as string]
[clojure.set :as set]
[clojure.data.json :as json]
[clojure.tools.reader :as reader]
[clojure.tools.reader.reader-types :as readers]
[cljs.vendor.clojure.data.json :as json]
[cljs.vendor.clojure.tools.reader :as reader]
[cljs.vendor.clojure.tools.reader.reader-types :as readers]
[cljs.tagged-literals :as tags]
[clojure.edn :as edn]
[cljs.util :as util]
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/cljs/repl/browser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[clojure.java.browse :as browse]
[clojure.string :as string]
[clojure.edn :as edn]
[clojure.data.json :as json]
[cljs.vendor.clojure.data.json :as json]
[cljs.util :as util]
[cljs.closure :as cljsc]
[cljs.repl :as repl]
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/cljs/repl/node.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[cljs.repl.bootstrap :as bootstrap]
[cljs.cli :as cli]
[cljs.closure :as closure]
[clojure.data.json :as json])
[cljs.vendor.clojure.data.json :as json])
(:import [java.net Socket]
[java.lang StringBuilder]
[java.io File BufferedReader BufferedWriter IOException]
Expand Down
8 changes: 4 additions & 4 deletions src/main/clojure/cljs/source_map.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(ns cljs.source-map
(:require [clojure.java.io :as io]
[clojure.string :as string]
[clojure.data.json :as json]
[cljs.vendor.clojure.data.json :as json]
[clojure.set :as set]
[cljs.source-map.base64-vlq :as base64-vlq]))

Expand Down Expand Up @@ -104,7 +104,7 @@
(sorted-map)))))

(defn decode-reverse
"Convert a v3 source map JSON object into a nested sorted map
"Convert a v3 source map JSON object into a nested sorted map
organized as file, line, and column. Note this source map
maps from *original* source location to generated source location."
([source-map]
Expand Down Expand Up @@ -345,11 +345,11 @@

(comment
;; INSTRUCTIONS:

;; switch into samples/hello
;; run repl to start clojure
;; build with

(require '[cljs.closure :as cljsc])
(cljsc/build "src"
{:optimizations :simple
Expand Down
Loading