mmaietta / bytenode-webpack-plugin

Compile JavaScript into bytecode using bytenode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@herberttn/bytenode-webpack-plugin

ci coveralls npm license

Compile JavaScript into bytecode using bytenode.
Inspired by bytenode-webpack-plugin.

Install

npm install --save @herberttn/bytenode-webpack-plugin

Supported versions

  • node v14+ (this plugin is published in ES2020 CommonJS syntax at the moment)
  • webpack v5.x

Supported features

  • electron-forge
    • ✔️ Default configuration
  • webpack
    • ✔️ entry as a string (e.g., entry: 'src/index.js')
    • ✔️ entry as an array (e.g., entry: ['src/index.js'])
    • ✔️ entry as an object (e.g., entry: { main: 'src/index.js' })
    • ✔️ entry middlewares (e.g., entry: ['src/index.js', 'webpack-hot-middleware/client'])
    • entry.*.filename (e.g., entry: { main: { filename: 'index.js' } })
    • ✔️ Dynamic output.filename (e.g., output: { filename: '[name].js' })
    • Static output.filename (e.g., output: { filename: 'index.js' })

Usage

import { BytenodeWebpackPlugin } from '@herberttn/bytenode-webpack-plugin';

// webpack options
module.exports = {
  // ...

  plugins: [
    // using all defaults
    new BytenodeWebpackPlugin(),

    // overriding an option
    new BytenodeWebpackPlugin({
      compileForElectron: true,
    }),
  ],
};

Options

interface Options {
  compileAsModule: boolean;    // wraps the code in a node module
  compileForElectron: boolean; // compiles for electron instead of plain node
  debugLifecycle: boolean;     // enables webpack hooks lifecycle logs
  keepSource: boolean;         // emits the original source files along with the compiled ones
  preventSourceMaps: boolean;  // prevents source maps from being generated
}

Default options

new BytenodeWebpackPlugin({
  compileAsModule: true,
  compileForElectron: false,
  debugLifecycle: false,
  keepSource: false,
  preventSourceMaps: true,
})

Contributors

herberttn
herberttn
jjeff
Jeff Robbins

About

Compile JavaScript into bytecode using bytenode

License:MIT License


Languages

Language:TypeScript 85.8%Language:JavaScript 14.2%