mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Applying optimize-js for obfuscated code
This commit is contained in:
Vendored
+169
-169
File diff suppressed because one or more lines are too long
+3
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "0.8.0-dev.0",
|
||||
"version": "0.8.0-dev.1",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
@@ -29,6 +29,7 @@
|
||||
"estraverse": "^4.2.0",
|
||||
"format-unicorn": "^1.1.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"optimize-js": "^1.0.1",
|
||||
"source-map-support": "^0.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -52,6 +53,7 @@
|
||||
"coveralls": "^2.11.14",
|
||||
"istanbul": "1.1.0-alpha.1",
|
||||
"mocha": "^3.0.2",
|
||||
"optimize-js-plugin": "0.0.4",
|
||||
"sinon": "^2.0.0-pre.3",
|
||||
"ts-loader": "^0.8.2",
|
||||
"ts-node": "^1.3.0",
|
||||
|
||||
@@ -12,6 +12,8 @@ import { Obfuscator } from "./Obfuscator";
|
||||
import { Options } from "./options/Options";
|
||||
import { SourceMapCorrector } from "./SourceMapCorrector";
|
||||
|
||||
const optimizeJs = require('optimize-js');
|
||||
|
||||
export class JavaScriptObfuscatorInternal {
|
||||
/**
|
||||
* @type {GenerateOptions}
|
||||
@@ -67,6 +69,10 @@ export class JavaScriptObfuscatorInternal {
|
||||
|
||||
const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, escodegenParams);
|
||||
|
||||
if (options.optimize) {
|
||||
generatorOutput.code = optimizeJs(generatorOutput.code);
|
||||
}
|
||||
|
||||
generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';
|
||||
|
||||
return generatorOutput;
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ export interface IObfuscatorOptions {
|
||||
debugProtectionInterval?: boolean;
|
||||
disableConsoleOutput?: boolean;
|
||||
encodeUnicodeLiterals?: boolean;
|
||||
optimize?: boolean;
|
||||
reservedNames?: string[];
|
||||
rotateUnicodeArray?: boolean;
|
||||
selfDefending?: boolean;
|
||||
|
||||
Vendored
+1
@@ -6,6 +6,7 @@ export interface IOptions {
|
||||
readonly debugProtectionInterval: boolean;
|
||||
readonly disableConsoleOutput: boolean;
|
||||
readonly encodeUnicodeLiterals: boolean;
|
||||
readonly optimize: boolean;
|
||||
readonly reservedNames: string[];
|
||||
readonly rotateUnicodeArray: boolean;
|
||||
readonly selfDefending: boolean;
|
||||
|
||||
@@ -72,6 +72,12 @@ export class Options implements IOptions {
|
||||
@IsBoolean()
|
||||
public readonly encodeUnicodeLiterals: boolean;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@IsBoolean()
|
||||
public readonly optimize: boolean;
|
||||
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,7 @@ export const DEFAULT_PRESET: IObfuscatorOptions = Object.freeze({
|
||||
disableConsoleOutput: true,
|
||||
domainLock: [],
|
||||
encodeUnicodeLiterals: false,
|
||||
optimize: true,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: true,
|
||||
selfDefending: true,
|
||||
|
||||
@@ -9,6 +9,7 @@ export const NO_CUSTOM_NODES_PRESET: IObfuscatorOptions = Object.freeze({
|
||||
disableConsoleOutput: false,
|
||||
domainLock: [],
|
||||
encodeUnicodeLiterals: false,
|
||||
optimize: false,
|
||||
reservedNames: [],
|
||||
rotateUnicodeArray: false,
|
||||
selfDefending: false,
|
||||
|
||||
+6
-2
@@ -2,7 +2,8 @@
|
||||
|
||||
var fs = require("fs"),
|
||||
nodeExternals = require('webpack-node-externals'),
|
||||
webpack = require('webpack');
|
||||
webpack = require('webpack'),
|
||||
OptimizeJSPlugin = require('optimize-js-plugin');
|
||||
|
||||
function getLicenseText () {
|
||||
return "/*\nCopyright (C) 2016 Timofey Kachalov <sanex3339@yandex.ru>\n\n" +
|
||||
@@ -31,7 +32,10 @@ module.exports = {
|
||||
raw: true,
|
||||
entryOnly: false
|
||||
}
|
||||
)
|
||||
),
|
||||
/*new OptimizeJSPlugin({
|
||||
sourceMap: true
|
||||
})*/
|
||||
],
|
||||
output: {
|
||||
path: './dist',
|
||||
|
||||
Reference in New Issue
Block a user