1.0.4 • Published 8 months ago

esmbytecode v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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

sage: esmbytecode [options] <input> <output>

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

import { compileToJSC } from 'esmbytecode';

await compileToJSC({
    input: "./src/index.ts",
    output: "./dist/lib.jsc",
    compress: true
})

Import compiled module in your project

import { importJSC } from 'esmbytecode';
const { default: lib, something } = await importJSC("./lib.jsc");

Credit

Credit to bytenode for the idea and the implementation of the bytecode usage.

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

9 months ago