Browse Source

Added `process` polyfill for the browser and fixed library exports for node environment

sanex 4 years ago
parent
commit
c311250d1c

+ 1 - 1
bin/javascript-obfuscator

@@ -1,3 +1,3 @@
 #!/usr/bin/env node
 
-require('../dist/index.cli').JavaScriptObfuscator.obfuscate(process.argv);
+require('../dist/index.cli').obfuscate(process.argv);

File diff suppressed because it is too large
+ 0 - 0
dist/index.browser.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.cli.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 2 - 1
package.json

@@ -23,7 +23,7 @@
   "dependencies": {
     "@nuxtjs/opencollective": "0.2.2",
     "acorn": "8.0.3",
-    "assert": "^2.0.0",
+    "assert": "2.0.0",
     "chalk": "4.1.0",
     "chance": "1.1.7",
     "class-validator": "0.12.2",
@@ -38,6 +38,7 @@
     "md5": "2.3.0",
     "mkdirp": "1.0.4",
     "multimatch": "4.0.0",
+    "process": "0.11.10",
     "reflect-metadata": "0.1.13",
     "source-map-support": "0.5.19",
     "string-template": "1.0.0",

+ 1 - 1
test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts

@@ -209,7 +209,7 @@ describe('JavaScriptObfuscator runtime eval', function () {
                     `
                         ${getEnvironmentCode()}
                         ${obfuscatedCode}
-                        module.exports.JavaScriptObfuscator.obfuscate('var foo = 1;').getObfuscatedCode();
+                        module.exports.obfuscate('var foo = 1;').getObfuscatedCode();
                     `,
                     evaluationTimeout
                 )

+ 3 - 0
webpack/webpack.browser.config.js

@@ -36,6 +36,9 @@ module.exports = {
         ),
         new webpack.EnvironmentPlugin({
             VERSION: packageJson.version
+        }),
+        new webpack.ProvidePlugin({
+            process: ['process']
         })
     ],
     output: {

+ 1 - 2
webpack/webpack.node.config.js

@@ -70,8 +70,7 @@ module.exports = {
         })
     ],
     output: {
-        libraryTarget:  'commonjs2',
-        library: 'JavaScriptObfuscator'
+        libraryTarget:  'commonjs2'
     },
     stats: {
         excludeModules: true

+ 6 - 1
yarn.lock

@@ -1980,7 +1980,7 @@ [email protected], assert-plus@^1.0.0:
   resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
   integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=
 
-assert@^2.0.0:
[email protected]:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32"
   integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==
@@ -6005,6 +6005,11 @@ process-on-spawn@^1.0.0:
   dependencies:
     fromentries "^1.2.0"
 
[email protected]:
+  version "0.11.10"
+  resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
+  integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
+
 progress@^2.0.0:
   version "2.0.3"
   resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"

Some files were not shown because too many files changed in this diff