swc-project / swc-project/swc-node
Question: how to make swc-node to use less memory
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 95
- Avg merge
- 14d 11h
- Merged PRs (30d)
- 1
Description
I use @swc-node to run TypeScript backend in production. because i don't like to add a build step to my workflow, on-the-fly transpilation just makes life easier
everything works fine, but the extra memory usage caused by swc is a downside to me.
to reproduce:
import { memoryUsage } from "node:process";
setInterval(() => {
console.log(memoryUsage());
}, 2000);
node main.js: rss: 45MB, heapTotal: 6MB, heapUsed: 6MB, external: 421KB, arrayBuffers: 18KB
deno main.ts: rss: 52MB, heapTotal: 11MB, heapUsed: 10MB, external: 76KB, arrayBuffers: 0
node -r @swc-node/register main.ts: rss: 102MB, heapTotal: 30MB, heapUsed: 23MB, external: 592KB, arrayBuffers: 57KB
There is a huge gap here. I was able to 60% reduce one of my project rss, just by compiling the source code before runtime.
I wonder is there anyway to consume less memory for production usage? maybe unload/free the swc compiler after a while during runtime.
I can work on a PR, but i have no idea to start
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported comparison with the provided Node, Deno, and node -r @swc-node/register main.ts commands. Trace the @swc-node/register entry point and measure whether compiler memory can be released during runtime; done should include a demonstrated production approach with lower memory usage or a documented explanation of the limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100