14

Is there any way to convert webpack bundled js file into source code ts? I have bundle.js file with me bundled with webpack. Unfortunately the source code files are deleted by a stupid accident. I want to reverse engineer my bundle.js file to get back my source code typescript files. Is there any possible way to achieve this?

Nutan
  • 1,478
  • 3
  • 12
  • 19

2 Answers2

10

Do you still have your source map files by any chance (e.g. main.bundle.js.map )? If so, you can run your app (ng serve), open the Chrome Dev Tools in your browser and you'll see your sources in TypeScript under the tab Sources -> webpack://

enter image description here

Yakov Fain
  • 11,972
  • 5
  • 33
  • 38
  • Thanks. I checked and found I do have source map files but the solution doesnt seem to be working . Under webpack:// I could only see empty bundle js and commonjs files. – Nutan Aug 25 '17 at 11:40
  • You should see there a folder without a name. Open it up. I've updated my answer with the image. – Yakov Fain Aug 25 '17 at 11:44
  • 1
    This saved me a lot of headache after a disk failure, thanks! – x0b Jan 03 '20 at 13:23
  • 5
    Do you know if there is a way to "download" the depacked webpack? – Ackdari Sep 23 '20 at 09:48
  • I had the same situation, but the code was split into endpoints (main.js, background.js, 787.9b602a0b.chunk.js, content.js), and this is a chrome extension. I used React. I have the source map. What can I do to convert it back? – Demian Feb 12 '23 at 13:05
7

You may try using debundle node module.

Debundle

uruapanmexicansong
  • 3,068
  • 1
  • 18
  • 22