Skip to content

Commit 0f2ba7b

Browse files
committed
published to npm
1 parent ac4abd4 commit 0f2ba7b

24 files changed

+1883
-258
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: npm install, build, and test
2929
run: |
3030
npm install
31-
npm run build-dev --
31+
npm run build --
3232
rm -rf node_modules/
3333
- name: Upload artifact for deployment job
3434
uses: actions/upload-artifact@v4

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
.git/
4+
.npmignore

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ Node Flow is a javascript library that enables developers to build node based to
2020

2121
Download the latest build [here](https://raw.githubusercontent.com/EliCDavis/node-flow/gh-pages/dist/web/NodeFlow.js).
2222

23+
## Building
24+
25+
If you want to build the library yourself, you can run
26+
27+
```bash
28+
npm run package
29+
```
30+
2331
## API
2432

2533
### Graph API
@@ -148,5 +156,4 @@ node.addOutput({ name: "sum", type: "float32" })
148156
Just run
149157

150158
```bash
151-
npm run watch-dev
152-
```
159+
```npm run watch

dev.tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"outFile": "./dist/js/NodeFlow.js",
5+
"sourceMap": true,
6+
"strict": true,
7+
"module": "AMD",
8+
"target": "ESNext"
9+
},
10+
11+
"include": [
12+
"src/index.ts"
13+
],
14+
15+
"exclude": [
16+
"node_modules"
17+
]
18+
}

esbuild.dev.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

esbuild.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { build, serve, BuildOptions } from 'esbuild';
2+
3+
const buildOptsWeb: BuildOptions = {
4+
entryPoints: ['./src/index.ts'],
5+
outfile: './dist/web/NodeFlow.js',
6+
platform: 'browser',
7+
target: ['esNext'],
8+
// format: 'cjs',
9+
bundle: true,
10+
sourcemap: true,
11+
minify: true,
12+
treeShaking: true,
13+
};
14+
15+
const serveOpts = { servedir: './' };
16+
const flags = process.argv.filter(arg => /--[^=].*/.test(arg));
17+
const enableWatch = (flags.includes('--watch'));
18+
19+
if (enableWatch) {
20+
buildOptsWeb.watch = {
21+
onRebuild: (error, result) => {
22+
if (error) { console.error('watch web development build failed:', error); }
23+
else { console.log('watch web development build succeeded:', result); }
24+
}
25+
};
26+
27+
serve(serveOpts, {}).then((result) => {
28+
console.log(`serving extension from "${serveOpts.servedir}" at "http://${result.host}:${result.port}"`);
29+
});
30+
}
31+
32+
build(buildOptsWeb).then(() => enableWatch ? console.log("watching web development build...") : null);

index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@
2727
}
2828
</style>
2929

30-
<script src="./dist/web/NodeFlow.js"></script>
30+
<script src="./dist/index.mjs" type="module"></script>
3131
</head>
3232

3333
<body>
3434
<canvas id="canvas"></canvas>
35-
<script>
35+
<script type="module">
36+
import { Theme, FlowNode, NodeFlowGraph, FlowNote } from "./dist/index.mjs";
37+
3638
const canvas = document.getElementById("canvas");
37-
NodeFlowTheme.FontFamily = "Source Code Pro";
39+
Theme.FontFamily = "Source Code Pro";
3840

3941
const node3 = new FlowNode({
4042
title: "Node 3",

0 commit comments

Comments
 (0)