1egoman / debundle

:card_file_box: A javascript debundler. Takes a Browserify or Webpack bundle and recreates the initial, pre-bundled source.
https://www.npmjs.com/package/debundle
705 stars 145 forks source link

Infer webpack module names from import constants names #14

Closed extesy closed 6 years ago

extesy commented 6 years ago

@1egoman I think it's possible to infer original module names and folders from other modules that import them, for example:

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__localization__ = __webpack_require__(47);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_bignumber_js__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_bignumber_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_bignumber_js__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__store_account__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__store_system__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__store_book__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_0x_relay_utils__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_0x_relay_utils___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_0x_relay_utils__);

Here you can see that module 4 is "constants.js", module 15 is "store/account.js", etc.

1egoman commented 6 years ago

Cool!

I don't really have interest in continuing to add features to this project (most likely, I'll rewrite it at some point in the future if I need a tool like this again). But, I'd love to review any pull requests if this is something you (or someone else) wants to tackle.

1egoman commented 6 years ago

Closed due to inactivity

One note though: if the bundle is minified (as bundles often are), this information is lost.