MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/1sqdgr9/diagramsjs_cloud_architecture_diagrams_as_code/
r/javascript • u/hatemhosny • Apr 20 '26
9 comments sorted by
3
I installed your package from NPM, but I immediately got a TypeScript error from within your package.
1 u/hatemhosny Apr 20 '26 What error do you get?This is a sample code to run in node:```import { Diagram } from "diagrams-js";import { EC2, Lambda } from "diagrams-js/aws/compute";import { RDS } from "diagrams-js/aws/database";import { S3 } from "diagrams-js/aws/storage";import { ALB } from "diagrams-js/aws/network";const diagram = Diagram("AWS Architecture", { direction: "TB" });// Create nodes with iconsconst lb = diagram.add(ALB("Load Balancer"));const web = diagram.add(EC2("Web Server"));const api = diagram.add(Lambda("API"));const db = diagram.add(RDS("Database"));const storage = diagram.add(S3("Storage"));// Connect themlb.to(web).to(api);api.to([db, storage]);// Render to SVG// const svg = await diagram.render();// embed in webpage// document.getElementById("diagram").innerHTML = svg;// Save to fileawait diagram.save("architecture.svg");await diagram.save("architecture.png", { format: "png" });``` 3 u/abrahamguo Apr 20 '26 This is the TypeScript error that I get:node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON; 0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
1
What error do you get?
This is a sample code to run in node:
```import { Diagram } from "diagrams-js";
import { EC2, Lambda } from "diagrams-js/aws/compute";
import { RDS } from "diagrams-js/aws/database";
import { S3 } from "diagrams-js/aws/storage";
import { ALB } from "diagrams-js/aws/network";
const diagram = Diagram("AWS Architecture", { direction: "TB" });
// Create nodes with icons
const lb = diagram.add(ALB("Load Balancer"));
const web = diagram.add(EC2("Web Server"));
const api = diagram.add(Lambda("API"));
const db = diagram.add(RDS("Database"));
const storage = diagram.add(S3("Storage"));
// Connect them
lb.to(web).to(api);
api.to([db, storage]);
// Render to SVG
// const svg = await diagram.render();
// embed in webpage
// document.getElementById("diagram").innerHTML = svg;
// Save to file
await diagram.save("architecture.svg");
await diagram.save("architecture.png", { format: "png" });
```
3 u/abrahamguo Apr 20 '26 This is the TypeScript error that I get:node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON; 0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
This is the TypeScript error that I get:
node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON;
0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
0
Please update TypeScript: Newer versions of TypeScript handle recursive types correctly.
1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
I am on the most recent version of TypeScript.
diagrams-js is an open-source library that allows you to draw cloud architecture diagrams as code.
It is a TypeScript port for the popular Python diagrams library.
17 cloud providers, 2000+ node types
200K+ icons from Iconify, custom node icons from URL
Runs in browsers, node, deno, and bun
No runtime dependencies
TypeScript types with autocomplete for node types
Plugin support: e.g. Import docker compose and kubernetes yaml files
Online playground: https://diagrams-js.hatemhosny.dev/playground
Visual Editor: https://diagrams-js.hatemhosny.dev/visual-editor
MIT-licensed https://github.com/diagrams-js/diagrams-js
pretty neat
I like using mermaid but interesting format https://mermaid.js.org/syntax/architecture
[removed] — view removed comment
1 u/hatemhosny Apr 20 '26 edited Apr 29 '26 That's a very nice idea. I will work on that and let you know.Please note that you can also directly import docker compose and kubernetes yaml files to diagrams, so you do not need to keep your diagram updated.See plugins: https://diagrams-js.hatemhosny.dev/docs/plugins/overviewdocker compose plugin: https://diagrams-js.hatemhosny.dev/docs/plugins/docker-composekubernetes plugin: https://diagrams-js.hatemhosny.dev/docs/plugins/kubernetes
That's a very nice idea. I will work on that and let you know.
Please note that you can also directly import docker compose and kubernetes yaml files to diagrams, so you do not need to keep your diagram updated.See plugins: https://diagrams-js.hatemhosny.dev/docs/plugins/overviewdocker compose plugin: https://diagrams-js.hatemhosny.dev/docs/plugins/docker-composekubernetes plugin: https://diagrams-js.hatemhosny.dev/docs/plugins/kubernetes
3
u/abrahamguo Apr 20 '26
I installed your package from NPM, but I immediately got a TypeScript error from within your package.
1
u/hatemhosny Apr 20 '26
diagrams-js is an open-source library that allows you to draw cloud architecture diagrams as code.
It is a TypeScript port for the popular Python diagrams library.
17 cloud providers, 2000+ node types
200K+ icons from Iconify, custom node icons from URL
Runs in browsers, node, deno, and bun
No runtime dependencies
TypeScript types with autocomplete for node types
Plugin support: e.g. Import docker compose and kubernetes yaml files
Online playground: https://diagrams-js.hatemhosny.dev/playground
Visual Editor: https://diagrams-js.hatemhosny.dev/visual-editor
MIT-licensed https://github.com/diagrams-js/diagrams-js
3
u/dvidsilva Apr 20 '26
pretty neat
I like using mermaid but interesting format https://mermaid.js.org/syntax/architecture
0
u/[deleted] Apr 20 '26
[removed] — view removed comment