Skip to content

Commit 759b11d

Browse files
committed
0.12.0 release
1 parent b1af4ca commit 759b11d

File tree

5 files changed

+39
-35
lines changed

5 files changed

+39
-35
lines changed

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"use strict";
2-
var JavaScriptObfuscator = require('javascript-obfuscator'), RawSource = require("webpack-sources").RawSource, SourceMapSource = require("webpack-sources").SourceMapSource, multimatch = require('multimatch'), transferSourceMap = require("multi-stage-sourcemap").transfer;
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var JavaScriptObfuscator = require('javascript-obfuscator');
4+
var RawSource = require("webpack-sources").RawSource;
5+
var SourceMapSource = require("webpack-sources").SourceMapSource;
6+
var multimatch = require('multimatch');
7+
var transferSourceMap = require("multi-stage-sourcemap").transfer;
38
var WebpackObfuscator = (function () {
49
function WebpackObfuscator(options, excludes) {
510
this.options = {};
@@ -58,13 +63,7 @@ var WebpackObfuscator = (function () {
5863
});
5964
};
6065
WebpackObfuscator.prototype.shouldExclude = function (filePath, excludes) {
61-
for (var _i = 0, excludes_1 = excludes; _i < excludes_1.length; _i++) {
62-
var exclude = excludes_1[_i];
63-
if (multimatch(filePath, exclude).length > 0) {
64-
return true;
65-
}
66-
}
67-
return false;
66+
return multimatch(filePath, excludes).length > 0;
6867
};
6968
return WebpackObfuscator;
7069
}());

index.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
"use strict";
22

3-
let JavaScriptObfuscator: any = require('javascript-obfuscator'),
4-
RawSource: any = require("webpack-sources").RawSource,
5-
SourceMapSource: any = require("webpack-sources").SourceMapSource,
6-
multimatch: any = require('multimatch'),
7-
transferSourceMap = require("multi-stage-sourcemap").transfer;
3+
import { Compiler } from 'webpack';
4+
5+
const JavaScriptObfuscator = require('javascript-obfuscator');
6+
const RawSource = require("webpack-sources").RawSource;
7+
const SourceMapSource = require("webpack-sources").SourceMapSource;
8+
const multimatch = require('multimatch');
9+
const transferSourceMap = require("multi-stage-sourcemap").transfer;
10+
11+
type TObject = {[key: string]: any};
812

913
class WebpackObfuscator {
10-
public options: any = {};
14+
/**
15+
* @type {TObject}
16+
*/
17+
public options: TObject = {};
18+
19+
/**
20+
* @type {string}
21+
*/
1122
public excludes: string[];
1223

1324
/**
14-
* @param options
15-
* @param excludes
25+
* @param {TObject} options
26+
* @param {string | string[]} excludes
1627
*/
17-
constructor (options: any, excludes: string|string[]) {
28+
constructor (options: TObject, excludes: string|string[]) {
1829
this.options = options || {};
1930
this.excludes = typeof excludes === 'string' ? [excludes] : excludes || [];
2031
}
2132

2233
/**
23-
* @param compiler
34+
* @param {Compiler} compiler
2435
*/
25-
public apply (compiler: any): void {
36+
public apply (compiler: Compiler): void {
2637
compiler.plugin('compilation', (compilation: any) => {
2738
compilation.plugin("optimize-chunk-assets", (chunks: any[], callback: () => void) => {
2839
let files = [];
@@ -97,13 +108,7 @@ class WebpackObfuscator {
97108
* @returns {boolean}
98109
*/
99110
private shouldExclude (filePath: string, excludes: string[]): boolean {
100-
for (let exclude of excludes) {
101-
if (multimatch(filePath, exclude).length > 0) {
102-
return true;
103-
}
104-
}
105-
106-
return false;
111+
return multimatch(filePath, excludes).length > 0
107112
}
108113
}
109114

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-obfuscator",
3-
"version": "0.11.2",
3+
"version": "0.12.0",
44
"description": "javascript-obfuscator plugin for Webpack",
55
"keywords": [
66
"obfuscator",
@@ -14,15 +14,16 @@
1414
],
1515
"main": "index.js",
1616
"dependencies": {
17-
"javascript-obfuscator": "0.11.2",
17+
"@types/webpack": "^3.0.13",
18+
"javascript-obfuscator": "0.12.0",
1819
"multi-stage-sourcemap": "0.2.1",
1920
"multimatch": "2.1.0"
2021
},
2122
"devDependencies": {
22-
"@types/node": "8.0.17",
23-
"typescript": "2.4.2",
23+
"@types/node": "8.0.45",
24+
"typescript": "2.5.3",
2425
"typings": "2.1.1",
25-
"webpack": "3.4.1"
26+
"webpack": "3.8.1"
2627
},
2728
"repository": {
2829
"type": "git",

test/config/webpack.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'use strict';
22

3-
const webpack = require('webpack');
43
const JavaScriptObfuscator = require('../../index');
54

65
module.exports = {
76
entry: {
87
'index': './test/input/index.js',
9-
'index1': './test/input/index1.js'
8+
'index-excluded': './test/input/index-excluded.js'
109
},
1110
devtool: 'source-map',
1211
target: 'web',
@@ -16,10 +15,10 @@ module.exports = {
1615
plugins: [
1716
new JavaScriptObfuscator({
1817
disableConsoleOutput: false
19-
}, ['index1*'])
18+
}, ['index-excluded*'])
2019
],
2120
output: {
22-
path: __dirname + 'test/output',
21+
path: __dirname + '/../output',
2322
filename: '[name].js'
2423
}
2524
};
File renamed without changes.

0 commit comments

Comments
 (0)