ghostdevv / rollup-obfuscator

A plugin to obfuscate javascript for rollup based on https://www.npmjs.com/javascript-obfuscator
MIT License
55 stars 7 forks source link

Obfuscate misses out some modules to obfuscate #150

Open VijayaSankarN opened 4 months ago

VijayaSankarN commented 4 months ago

I have to obfuscate 7173 modules (application in ReactJS CoreUI framework). With this configuration:

plugins: [
  react(),
  obfuscator({
    compact: false,
    numbersToExpressions: true,
    identifierNamesGenerator: 'hexadecimal',
    selfDefending: true,
    renameGlobals: true,
  }),
]

All modueles are processed. But any other options added to the above config, like deadCodeInjection or splitStrings or stringArray or any other options from https://www.npmjs.com/package/javascript-obfuscator, the number of modules being processed are getting reduced to anything less than 6000 randomly and then build ends without any errors. This prevents the execution of the application overall.

What is being missed or is there anything that I need to configure in vite or obfuscator configuration to always ensure that 7173 modules are being executed.

I even tried adding space size:

{
  "scripts": {
    "build": "cross-env NODE_OPTIONS='--max_old_space_size=8192' vite build"
  }
}

Adding this further affects the number of modules being processed to anywhere between 2000 and 3000. Adjusting the values are of no help.

Without this Obfuscate configuration vite build always builds all the modules successfully.

Iceberry-qdd commented 3 months ago

Same question.

After using this plugin:

vite v3.2.10 building for production...
✓ 201 modules transformed.

Not using this plugin:

vite v3.2.10 building for production...
✓ 326 modules transformed.
Iceberry-qdd commented 3 months ago

Oh, finally i solve this by change option ignoreImports from false to true. Guess you can add this option to solve it too.

plugins: [
  react(),
  obfuscator({
    compact: false,
    numbersToExpressions: true,
    identifierNamesGenerator: 'hexadecimal',
    selfDefending: true,
    renameGlobals: true,
    ignoreImports: true // Add this
  }),
]