Socket
Socket
Sign inDemoInstall

rollup-plugin-obfuscator

Package Overview
Dependencies
107
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 1.0.0

14

dist/rollup-plugin-obfuscator.d.ts
import { Plugin } from 'rollup';
import { ObfuscationResult, ObfuscatorOptions } from 'javascript-obfuscator';
declare type FilterOptions = string | RegExp | (string | RegExp)[];
type FilterOptions = string | RegExp | (string | RegExp)[];
export interface RollupPluginObfuscatorOptions {
/**
* Global options, applied when rendering chunks. Pass `false` to disable.
* Set to `true` if you want to obfuscate the whole bundle, `false` to obfuscate each file separately.
* @default false
*/
globalOptions: ObfuscatorOptions | false;
global: boolean;
/**
* Per-file options, applied when transforming files, include/exclude works for this option. Pass `false` to disable.
* javascript-obfuscator options. Refer to documentation here https://github.com/javascript-obfuscator/javascript-obfuscator#javascript-obfuscator-options
* @default {}
*/
fileOptions: ObfuscatorOptions | false;
options: ObfuscatorOptions;
/**
* Files to include when applying per-file obfuscation.
* @default ['**\/*.js', '**\/*.ts']
*/

@@ -19,2 +22,3 @@ include: FilterOptions;

* Files to exclude when applying per-file obfuscation. The priority is higher than `include`.
* @default ['node_modules/**']
*/

@@ -21,0 +25,0 @@ exclude: FilterOptions;

@@ -17,4 +17,4 @@ "use strict";

var defaultOptions = {
globalOptions: {},
fileOptions: {},
global: false,
options: {},
include: ['**/*.js', '**/*.ts'],

@@ -29,6 +29,6 @@ exclude: ['node_modules/**'],

name: 'rollup-plugin-obfuscator',
transform: options.fileOptions === false ? undefined : function (code, id) {
transform: options.global ? undefined : function (code, id) {
if (!filter(id))
return null;
var obfuscationResult = options.obfuscate(code, __assign(__assign({}, options.fileOptions), { inputFileName: id, sourceMap: true }));
var obfuscationResult = options.obfuscate(code, __assign(__assign({}, options.options), { inputFileName: id, sourceMap: true }));
return {

@@ -39,5 +39,5 @@ code: obfuscationResult.getObfuscatedCode(),

},
renderChunk: options.globalOptions === false ? undefined : function (code, _a) {
renderChunk: !options.global ? undefined : function (code, _a) {
var fileName = _a.fileName;
var obfuscationResult = options.obfuscate(code, __assign(__assign({}, options.globalOptions), { inputFileName: fileName, sourceMap: true }));
var obfuscationResult = options.obfuscate(code, __assign(__assign({}, options.options), { inputFileName: fileName, sourceMap: true }));
return {

@@ -44,0 +44,0 @@ code: obfuscationResult.getObfuscatedCode(),

{
"name": "rollup-plugin-obfuscator",
"version": "0.2.2",
"version": "1.0.0",
"description": "The most powerful rollup plugin for javascript-obfuscator",
"keywords": [
"rollup-plugin",
"vite-plugin",
"obfuscator",
"javascript-obfuscator",
"obfuscate",
"obfuscation"
],
"main": "dist/rollup-plugin-obfuscator.js",

@@ -21,3 +29,3 @@ "types": "dist/rollup-plugin-obfuscator.d.ts",

"dependencies": {
"@rollup/pluginutils": "^4.2.1"
"@rollup/pluginutils": "^5.0.2"
},

@@ -30,5 +38,5 @@ "peerDependencies": {

"javascript-obfuscator": "^4.0.0",
"rollup": "^2.72.1",
"typescript": "^4.6.4"
"rollup": "^3.15.0",
"typescript": "^4.9.5"
}
}

@@ -17,15 +17,9 @@ # rollup-plugin-obfuscator

## Why?
## Why was this plugin made?
There is already [a plugin for this](https://github.com/javascript-obfuscator/rollup-plugin-javascript-obfuscator), but it's outdated and not powerful enough for me.
1. javascript-obfuscator is installed separately from the rollup plugin, so it will always be updatable
2. with this plugin, you can decide if you prefer to apply obfuscation to:
a. each file, to avoid obfuscating your open-source dependencies, which results in a **huge performance boost**
b. the whole bundle
With this plugin **you** install `javascript-obfuscator` separately from the plugin (as seen in the installation instructions above). This plugin is designed so `javascript-obfuscator` will always be updatable, independently from `rollup-plugin-obfuscator`.
Additionally, it's much more powerful because you can apply obfuscation settings:
- per file
- to the whole bundle
The point is that you can avoid obfuscating your open-source dependencies, which results in a **huge performance boost**.
## Usage

@@ -40,12 +34,7 @@

obfuscator({
fileOptions: {
options: {
// Your javascript-obfuscator options here
// Will be applied on each file separately. Set to `false` to disable
// Will be applied on each file separately.
// See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator
},
globalOptions: {
// Your javascript-obfuscator options here
// Will be applied on the whole bundle. Set to `false` to disable
// See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator
},
}),

@@ -58,16 +47,15 @@ ]

### `globalOptions`
### `global`
Type: `Object` | `false`<br/>
Default: `{}`
Type: `boolean`<br/>
Default: `false`
Options that will be passed to javascript-obfuscator when it processes each file. If you don't want each of your file to be processed individually, you can set this to `false`.
See allowed options [here](https://github.com/javascript-obfuscator/javascript-obfuscator).
Set to `true` if you want to obfuscate the whole bundle, `false` to obfuscate each file separately.
### `fileOptions`
### `options`
Type: `Object` | `false`<br/>
Type: `Object`<br/>
Default: `{}`
Options that will be passed to javascript-obfuscator when it processes the whole bundle. If you don't want to apply the obfuscation to the whole bundle, you can set this to `false`.
Options that will be passed to javascript-obfuscator.
See allowed options [here](https://github.com/javascript-obfuscator/javascript-obfuscator).

@@ -74,0 +62,0 @@

@@ -10,11 +10,14 @@ import { Plugin } from 'rollup';

/**
* Global options, applied when rendering chunks. Pass `false` to disable.
* Set to `true` if you want to obfuscate the whole bundle, `false` to obfuscate each file separately.
* @default false
*/
globalOptions: ObfuscatorOptions | false,
global: boolean,
/**
* Per-file options, applied when transforming files, include/exclude works for this option. Pass `false` to disable.
* javascript-obfuscator options. Refer to documentation here https://github.com/javascript-obfuscator/javascript-obfuscator#javascript-obfuscator-options
* @default {}
*/
fileOptions: ObfuscatorOptions | false,
options: ObfuscatorOptions,
/**
* Files to include when applying per-file obfuscation.
* @default ['**\/*.js', '**\/*.ts']
*/

@@ -24,2 +27,3 @@ include: FilterOptions,

* Files to exclude when applying per-file obfuscation. The priority is higher than `include`.
* @default ['node_modules/**']
*/

@@ -34,4 +38,4 @@ exclude: FilterOptions,

const defaultOptions = {
globalOptions: {},
fileOptions: {},
global: false,
options: {},
include: ['**/*.js', '**/*.ts'],

@@ -52,7 +56,7 @@ exclude: ['node_modules/**'],

transform: options.fileOptions === false ? undefined : (code, id) => {
transform: options.global ? undefined : (code, id) => {
if (!filter(id)) return null;
const obfuscationResult = options.obfuscate(code, {
...options.fileOptions,
...options.options,
inputFileName: id,

@@ -67,5 +71,5 @@ sourceMap: true,

},
renderChunk: options.globalOptions === false ? undefined : (code, { fileName }) => {
renderChunk: !options.global ? undefined : (code, { fileName }) => {
const obfuscationResult = options.obfuscate(code, {
...options.globalOptions,
...options.options,
inputFileName: fileName,

@@ -72,0 +76,0 @@ sourceMap: true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc