squint-cljs 0.0.0-alpha.42 → 0.0.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -18
- package/lib/cli.js +627 -627
- package/lib/cljs_core.js +4 -4
- package/lib/compiler.js +433 -434
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Squint
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
JavaScript compiler.
|
|
3
|
+
Squint is an experimental ClojureScript syntax to JavaScript compiler.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Squint is not intended as a replacement for ClojureScript but as a tool to
|
|
7
6
|
target JS for anything you would not use ClojureScript for, for whatever reason:
|
|
8
7
|
performance, bundle size, ease of interop, etc.
|
|
9
8
|
|
|
@@ -11,17 +10,20 @@ performance, bundle size, ease of interop, etc.
|
|
|
11
10
|
> breaking changes. It's fine to use it for non-critical projects but don't use
|
|
12
11
|
> it in production yet.
|
|
13
12
|
|
|
13
|
+
Squint was previously called ClavaScript and the name may appear in some places
|
|
14
|
+
in this README. Please file an issue or PR if you spot one.
|
|
15
|
+
|
|
14
16
|
## Quickstart
|
|
15
17
|
|
|
16
|
-
Although it's early days, you're welcome to try out `
|
|
18
|
+
Although it's early days, you're welcome to try out `squint` and submit issues.
|
|
17
19
|
|
|
18
20
|
``` shell
|
|
19
|
-
$ mkdir
|
|
21
|
+
$ mkdir squint-test && cd squint-test
|
|
20
22
|
$ npm init -y
|
|
21
|
-
$ npm install
|
|
23
|
+
$ npm install squint-cljs@latest
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
Create a `.cljs`
|
|
26
|
+
Create a `.cljs` file, e.g. `example.cljs`:
|
|
25
27
|
|
|
26
28
|
``` clojure
|
|
27
29
|
(ns example
|
|
@@ -39,16 +41,16 @@ Create a `.cljs` or `.clvs` file, e.g. `example.cljs`:
|
|
|
39
41
|
Then compile and run (`run` does both):
|
|
40
42
|
|
|
41
43
|
```
|
|
42
|
-
$ npx
|
|
44
|
+
$ npx squint run example.cljs
|
|
43
45
|
true
|
|
44
46
|
6
|
|
45
47
|
```
|
|
46
48
|
|
|
47
|
-
Run `npx
|
|
49
|
+
Run `npx squint --help` to see all command line options.
|
|
48
50
|
|
|
49
|
-
## Why
|
|
51
|
+
## Why Squint
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
Squint lets you write CLJS syntax but emits small JS output, while still having
|
|
52
54
|
parts of the CLJS standard library available (ported to mutable data structures,
|
|
53
55
|
so with caveats). This may work especially well for projects e.g. that you'd
|
|
54
56
|
like to deploy on CloudFlare workers, node scripts, Github actions, etc. that
|
|
@@ -56,8 +58,8 @@ need the extra performance, startup time and/or small bundle size.
|
|
|
56
58
|
|
|
57
59
|
## Differences with ClojureScript
|
|
58
60
|
|
|
59
|
-
-
|
|
60
|
-
- There is no CLJS standard library. The `"
|
|
61
|
+
- Squint does not protect you in any way from the pitfalls of JS with regards to truthiness, mutability and equality
|
|
62
|
+
- There is no CLJS standard library. The `"squint-cljs/core.js"` module has similar JS equivalents
|
|
61
63
|
- Keywords are translated into strings
|
|
62
64
|
- Maps, sequences and vectors are represented as mutable objects and arrays
|
|
63
65
|
- Most functions return arrays and objects, not custom data structures
|
|
@@ -70,7 +72,7 @@ need the extra performance, startup time and/or small bundle size.
|
|
|
70
72
|
|
|
71
73
|
### Seqs
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
Squint does not implement Clojure seqs. Instead it uses the JavaScript
|
|
74
76
|
[iteration
|
|
75
77
|
protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
|
|
76
78
|
to work with collections. What this means in practice is the following:
|
|
@@ -91,7 +93,7 @@ the results.
|
|
|
91
93
|
|
|
92
94
|
With respect to memory usage:
|
|
93
95
|
|
|
94
|
-
- Lazy seqs in
|
|
96
|
+
- Lazy seqs in squint are built on generators. They do not cache their results, so every time they are consumed, they are re-calculated from scratch.
|
|
95
97
|
- Lazy seq function results hold on to their input, so if the input contains resources that should be garbage collected, it is recommended to limit their scope and convert their results to arrays when leaving the scope:
|
|
96
98
|
|
|
97
99
|
|
|
@@ -153,7 +155,7 @@ See an example of an application using JSX [here](https://clavascript.github.io/
|
|
|
153
155
|
|
|
154
156
|
## Async/await
|
|
155
157
|
|
|
156
|
-
|
|
158
|
+
squint supports `async/await`:
|
|
157
159
|
|
|
158
160
|
``` clojure
|
|
159
161
|
(defn ^:async foo [] (js/Promise.resolve 10))
|
|
@@ -182,4 +184,4 @@ The core team consists of:
|
|
|
182
184
|
License
|
|
183
185
|
=======
|
|
184
186
|
|
|
185
|
-
|
|
187
|
+
Squint is licensed under the EPL, the same as Clojure core and [Scriptjure](https://github.com/arohner/scriptjure). See epl-v10.html in the root directory for more information.
|