-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1ef68de
Showing
11 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: npm-publish | ||
run-name: NPM Publish | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
jobs: | ||
check-bats-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.17.1' | ||
- name: NPM Publish | ||
uses: JS-DevTools/[email protected] | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.clj-kondo | ||
.nrepl-port | ||
.cpcache | ||
.lsp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[tools] | ||
node = '18.17.1' | ||
clojure = "1.11.1.1403" | ||
java = "temurin-jre-17.0.8+7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: svelte-preprocess-cljs | ||
root: . | ||
windows: | ||
- VIM: | ||
layout: even-horizontal | ||
panes: | ||
- nvim | ||
- | ||
- GIT: ssh-agent zsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ClojureScript preprocessor for Svelte using Squint | ||
|
||
[Counter.svelte](example/src/lib/Counter.svelte) | ||
```svelte | ||
<script lang="cljs"> | ||
(def count 0) | ||
(defn increment [] | ||
(set! count (inc count))) | ||
</script> | ||
<button on:click={increment}> | ||
count is {count} | ||
</button> | ||
``` | ||
|
||
## Install | ||
|
||
```bash | ||
npm install -D svelte-preprocess-cljs | ||
``` | ||
|
||
add to `svelte.config.js` | ||
|
||
```js | ||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' | ||
import squint from "svelte-preprocess-squint"; | ||
|
||
export default { | ||
preprocess: [ | ||
squint(), | ||
vitePreprocess() | ||
], | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{:paths ["src"] | ||
:tasks | ||
{tmux (shell "tmuxinator local") | ||
shell (shell "nix-shell") | ||
lint (shell "clj-kondo --lang cljs --lint src") | ||
prettier (shell "npx prettier . --write") | ||
squint (shell "npx squint compile src/main.cljs") | ||
build {:depends [squint prettier]}}} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "svelte-preprocess-cljs", | ||
"version": "0.0.1", | ||
"description": "ClojureScript preprocessor for Svelte using Squint", | ||
"main": "src/main.mjs", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jruz/svelte-preprocess-cljs.git" | ||
}, | ||
"keywords": [ | ||
"clojurescript", | ||
"cljs", | ||
"squint", | ||
"squint-cljs", | ||
"svelte" | ||
], | ||
"author": "jruz", | ||
"license": "ISC", | ||
"dependencies": { | ||
"squint-cljs": "^0.1.16" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ pkgs ? import <nixpkgs> { } }: | ||
|
||
pkgs.mkShell { | ||
buildInputs = with pkgs;[ | ||
rtx | ||
clj-kondo | ||
babashka | ||
joker | ||
rlwrap | ||
]; | ||
shellHook = '' | ||
zsh | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns main | ||
(:require [squint-cljs.lib.compiler :as squint])) | ||
|
||
(defn script | ||
[opts] | ||
(let [content (:content opts) | ||
attributes (:attributes opts) | ||
lang (:lang attributes)] | ||
(when (= lang "cljs") | ||
(try | ||
{:code (squint/compile-string content)} | ||
(catch :default err | ||
(js/console.log err)))))) | ||
|
||
(defn -main | ||
[opts] | ||
{:name "svelte-preprocess-cljs" | ||
:script (script opts)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as squint_core from "squint-cljs/core.js"; | ||
import { compile_string } from "squint-cljs.lib.compiler"; | ||
var script = function (opts) { | ||
let content1 = squint_core.get(opts, "content"); | ||
let attributes2 = squint_core.get(opts, "attributes"); | ||
let lang3 = squint_core.get(attributes2, "lang"); | ||
if (lang3 === "cljs") { | ||
return (function () { | ||
try { | ||
return { code: compile_string(content1) }; | ||
} catch (err) { | ||
return console.log(err); | ||
} | ||
})(); | ||
} | ||
}; | ||
var _main = function (opts) { | ||
return { name: "svelte-plugin-cljs", script: script(opts) }; | ||
}; | ||
export { script, _main }; |