Prechádzať zdrojové kódy

now using `babel-runtime` for providing polyfills and helpers

sanex3339 8 rokov pred
rodič
commit
5b95b3b98a

+ 8 - 1
.babelrc

@@ -2,5 +2,12 @@
   "generatorOpts": {
     "retainFunctionParens": true
   },
-  "presets": ["es2015"]
+  "presets": ["es2015"],
+  "plugins": [
+    ["transform-runtime", {
+      "helpers": true,
+      "polyfill": true,
+      "regenerator": false
+    }]
+  ]
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 364 - 176
dist/index.js


+ 2 - 1
package.json

@@ -20,7 +20,7 @@
     "javascript-obfuscator": "./bin/javascript-obfuscator.js"
   },
   "dependencies": {
-    "babel-polyfill": "6.20.0",
+    "babel-runtime": "^6.20.0",
     "chance": "1.0.4",
     "class-validator": "0.6.6",
     "commander": "2.9.0",
@@ -53,6 +53,7 @@
     "awesome-typescript-loader": "3.0.0-beta.17",
     "babel-cli": "6.18.0",
     "babel-loader": "6.2.10",
+    "babel-plugin-transform-runtime": "^6.15.0",
     "babel-preset-es2015": "6.18.0",
     "chai": "3.5.0",
     "coveralls": "2.11.15",

+ 0 - 4
src/JavaScriptObfuscator.ts

@@ -1,9 +1,5 @@
 import 'reflect-metadata';
 
-if (!(<any>global)._babelPolyfill) {
-    require('babel-polyfill');
-}
-
 import { ServiceIdentifiers } from './container/ServiceIdentifiers';
 
 import { Chance } from 'chance';

+ 3 - 3
test/functional-tests/node-transformers/node-control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.spec.ts

@@ -31,11 +31,11 @@ describe('BinaryExpressionControlFlowReplacer', () => {
 
         describe('variant #2 - multiple binary expressions with threshold = 1', () => {
             it('should replace binary expression node by call to control flow storage node', function () {
-                this.timeout(4000);
+                this.timeout(2000);
 
-                const samplesCount: number = 200;
+                const samplesCount: number = 100;
                 const expectedValue: number = 0.5;
-                const delta: number = 0.06;
+                const delta: number = 0.1;
 
                 let equalsValue: number = 0;
 

+ 0 - 2
test/index.spec.ts

@@ -1,8 +1,6 @@
-import { BabelPolyfill } from './polyfills/BabelPolyfill';
 import 'reflect-metadata';
 
 require('source-map-support').install();
-BabelPolyfill.append();
 
 /**
  * Unit tests

+ 0 - 7
test/polyfills/BabelPolyfill.ts

@@ -1,7 +0,0 @@
-export class BabelPolyfill {
-    public static append (): void {
-        if (!(<any>global)._babelPolyfill) {
-            require('babel-polyfill');
-        }
-    }
-}

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov