Code Monkey home page Code Monkey logo

Comments (4)

trompx avatar trompx commented on August 22, 2024 3

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)

from debundle.

1egoman avatar 1egoman commented on August 22, 2024 1

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. 😦

from debundle.

1egoman avatar 1egoman commented on August 22, 2024

Your moduleAST variable is set incorrectly. See https://github.com/1egoman/debundle/blob/master/DOCS.md#moduleast

from debundle.

trompx avatar trompx commented on August 22, 2024

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.

from debundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.