Closed trompx closed 7 years ago
Your moduleAST
variable is set incorrectly. See https://github.com/1egoman/debundle/blob/master/DOCS.md#moduleast
Thanks, I made some progress.
I had to add a console.log(ast.body)
to check the structure, maybe considering adding an option to output that data would help people configuring their moduleAst parameter.
console.log(ast.body) output:
Node {
type: 'ExpressionStatement',
start: 0,
end: 2418,
expression:
Node {
type: 'UnaryExpression',
start: 0,
end: 2417,
operator: '!',
prefix: true,
argument:
Node {
type: 'CallExpression',
start: 1,
end: 2417,
callee: [Object],
arguments: [Object] } } }
So I ended up with the following config:
{
"type": "browserify",
"knownPaths": {},
"entryPoint": "ast.body[0].expression.argument.arguments[2].elements[0].value",
"moduleAst": ["body", 0, "expression", "argument", "arguments", 0]
}
With my bundle, I get the following output with still an error:
* Reading bundle...
* 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
* Reassembling requires...
* Replacing e with 'module'...
* Replacing i with 'exports'...
* Replacing e with 'module'...
* Replacing i with 'exports'...
* Resolving files...
/usr/local/lib/node_modules/debundle/src/utils/getModulePath.js:8
throw new Error(`Module ${mod.id} cannot be found in the module array.`);
TypeError: Cannot read property 'id' of undefined
at makeModuleTree (/usr/local/lib/node_modules/debundle/src/utils/getModulePath.js:8:34)
at getModuleLocation (/usr/local/lib/node_modules/debundle/src/utils/getModuleLocation.js:17:14)
at modules.map.i (/usr/local/lib/node_modules/debundle/src/lookupTable.js:14:17)
at Array.map (native)
at lookupTableResolver (/usr/local/lib/node_modules/debundle/src/lookupTable.js:10:18)
at Object.<anonymous> (/usr/local/lib/node_modules/debundle/src/index.js:126:15)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
Entrypoint should be the id of the module that is at the top of the module tree. See https://github.com/1egoman/debundle/blob/master/DOCS.md#entrypoint-required-for-webpack-bundles
In the bundle here, I believe your entrypoint is the module with the id of 1
.
Try something like this:
{
"type": "browserify",
"knownPaths": {},
"entryPoint": 1,
"moduleAst": ["body", 0, "expression", "argument", "arguments", 0]
}
Also, the docs and error messages for this project could be improved. If you have any suggestions, I'd appreciate if you could either leave an issue or contribute better versions. Unfortunately I don't have time right now to devote to this project. 😦
No problem.
With your config it works correctly. Unfortunatly, the debundle does not return a clean es6 class just like here: https://gist.github.com/SamVerschueren/233d48892f6ba88be4a8768dc4fc5886
Anyway I greatly appreciate your help, thanks again.
@1egoman
Now (same setup as in https://github.com/1egoman/debundle/issues/5), when I run the command:
I get: