https://github.com/ido-pluto/esmbytecode
Compile JS/TS ESM to Bytecode
https://github.com/ido-pluto/esmbytecode
Last synced: 4 months ago
JSON representation
Compile JS/TS ESM to Bytecode
- Host: GitHub
- URL: https://github.com/ido-pluto/esmbytecode
- Owner: ido-pluto
- Created: 2024-10-10T22:42:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-13T10:33:50.000Z (over 1 year ago)
- Last Synced: 2025-10-06T17:55:13.487Z (9 months ago)
- Language: TypeScript
- Size: 401 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compile ESM into one bytecode
Compile the ESM project into one bytecode file (including your dependencies).
Useful when you want to hide your source code, or when you want to distribute your project as a few files.
- Compile
- Compression
- Bundle
- Support some .node addons (node-gyp-imports are not supported)
- TypeScript support
## Compile
```bash
sage: esmbytecode [options]
Compile and bundle your ESM project into a single file
Arguments:
input File to start the bundling process from
output Output file
Options:
-c --compress Compress the output file
-V, --version output the version number
-h, --help display help for command
```
## Important Notes
- It will work only with the specific node version it was compiled with (works with node.js only!).
- It will not work with node-gyp imports.
- It will not work with dynamic imports that are not statically analyzable.
### Compile your project with node API
```js
import { compileToJSC } from 'esmbytecode';
await compileToJSC({
input: "./src/index.ts",
output: "./dist/lib.jsc",
compress: true
})
```
### Import compiled module in your project
```js
import { importJSC } from 'esmbytecode';
const { default: lib, something } = await importJSC("./lib.jsc");
```
### Credit
Credit to [bytenode](https://www.npmjs.com/package/bytenode) for the idea and the implementation of the bytecode usage.