Skip to content

Commit 8b3571d

Browse files
committed
Initialize include-webpack
0 parents  commit 8b3571d

File tree

10 files changed

+1064
-0
lines changed

10 files changed

+1064
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
calcit.cirru -diff linguist-generated
3+
yarn.lock -diff linguist-generated

.github/workflows/tests.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
15+
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
16+
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
17+
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
18+
19+
- name: add cr
20+
run: |
21+
mkdir -p $GITHUB_WORKSPACE/bin
22+
wget -O $GITHUB_WORKSPACE/bin/cr http://repo.calcit-lang.org/binaries/linux/cr
23+
chmod +x $GITHUB_WORKSPACE/bin/cr
24+
echo "::add-path::$GITHUB_WORKSPACE/bin"
25+
26+
- name: "prepare modules"
27+
run: mkdir -p ~/.config/calcit/modules/ && cd ~/.config/calcit/modules/ && echo 'no deps'
28+
29+
- name: "test"
30+
run: mode=ci cr -1
31+
32+
- run: mode=ci cr --emit-js -1 && yarn && yarn webpack && node ./js-out/bundle.js

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.compact-inc.cirru
3+
.calcit-error.cirru
4+
5+
js-out/
6+
node_modules
7+
8+
example/

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Calcit Workflow
3+
----
4+
5+
> running in both Calcit and Calcit-js, with hot code reload.
6+
7+
### Usages
8+
9+
Install [calcit-runner](https://github.com/calcit-lang/calcit_runner.rs) to run demo:
10+
11+
```bash
12+
cr -1 # run once
13+
14+
cr # run and watch
15+
```
16+
17+
For JavaScript:
18+
19+
```bash
20+
cr --emit-js -1 # emit-js once
21+
yarn webpack
22+
node js-out/bundle.js # run code
23+
```
24+
25+
watch reload js program:
26+
27+
```bash
28+
cr --emit-js
29+
30+
# and watch and build with Webpack
31+
hot=true webpack --watch
32+
33+
# run with hot reload
34+
node js-out/bundle.js
35+
```
36+
37+
### Workflow
38+
39+
https://github.com/calcit-lang/calcit-workflow
40+
41+
### License
42+
43+
MIT

calcit.cirru

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compact.cirru

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
{} (:package |app)
3+
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!)
4+
:modules $ []
5+
:version nil
6+
:files $ {}
7+
|app.main $ {}
8+
:ns $ quote (ns app.main)
9+
:defs $ {}
10+
|main! $ quote
11+
defn main! ()
12+
assert= 2 $ + 1 1
13+
echo "\"Started."
14+
|reload! $ quote
15+
defn reload! () $ echo "\"Reloaded."
16+
|on-error $ quote
17+
defn on-error (message) (; draw-error-message message)
18+
:proc $ quote ()
19+
:configs $ {} (:extension nil)

main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { main_$x_, reload_$x_ } from "./js-out/app.main.js"
2+
3+
main_$x_()
4+
5+
if (module.hot) {
6+
module.hot.accept('./js-out/app.main.js', (main) => {
7+
reload_$x_()
8+
})
9+
}

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"dependencies": {
3+
"@calcit/procs": "^0.4.1"
4+
},
5+
"scripts": {
6+
"watch-server": "cr --emit-js",
7+
"build-server": "yarn webpack && node js-out/bundle.js",
8+
"dev-server": "hot=true webpack --watch"
9+
},
10+
"devDependencies": {
11+
"webpack": "^5.38.1",
12+
"webpack-cli": "^4.7.2"
13+
},
14+
"version": "0.0.7"
15+
}

webpack.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let path = require("path");
2+
let webpack = require('webpack');
3+
4+
let entry = process.env.entry ?? './main.js';
5+
console.log("Entry:", entry);
6+
7+
let hot = process.env.hot === 'true' ? true : false;
8+
console.log("Hot:", hot)
9+
10+
module.exports = {
11+
entry: hot ? [
12+
'webpack/hot/poll?1000',
13+
entry
14+
] : entry,
15+
target: 'node',
16+
mode: "development",
17+
devtool: "hidden-source-map",
18+
externals: {
19+
ws: "commonjs ws",
20+
randomcolor: "commonjs randomcolor",
21+
shortid: "commonjs shortid",
22+
md5: "commonjs md5",
23+
},
24+
output: {
25+
path: path.resolve(__dirname, "js-out/"),
26+
filename: "bundle.js",
27+
},
28+
plugins: [
29+
hot ? new webpack.HotModuleReplacementPlugin(): null
30+
].filter(x => x != null)
31+
};

0 commit comments

Comments
 (0)