浏览代码

reverted back babel-polyfill

sanex3339 8 年之前
父节点
当前提交
8e00b56434

+ 1 - 0
package.json

@@ -20,6 +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",

+ 6 - 0
src/JavaScriptObfuscator.ts

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

+ 4 - 0
test/dev/dev-compile-performance.ts

@@ -2,6 +2,10 @@
 
 import * as fs from 'fs';
 
+if (!(<any>global)._babelPolyfill) {
+    require('babel-polyfill');
+}
+
 (function () {
     const JavaScriptObfuscator: any = require("../../index");
 

+ 4 - 0
test/dev/dev-runtime-performance.ts

@@ -1,5 +1,9 @@
 'use strict';
 
+if (!(<any>global)._babelPolyfill) {
+    require('babel-polyfill');
+}
+
 (function () {
     const JavaScriptObfuscator: any = require("../../index");
 

+ 4 - 0
test/dev/dev.ts

@@ -1,5 +1,9 @@
 'use strict';
 
+if (!(<any>global)._babelPolyfill) {
+    require('babel-polyfill');
+}
+
 (function () {
     const JavaScriptObfuscator: any = require("../../index");
 

+ 2 - 0
test/index.spec.ts

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

+ 7 - 0
test/polyfills/BabelPolyfill.ts

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