Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Protect your source by shimming your entrypoints with bytenode.

Notifications You must be signed in to change notification settings

sbrow/bytenode-webpack-plugin

Repository files navigation

Bytenode Webpack Plugin

This plugin makes it easy to protect your source code with Bytenode by replacing your entry point with a script that can import bytecode.

In short, it turns this:

// index.js
function hello() {
  console.log("Hello, world!");
}

module.exports = hello;

Into this:

// index.js
require("bytenode");
require("./main");
// main.js
function hello() {
  console.log("Hello, world!");
}

module.exports = hello;

Setup

Install the plugin:

$ npm install bytenode-webpack-plugin

Then simply add BytenodePlugin to your configuration, passing the name of the entrypoint to shim and the new file name to the entries field.

Example

To shim entrypoint "index.js" as "main.js", here's a basic config file:

module.exports = {
  mode: "production",
  entry: {
    index: "src/index.js",
  },
  output: {
    dir: "app",
    filename: "[name].js",
  },
  plugins: [new BytenodePlugin({ entries: { index: "main" } })],
};

You can then compile main.js to bytecode using the bytenode cli.

$ bytenode app/main.js && rm ./app/main.js