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

Variables renaming #11

Closed kiwina closed 6 years ago

kiwina commented 6 years ago

hi i noticed that in webpack a lot of variables get renamed to module, exports, require any way around that? Also on windows debundler fails at getModuleLocation when it checks if (!filePath.startsWith(pathPrefix)) removing the check gets the output

1egoman commented 6 years ago

i noticed that in webpack a lot of variables get renamed to module, exports, require any way around that?

Not with this package. You could potentially preprocess the bundle somehow?

Also on windows debundler fails at getModuleLocation when it checks if (!filePath.startsWith(pathPrefix)) removing the check gets the output.

Ok. Can you give me a more thorough example? I can't help you if you don't give me details.

kiwina commented 6 years ago

getModuleLocation error happens with any of the tests on windows

λ debundle -i bundle.js -o dist/ -c debundle.config.json
* Reading bundle...
* Decoding modules...
* Reassembling requires...
* No lookup tabie for module 0, so using identifier as require path...
* 0 => 0
C:\Users\xxx\AppData\Local\Yarn\config\global\node_modules\debundle\src\utils\getModuleLocation.js:98
    throw new Error(err);
    ^

once i remove the test

* Reading bundle...
* Decoding modules...
* Reassembling requires...
* No lookup tabie for module 0, so using identifier as require path...
* 0 => 0
* No lookup tabie for module 294, so using identifier as require path...
* 294 => 294

And an example of what gets renamed

function r(module) {
  return module && module.__esModule ? module : { default: module };
}
Object.defineProperty(exports, '__esModule', { value: !0 });
var i = require('./125'), o = r(i);
exports.default = {
  roundTo: function (module, exports) {
    var require = module % exports;
    return require <= exports / 2 ? module - require : module + (exports - require);
  },
1egoman commented 6 years ago

Ah ok, take a look at https://github.com/1egoman/debundle/blob/master/DOCS.md#replacerequires, which might help clarify (a bit) what's going on.

1egoman commented 6 years ago

Closed due to inactivtiy