bytenode-webpack-plugin
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -0,6 +1,10 @@ | ||
const Module = require('module') | ||
const bytenode = require('bytenode') | ||
require('v8').setFlagsFromString('--no-lazy') | ||
class BytenodeWebpackPlugin { | ||
constructor (options = {}) { | ||
this.options = Object.assign({ | ||
compileAsModule: true, | ||
keepSource: false | ||
@@ -17,3 +21,6 @@ }, options) | ||
// Compile them to v8 bytecode and emit them as .jsc files | ||
const source = compilation.assets[filename]._value | ||
let source = compilation.assets[filename]._value | ||
if (this.options.compileAsModule) { | ||
source = Module.wrap(source) | ||
} | ||
const bytecode = bytenode.compileCode(source) | ||
@@ -20,0 +27,0 @@ compilation.assets[filename.replace('.js', '.jsc')] = { |
{ | ||
"name": "bytenode-webpack-plugin", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Compiles JS files to V8 bytecode.", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
}, | ||
"author": "Aamir Syed <aamir@shardus.com>", | ||
"author": "Aamir Syed <aamir@shardus.com>", | ||
"license": "ISC", | ||
@@ -16,0 +16,0 @@ "bugs": { |
@@ -37,7 +37,8 @@ # Bytenode Webpack Plugin | ||
| Name | Type | Default | Description | | ||
|------------------|-----------|---------|----------------------------------------| | ||
| **`keepSource`** | `boolean` | `false` | Keep JS source files in output or not. | | ||
| Name | Type | Default | Description | | ||
|-----------------------|-----------|---------|----------------------------------------------------------------| | ||
| **`compileAsModule`** | `boolean` | `true` | Allow the resulting `.jsc` file to be used as a module or not. | | ||
| **`keepSource`** | `boolean` | `false` | Keep JS source files in output or not. | | ||
Here's an example that shows how to output both `.js` and `.jsc` files: | ||
To use options: | ||
@@ -55,2 +56,3 @@ ```javascript | ||
new BytenodeWebpackPlugin({ | ||
compileAsModule: false, | ||
keepSource: true | ||
@@ -57,0 +59,0 @@ }) |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
3586
35
73
2