#how build project to one bin?

17 messages · Page 1 of 1 (latest)

mental lily
#

how build project to one bin? like i have api server and i want build to one file how?

primal scarab
#

there's almost zero reason to do this but you can look into yao-pkg or SEA

weary sedge
#

bun build or deno compile. Node.js' SEA only works for CommonJS input and the last time I checked still expects the source files to be on the file system.

vocal relic
#

More practically you might want to look into Dockerizing it instead, if you want an artifact to move around

mental lily
#

i have api server for project and i didnt want share source code yea i know 100% no way to secure

lean forum
#

Worrying about source code sharing is IMHO a waste of time. Instead put into contracts the protections instead.

#

Anyone who really wants to know what you're doing will find out if you let them have access to it. Especially JS and other interpreted languages.

tight sedge
#

SEA is the recommended way of building single binary Node.js apps. Sourceless bins are not supported by SEA at the moment but I'd be happy to implement it if the development is funded. Yao-pkg does support sourceless bins by relying on just the V8 code cache without sources but it's not 100% secure: https://swarm.ptsecurity.com/how-we-bypassed-bytenode-and-decompiled-node-js-bytecode-in-ghidra/. Note that the sourceless feature of yao-pkg on the latest versions of Node.js is blocked - https://github.com/yao-pkg/pkg/issues/87 which I was looking into earlier but I can't justify more time for that without the proper funding

primal scarab
#

SEA cannot be "the recommended way" when it is both experimental and lacking in features

#

the issue you linked also appears to be limited to cross-platform building?

weary sedge
#

There's also Bellard's QuickJS qjsc, QuickJS NG's qjs with built in compilation capability, Facebook's Static Hermes to compile JavaScript to a native executable, Bytecode Alliance's javy to compile JavaScript to WASM - with WASI support. And other ways to compile JavaScript to a standalone executable.

weary sedge
sudden sparrow
#

You can use esbuild to bundle your source into one big JS file (instead of shipping many small source files).
You can minimize/uglify the bundle to make it weigh less and also be less readable, using the same tool

#

There are also libraries that let you bundle that along with a NodeJS distributable into a single executable (.exe)
like: https://www.npmjs.com/package/pkg