Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile backend Nodejs scripts via Vercel #195

Open
ceremcem opened this issue Jun 30, 2022 · 1 comment
Open

Compile backend Nodejs scripts via Vercel #195

ceremcem opened this issue Jun 30, 2022 · 1 comment

Comments

@ceremcem
Copy link
Contributor

Description:

Compile backend scripts via Vercel in order to improve Ram and CPU usage

https://github.com/vercel/ncc

@sourcevault
Copy link

ncc puts all the files in one folder.

[1] For livescript, if you are compiling into dist folder, I suggest you create a seperate bundle folder.

[2] since I use a package.yaml instead of a package.json I use yq to change the entry file for nodejs.

[3] and then after ncc ...., I go back to normal.

It's all there in my makefile as below :

ncc:
  yq w -i src/package.yaml bin.remotemon 'bundle/index.js'  # [2]
  lsc --no-header -cbo dist src
  lsc -cb test
  yaml2json -p src/package.yaml > package.json
  ncc --minify build ./dist/cmdline.js -o ./bundle # [1]
  yq w -i src/package.yaml bin.remotemon 'dist/cmdline.js' # [3]

I compared the timing with rust's exa program, it's x10 slower, but that is better than x60.

rust `exa`   | 0.02s | 1
nodejs + ncc | 0.2s  | 10x
nodejs       | 1.2s  | 60x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants