mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Merge pull request #253 from javascript-obfuscator/web-version
Added base web version
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
Change Log
|
||||
===
|
||||
v0.17.0
|
||||
---
|
||||
* **Browser version**: Added browser version dist
|
||||
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/252
|
||||
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/247
|
||||
|
||||
v0.16.0
|
||||
---
|
||||
* Correct obfuscation of object rest and spread properties
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
Author: Timofey Kachalov
|
||||
-->
|
||||
|
||||
# JavaScript obfuscator for Node.js
|
||||
# JavaScript obfuscator
|
||||
|
||||

|
||||
|
||||
JavaScript obfuscator is a powerful free obfuscator for JavaScript and Node.js with a wide number of features which provides protection for your source code.
|
||||
JavaScript obfuscator is a powerful free obfuscator for JavaScript with a wide number of features which provides protection for your source code.
|
||||
|
||||
Example of obfuscated code: [gist.github.com](https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf)
|
||||
|
||||
@@ -50,7 +50,9 @@ It is not recommended to obfuscate vendor scripts and polyfills, since the obfus
|
||||
|
||||
## Installation
|
||||
|
||||
Install the package with Yarn or NPM and add it to your `devDependencies`:
|
||||
#### Using Yarn or NPM
|
||||
|
||||
Install the package with Yarn or NPM and add it to your `dependencies` or `devDependencies`:
|
||||
|
||||
```sh
|
||||
$ yarn add --dev javascript-obfuscator
|
||||
@@ -60,9 +62,21 @@ or
|
||||
$ npm install --save-dev javascript-obfuscator
|
||||
```
|
||||
|
||||
## Node.js usage
|
||||
#### In a Browser
|
||||
|
||||
Here's an example of how to use it:
|
||||
From CDN:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js"/>
|
||||
```
|
||||
|
||||
From `node_modules`:
|
||||
|
||||
```html
|
||||
<script src="./node_modules/javascript-obfuscator/dist/index.browser.js"/>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var JavaScriptObfuscator = require('javascript-obfuscator');
|
||||
@@ -866,7 +880,7 @@ Try to run `npm link javascript-obfuscator` command or install it globally with
|
||||
### Error `maximum call stack size exceeded`
|
||||
Likely this is `selfDefending` mechanism. Something is changing source code after obfuscation with `selfDefending` option.
|
||||
|
||||
### Web version?
|
||||
### Online version?
|
||||
|
||||
[obfuscator.io](https://obfuscator.io)
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('../dist/index').runCLI(process.argv);
|
||||
require('../dist/index.cli').obfuscate(process.argv);
|
||||
Vendored
+54
File diff suppressed because one or more lines are too long
Vendored
+25
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
import { JavaScriptObfuscatorCLI } from './src/JavaScriptObfuscatorCLIFacade';
|
||||
|
||||
module.exports = JavaScriptObfuscatorCLI;
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "0.16.0",
|
||||
"version": "0.17.0-dev.0",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
@@ -15,6 +15,7 @@
|
||||
"node": ">=6.11.5"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"browser": "dist/index.browser.js",
|
||||
"bin": {
|
||||
"javascript-obfuscator": "./bin/javascript-obfuscator"
|
||||
},
|
||||
@@ -33,7 +34,6 @@
|
||||
"mkdirp": "0.5.1",
|
||||
"multimatch": "2.1.0",
|
||||
"opencollective": "1.0.3",
|
||||
"pjson": "1.0.9",
|
||||
"reflect-metadata": "0.1.12",
|
||||
"source-map-support": "0.5.4",
|
||||
"string-template": "1.0.0",
|
||||
@@ -64,6 +64,7 @@
|
||||
"coveralls": "3.0.0",
|
||||
"istanbul": "1.1.0-alpha.1",
|
||||
"mocha": "5.1.0",
|
||||
"pjson": "1.0.9",
|
||||
"pre-commit": "1.2.2",
|
||||
"rimraf": "2.6.2",
|
||||
"sinon": "4.5.0",
|
||||
@@ -85,7 +86,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "scripts/start",
|
||||
"webpack": "scripts/webpack",
|
||||
"webpack:prod": "scripts/webpack-prod",
|
||||
"webpack:dev": "scripts/webpack-dev",
|
||||
"build": "scripts/build",
|
||||
"watch": "scripts/watch",
|
||||
"removeCacheDir": "scripts/remove-cache-dir",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
yarn run removeCacheDir &&
|
||||
yarn run webpack &&
|
||||
yarn run webpack:prod &&
|
||||
yarn run tslint &&
|
||||
yarn test
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/tsc -p tsconfig.test.json &&
|
||||
$(yarn bin)/tsc -p test/tsconfig.test.json &&
|
||||
$(yarn bin)/babel test-tmp --out-dir test-tmp --source-maps inline &&
|
||||
rsync -a --prune-empty-dirs --include '*/' --include '*.js' --include '*.json' --exclude '*' test/ test-tmp/test/
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/tslint src/**/*.ts --project tsconfig.json
|
||||
$(yarn bin)/tslint src/**/*.ts --project src/tsconfig.node.json
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/webpack --mode development --watch
|
||||
$(yarn bin)/webpack --config webpack/webpack.node.config.js --mode development --watch
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/webpack --mode production
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/webpack --config webpack/webpack.node.config.js --mode production
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(yarn bin)/webpack --config webpack/webpack.node.config.js --config webpack/webpack.browser.config.js --mode production
|
||||
@@ -4,7 +4,6 @@ import { ServiceIdentifiers } from './container/ServiceIdentifiers';
|
||||
import * as escodegen from 'escodegen-wallaby';
|
||||
import * as espree from 'espree';
|
||||
import * as ESTree from 'estree';
|
||||
import * as packageJson from 'pjson';
|
||||
|
||||
import { IGeneratorOutput } from './interfaces/IGeneratorOutput';
|
||||
import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
|
||||
@@ -127,7 +126,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
|
||||
*/
|
||||
public obfuscate (sourceCode: string): IObfuscationResult {
|
||||
const timeStart: number = Date.now();
|
||||
this.logger.info(LoggingMessage.Version, packageJson.version);
|
||||
this.logger.info(LoggingMessage.Version, '0.16.0');
|
||||
this.logger.info(LoggingMessage.ObfuscationStarted);
|
||||
this.logger.info(LoggingMessage.RandomGeneratorSeed, this.randomGenerator.getSeed());
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'reflect-metadata';
|
||||
|
||||
import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI';
|
||||
|
||||
class JavaScriptObfuscatorCLIFacade {
|
||||
/**
|
||||
* @param {string[]} argv
|
||||
*/
|
||||
public static obfuscate (argv: string[]): void {
|
||||
const javaScriptObfuscatorCLI: JavaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI(argv);
|
||||
|
||||
javaScriptObfuscatorCLI.initialize();
|
||||
javaScriptObfuscatorCLI.run();
|
||||
}
|
||||
}
|
||||
|
||||
export { JavaScriptObfuscatorCLIFacade as JavaScriptObfuscatorCLI };
|
||||
@@ -9,9 +9,13 @@ import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
|
||||
import { IObfuscationResult } from './interfaces/IObfuscationResult';
|
||||
|
||||
import { InversifyContainerFacade } from './container/InversifyContainerFacade';
|
||||
import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI';
|
||||
|
||||
class JavaScriptObfuscatorFacade {
|
||||
/**
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
public static version: string = process.env.VERSION || 'unknown';
|
||||
|
||||
/**
|
||||
* @param {string} sourceCode
|
||||
* @param {TInputOptions} inputOptions
|
||||
@@ -30,16 +34,6 @@ class JavaScriptObfuscatorFacade {
|
||||
|
||||
return obfuscationResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} argv
|
||||
*/
|
||||
public static runCLI (argv: string[]): void {
|
||||
const javaScriptObfuscatorCLI: JavaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI(argv);
|
||||
|
||||
javaScriptObfuscatorCLI.initialize();
|
||||
javaScriptObfuscatorCLI.run();
|
||||
}
|
||||
}
|
||||
|
||||
export { JavaScriptObfuscatorFacade as JavaScriptObfuscator };
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as commander from 'commander';
|
||||
import * as packageJson from 'pjson';
|
||||
import * as path from 'path';
|
||||
|
||||
import { TInputCLIOptions } from '../types/options/TInputCLIOptions';
|
||||
@@ -186,7 +185,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
this.commands
|
||||
.usage('<inputPath> [options]')
|
||||
.version(
|
||||
packageJson.version,
|
||||
process.env.VERSION || 'unknown',
|
||||
'-v, --version'
|
||||
)
|
||||
.option(
|
||||
@@ -248,7 +247,10 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
ArraySanitizer
|
||||
)
|
||||
.option(
|
||||
'--identifier-names-generator <string> [hexadecimal, mangled]', 'Sets identifier names generator (Default: hexadecimal)',
|
||||
'--identifier-names-generator <string>',
|
||||
'Sets identifier names generator. ' +
|
||||
'Values: hexadecimal, mangled. ' +
|
||||
'Default: hexadecimal',
|
||||
IdentifierNamesGeneratorSanitizer
|
||||
)
|
||||
.option(
|
||||
@@ -296,8 +298,10 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
'Sets file name for output source map when `--source-map-mode=separate`'
|
||||
)
|
||||
.option(
|
||||
'--source-map-mode <string> [inline, separate]',
|
||||
'Specify source map output mode',
|
||||
'--source-map-mode <string>',
|
||||
'Specify source map output mode. ' +
|
||||
'Values: inline, separate. ' +
|
||||
'Default: separate',
|
||||
SourceMapModeSanitizer
|
||||
)
|
||||
.option(
|
||||
@@ -306,8 +310,10 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
BooleanSanitizer
|
||||
)
|
||||
.option(
|
||||
'--string-array-encoding <string|boolean> [true, false, base64, rc4]',
|
||||
'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed',
|
||||
'--string-array-encoding <string|boolean>',
|
||||
'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed. ' +
|
||||
'Values: true, false, base64, rc4. ' +
|
||||
'Default: false',
|
||||
StringArrayEncodingSanitizer
|
||||
)
|
||||
.option(
|
||||
@@ -317,7 +323,9 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
)
|
||||
.option(
|
||||
'--target <string>',
|
||||
'Allows to set target environment for obfuscated code.',
|
||||
'Allows to set target environment for obfuscated code. ' +
|
||||
'Values: browser, browser-no-eval, node. ' +
|
||||
'Default: browser',
|
||||
ObfuscationTargetSanitizer
|
||||
)
|
||||
.option(
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
},
|
||||
"exclude": [
|
||||
"../test"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"importHelpers": true,
|
||||
"noEmitHelpers": true,
|
||||
"sourceMap": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "tslint-language-service",
|
||||
"ignoreDefinitionFiles": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"../test"
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { assert } from 'chai';
|
||||
|
||||
import { StdoutWriteMock } from '../../mocks/StdoutWriteMock';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscatorFacade';
|
||||
import { JavaScriptObfuscatorCLI } from '../../../src/JavaScriptObfuscatorCLIFacade';
|
||||
|
||||
describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
this.timeout(100000);
|
||||
@@ -35,7 +35,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let isFileExist: boolean;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -67,7 +67,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
before(() => {
|
||||
outputFixturesFilePath = `${fixturesDirName}/${outputFileName}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath
|
||||
@@ -89,7 +89,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => JavaScriptObfuscator.runCLI([
|
||||
testFunc = () => JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
'wrong/file/path'
|
||||
@@ -111,7 +111,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
before(() => {
|
||||
fs.writeFileSync(outputFilePath, 'data');
|
||||
|
||||
testFunc = () => JavaScriptObfuscator.runCLI([
|
||||
testFunc = () => JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
outputFilePath
|
||||
@@ -133,7 +133,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let isFileExist: boolean;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -155,7 +155,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => JavaScriptObfuscator.runCLI([
|
||||
testFunc = () => JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -201,7 +201,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
outputFixturesFilePath2 = `${directoryPath}/${outputFileName2}`;
|
||||
outputFixturesFilePath3 = `${directoryPath}/${outputFileName3}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
directoryPath,
|
||||
@@ -263,7 +263,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
outputFixturesFilePath1 = `${directoryPath}/${outputFileName1}`;
|
||||
outputFixturesFilePath2 = `${directoryPath}/${outputFileName2}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
directoryPath,
|
||||
@@ -322,7 +322,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
outputFixturesFilePath2 = `${outputDirectoryPath}/${directoryPath}/${outputFileName2}`;
|
||||
outputFixturesFilePath3 = `${outputDirectoryPath}/${directoryPath}/${outputFileName3}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
directoryPath,
|
||||
@@ -388,7 +388,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
outputFixturesFilePath2 = `${directoryPath}/${outputFileName2}`;
|
||||
outputFixturesFilePath3 = `${directoryPath}/${outputFileName3}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
directoryPath,
|
||||
@@ -453,7 +453,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
outputFixturesFilePath2 = `${directoryPath}/${outputFileName2}`;
|
||||
outputFixturesFilePath3 = `${directoryPath}/${outputFileName3}`;
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
directoryPath,
|
||||
@@ -503,7 +503,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
sourceMapObject: any;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -554,7 +554,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
sourceMapObject: any;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -611,7 +611,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
sourceMapObject: any;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -664,7 +664,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let isFileExist: boolean;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -708,7 +708,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
beforeEach(() => {
|
||||
stdoutWriteMock.mute();
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -730,7 +730,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
beforeEach(() => {
|
||||
stdoutWriteMock.mute();
|
||||
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator'
|
||||
]);
|
||||
@@ -756,7 +756,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
sourceMapObject: any;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
@@ -804,7 +804,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let isFileExist: boolean;
|
||||
|
||||
before(() => {
|
||||
JavaScriptObfuscator.runCLI([
|
||||
JavaScriptObfuscatorCLI.obfuscate([
|
||||
'node',
|
||||
'javascript-obfuscator',
|
||||
fixtureFilePath,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../test-tmp",
|
||||
"noEmitHelpers": true,
|
||||
"importHelpers": true,
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"noImplicitAny": true,
|
||||
},
|
||||
"include": [
|
||||
"../**/*"
|
||||
]
|
||||
}
|
||||
+3
-13
@@ -2,30 +2,20 @@
|
||||
"compilerOptions": {
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"noEmitHelpers": true,
|
||||
"noImplicitThis": false,
|
||||
"noUnusedLocals": true,
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "es2017",
|
||||
"plugins": [
|
||||
{
|
||||
"name": "tslint-language-service",
|
||||
"ignoreDefinitionFiles": true
|
||||
}
|
||||
]
|
||||
"strict": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test"
|
||||
"node_modules"
|
||||
],
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "test-tmp",
|
||||
"target": "es2017",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"noEmitHelpers": true,
|
||||
"importHelpers": true,
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const copyright = 'Copyright (C) 2016-2018 Timofey Kachalov <sanex3339@yandex.ru>';
|
||||
|
||||
class WebpackUtils {
|
||||
/**
|
||||
* @param entries
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static getBannerText (...entries) {
|
||||
const lineSeparator = '\n\n';
|
||||
|
||||
return entries.reduce((bannerText, entry) => {
|
||||
return `${bannerText}${entry}${lineSeparator}`
|
||||
}, '');
|
||||
}
|
||||
|
||||
static getLicenseText () {
|
||||
return `/*!\n${copyright}\n\n` +
|
||||
fs.readFileSync('./LICENSE.BSD', 'utf8') + "\n*/";
|
||||
}
|
||||
|
||||
static getSourceMapSupportImport () {
|
||||
return `require("source-map-support").install();`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.WebpackUtils = WebpackUtils;
|
||||
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
const packageJson = require('pjson');
|
||||
|
||||
const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
'index': './index.ts'
|
||||
},
|
||||
target: 'web',
|
||||
module: {
|
||||
exprContextCritical: false,
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
query: {
|
||||
configFileName: 'src/tsconfig.browser.json',
|
||||
useBabel: true,
|
||||
babelCore: '@babel/core',
|
||||
useCache: true,
|
||||
forceIsolatedModules: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
plugins: [
|
||||
new webpack.BannerPlugin(
|
||||
{
|
||||
banner: WebpackUtils.getBannerText(WebpackUtils.getLicenseText()),
|
||||
raw: true,
|
||||
entryOnly: false
|
||||
}
|
||||
),
|
||||
new webpack.EnvironmentPlugin({
|
||||
VERSION: packageJson.version
|
||||
})
|
||||
],
|
||||
output: {
|
||||
libraryTarget: 'umd',
|
||||
library: 'JavaScriptObfuscator',
|
||||
filename: 'index.browser.js'
|
||||
},
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
stats: {
|
||||
maxModules: 0,
|
||||
warnings: false
|
||||
}
|
||||
};
|
||||
@@ -1,45 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require("fs");
|
||||
const nodeExternals = require('webpack-node-externals');
|
||||
const webpack = require('webpack');
|
||||
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
|
||||
const TSLintPlugin = require('tslint-webpack-plugin');
|
||||
const packageJson = require('pjson');
|
||||
|
||||
const copyright = 'Copyright (C) 2016-2018 Timofey Kachalov <sanex3339@yandex.ru>';
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
const getLicenseText = () => {
|
||||
return `/*!\n${copyright}\n\n` +
|
||||
fs.readFileSync('./LICENSE.BSD', 'utf8') + "\n*/";
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
const getSourceMapSupportImport = () => {
|
||||
return `require("source-map-support").install();`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
const getBannerText = () => {
|
||||
const lineSeparator = '\n\n';
|
||||
|
||||
return getLicenseText() +
|
||||
lineSeparator +
|
||||
getSourceMapSupportImport() +
|
||||
lineSeparator;
|
||||
};
|
||||
const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
'index': './index.ts'
|
||||
},
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
'index': './index.ts',
|
||||
'index.cli': './index.cli.ts'
|
||||
},
|
||||
target: 'node',
|
||||
externals: [nodeExternals()],
|
||||
module: {
|
||||
@@ -49,6 +23,7 @@ module.exports = {
|
||||
test: /\.ts(x?)$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
query: {
|
||||
configFileName: 'src/tsconfig.node.json',
|
||||
useBabel: true,
|
||||
babelCore: '@babel/core',
|
||||
useCache: true,
|
||||
@@ -63,23 +38,29 @@ module.exports = {
|
||||
plugins: [
|
||||
new webpack.BannerPlugin(
|
||||
{
|
||||
banner: getBannerText(),
|
||||
banner: WebpackUtils.getBannerText(
|
||||
WebpackUtils.getLicenseText(),
|
||||
WebpackUtils.getSourceMapSupportImport()
|
||||
),
|
||||
raw: true,
|
||||
entryOnly: false
|
||||
}
|
||||
),
|
||||
new webpack.EnvironmentPlugin({
|
||||
VERSION: packageJson.version
|
||||
}),
|
||||
new CheckerPlugin(),
|
||||
new TSLintPlugin({
|
||||
files: ['./src/**/*.ts'],
|
||||
project: './tsconfig.json',
|
||||
project: './src/tsconfig.node.json',
|
||||
exclude: []
|
||||
})
|
||||
],
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
library: "JavaScriptObfuscator"
|
||||
libraryTarget: 'commonjs2',
|
||||
library: 'JavaScriptObfuscator'
|
||||
},
|
||||
stats: {
|
||||
maxModules: 0
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user