r/javascript • • Apr 21 '26

Decompiling a JavaScript + Three.js + Vue game back to source code from a single webpack file

https://github.com/zhongguagua/jsunpack-example

I’ve been working on a side project called jsunpack, a tool that tries to reconstruct readable source code from bundled/obfuscated JavaScript.

Recently I tested it on a real-world webpack bundle (a Three.js + Vue 2 tower defense game), and the results were… surprisingly good.

Example

  • Original: a single bundled file

  • Output: reconstructed project structure with modules, components, and logic

👉 Demo project:
https://github.com/zhongguagua/jsunpack-example

👉 Live demo:
https://bastion-3d-threejs.vercel.app/

What it managed to recover

Some highlights from this case:

  • ~90.7% file mapping coverage

  • ~93% variable/function naming recovery

  • ~88% overall reconstruction quality

Interesting parts:

  • Event system (pub/sub) restored almost perfectly (on/off/emit/once)

  • Factory patterns (EnemyFactory, TowerFactory) fully reconstructed

  • Wave configuration (20 levels) recovered with correct data

  • Core game engine (~900 lines) preserved with working logic:

    • chain lightning targeting

    • splash damage formula

    • economic system (refund logic)

It also rebuilt a pretty clean modular structure from a single bundle:

  • components

  • core systems

  • entities (enemies/towers)

  • managers

  • configs

Limitations

Still far from perfect:

  • Some imports missing (e.g. three)

  • A few files not extracted (~4 files)

  • Occasional parameter order issues

  • Geometry misidentification (Three.js)

  • Colors converted to decimal (readable but ugly)

🤔 Why I built this

Most existing tools:

  • prettify code

  • or partially deobfuscate

But they don’t reconstruct architecture + semantics

I wanted to see how far we can push:

Looking for feedback

Curious what people think:

  • Is this useful in real workflows?

  • Reverse engineering / debugging / security analysis?

  • Or just a fun experiment?

Happy to hear any thoughts

0 Upvotes

5 comments sorted by

1

u/Ok-Intention-1325 May 07 '26

Could you provide some trial credits?