Closed wongchichong closed 6 years ago
@wongchichong I just ran through the example again, it works for me. What's in your debundle.config.json
? What node version are you running? Do the md5sums of the files match the md5sums I calculated in the logs below?
λ ~/w/1egoman/debundle-2 node -v
v6.11.2
λ ~/w/1egoman/debundle-2 debundle
This is a debundler - it takes a bundle and expands it into the source that was used to compile it.
Usage: /Users/ryan/.nvm/versions/node/v6.11.2/bin/debundle [input file] {OPTIONS}
Options:
--input, -i Bundle to debundle
--output, -o Directory to debundle code into.
--config, -c Configuration directory
λ ~/w/1egoman/debundle-2
λ ~/w/1egoman/debundle-2 curl https://raw.githubusercontent.com/1egoman/debundle/master/test_bundles/browserify/bundle.js > bundle.js
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8899 100 8899 0 0 62729 0 --:--:-- --:--:-- --:--:-- 93673
λ ~/w/1egoman/debundle-2 curl https://raw.githubusercontent.com/1egoman/debundle/master/test_bundles/browserify/debundle.config.json > debundle.config.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 47 100 47 0 0 474 0 --:--:-- --:--:-- --:--:-- 489
λ ~/w/1egoman/debundle-2 md5sum debundle.config.json
bdba8714f7ebbac1b66321c348938ef2 debundle.config.json
λ ~/w/1egoman/debundle-2 md5sum bundle.js
9fe28cd172341184b4aead6c89200659 bundle.js
λ ~/w/1egoman/debundle-2 debundle -i bundle.js -o dist/ -c debundle.config.json
* Using default AST location for browserify...
* Reading bundle...
* Using auto-discovered browserify entry point...
* Decoding modules...
* Discovered module 1
* Extracted module code for 1
* Extracted module lookup table for 1
* Calculated module lookup table for 1
* Discovered module 2
* Extracted module code for 2
* Extracted module lookup table for 2
* Calculated module lookup table for 2
* Discovered module 3
* Extracted module code for 3
* Extracted module lookup table for 3
* Calculated module lookup table for 3
* Discovered module 4
* Extracted module code for 4
* Extracted module lookup table for 4
* Calculated module lookup table for 4
* Discovered module 5
* Extracted module code for 5
* Extracted module lookup table for 5
* Calculated module lookup table for 5
* Discovered module 6
* Extracted module code for 6
* Extracted module lookup table for 6
* Calculated module lookup table for 6
* Discovered module 7
* Extracted module code for 7
* Extracted module lookup table for 7
* Calculated module lookup table for 7
* Reassembling requires...
* Reconstructing require path for module 2...
* 2 => node_modules/uuid/index
* Reconstructing require path for module 5...
* 5 => node_modules/uuid/v1
* Reconstructing require path for module 2...
* 2 => node_modules/uuid/index
* Reconstructing require path for module 6...
* 6 => node_modules/uuid/v4
* Reconstructing require path for module 5...
* 5 => node_modules/uuid/v1
* Reconstructing require path for module 4...
* 4 => node_modules/uuid/lib/rng
* Reconstructing require path for module 5...
* 5 => node_modules/uuid/v1
* Reconstructing require path for module 3...
* 3 => node_modules/uuid/lib/bytesToUuid
* Reconstructing require path for module 6...
* 6 => node_modules/uuid/v4
* Reconstructing require path for module 4...
* 4 => node_modules/uuid/lib/rng
* Reconstructing require path for module 6...
* 6 => node_modules/uuid/v4
* Reconstructing require path for module 3...
* 3 => node_modules/uuid/lib/bytesToUuid
* Reconstructing require path for module 7...
* 7 => index
* Reconstructing require path for module 1...
* 1 => node_modules/number/
* Reconstructing require path for module 7...
* 7 => index
* Reconstructing require path for module 2...
* 2 => node_modules/uuid/
* Resolving files...
* Reconstructing require path for module 1...
* 1 => node_modules/number/index
* Reconstructing require path for module 2...
* 2 => node_modules/uuid/index
* Reconstructing require path for module 3...
* 3 => node_modules/uuid/lib/bytesToUuid
* Reconstructing require path for module 4...
* 4 => node_modules/uuid/lib/rng
* Reconstructing require path for module 5...
* 5 => node_modules/uuid/v1
* Reconstructing require path for module 6...
* 6 => node_modules/uuid/v4
* Reconstructing require path for module 7...
* 7 => index
* Writing to disk...
* dist/node_modules/number doesn't exist, creating...
* dist/node_modules/uuid doesn't exist, creating...
* dist/node_modules/uuid/lib doesn't exist, creating...
* dist/node_modules/uuid/lib doesn't exist, creating...
* dist/node_modules/uuid doesn't exist, creating...
* dist/node_modules/uuid doesn't exist, creating...
* dist doesn't exist, creating...
* Writing file dist/index.js
* Writing file dist/node_modules/number/index.js
* Writing file dist/node_modules/uuid/lib/bytesToUuid.js
* Writing file dist/node_modules/uuid/index.js
* Writing file dist/node_modules/uuid/v1.js
* Writing file dist/node_modules/uuid/lib/rng.js
* Writing file dist/node_modules/uuid/v4.js
Just update the node.js version, still had the same error. PS. I'm running on windows 10.
C:\TEMP\cad>node -v
v8.9.1
C:\TEMP\cad>debundle
This is a debundler - it takes a bundle and expands it into the source that was used to compile it.
Usage: C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\index.js [input file] {OPTIONS}
Options:
--input, -i Bundle to debundle
--output, -o Directory to debundle code into.
--config, -c Configuration directory
C:\TEMP\cad>curl https://raw.githubusercontent.com/1egoman/debundle/master/test_bundles/browserify/bundle.js > bundle.js
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8899 100 8899 0 0 501 0 0:00:17 0:00:17 --:--:-- 501
C:\TEMP\cad>curl https://raw.githubusercontent.com/1egoman/debundle/master/test_bundles/browserify/debundle.config.json > debundle.config.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 47 100 47 0 0 3 0 0:00:15 0:00:13 0:00:02 4
C:\TEMP\cad>md5sum debundle.config.json
MD5sums 1.2 freeware for Win9x/ME/NT/2000/XP+
Copyright (C) 2001-2005 Jem Berkes - http://www.pc-tools.net/
Type md5sum -h for help
[Path] / filename MD5 sum
-------------------------------------------------------------------------------
[C:\TEMP\cad\]
debundle.config.json bdba8714f7ebbac1b66321c348938ef2
C:\TEMP\cad>md5sum bundle.js
MD5sums 1.2 freeware for Win9x/ME/NT/2000/XP+
Copyright (C) 2001-2005 Jem Berkes - http://www.pc-tools.net/
Type md5sum -h for help
[Path] / filename MD5 sum
-------------------------------------------------------------------------------
[C:\TEMP\cad\]
bundle.js 9fe28cd172341184b4aead6c89200659
C:\TEMP\cad>debundle -i bundle.js -o dist/ -c debundle.config.json
* Using default AST location for browserify...
* Reading bundle...
* Using auto-discovered browserify entry point...
* Decoding modules...
* Discovered module 1
* Extracted module code for 1
* Extracted module lookup table for 1
* Calculated module lookup table for 1
* Discovered module 2
* Extracted module code for 2
* Extracted module lookup table for 2
* Calculated module lookup table for 2
* Discovered module 3
* Extracted module code for 3
* Extracted module lookup table for 3
* Calculated module lookup table for 3
* Discovered module 4
* Extracted module code for 4
* Extracted module lookup table for 4
* Calculated module lookup table for 4
* Discovered module 5
* Extracted module code for 5
* Extracted module lookup table for 5
* Calculated module lookup table for 5
* Discovered module 6
* Extracted module code for 6
* Extracted module lookup table for 6
* Calculated module lookup table for 6
* Discovered module 7
* Extracted module code for 7
* Extracted module lookup table for 7
* Calculated module lookup table for 7
* Reassembling requires...
* Reconstructing require path for module 2...
* 2 => node_modules/uuid/index
C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\utils\getModuleLocation.js:98
throw new Error(err);
^
Error: Don't have enough information to expand bundle into named files. The process requires the path of one of the below to be explicitly defined:
at getModuleLocation (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\utils\getModuleLocation.js:98:11)
at node (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\transformRequires.js:79:34)
at NodePath.single (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\extern\replace-method\index.js:42:20)
at traverse (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:35:26)
at C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:48:13
at C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\types.js:612:18
at Array.forEach (<anonymous>)
at Object.exports.eachField (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\types.js:611:27)
at NodePath.traverse (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:42:15)
at NodePath.Pp.each (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\path.js:89:22)
@wongchichong Ah, you're on windows. Debundle doesn't support windows right now mostly because I don't have a windows machine to try and replicate problems and there are lots of hard-coded forward slashes all over the place.
Closed due to inactivity
I ran into this issue on my Mac (both node v6.11.2 and v10.5.0) , and the trouble was a path that started with ../
(it was from this line in my code: var ngApp = require('../_ng/setup');
)
The clue was in getModuleLocation.js:
// If a filePath has a bunch of `../`s at the end, then it's broken (it broke out of the dist
// folder!) In this cae, tell the user we need an absolute path of one of the files in order to
// resolve it. Log out each of the paths along the require tree and it's respective module id.
To resolve it, I mapped it to another path in the knownPaths
parameter; this was my config file:
{
"type": "browserify",
"knownPaths": {
"61": "./_ng/setup"
}
}
It is also a massive file (beautified, it's 48796 lines of code!) so the error didn't happen until the very end, after it had run for 20min 😭
I get the following error while running the sample, Please help.
debundle -i bundle.js -o dist/ -c debundle.config.json
Error: Don't have enough information to expand bundle into named files. The process requires the path of one of the below to be explicitly defined: at getModuleLocation (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\utils\getModuleLocation.js:98:11) at node (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\transformRequires.js:79:34) at NodePath.single (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\src\extern\replace-method\index.js:42:20) at traverse (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:35:26) at C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:48:13 at C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\types.js:612:18 at Array.forEach (native) at Object.exports.eachField (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\types.js:611:27) at NodePath.traverse (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\traverse.js:42:15) at NodePath.Pp.each (C:\Users\Wong\AppData\Roaming\npm\node_modules\debundle\node_modules\ast-types\lib\path.js:89:22)