Coder Social home page Coder Social logo

Comments (2)

mrjoelkemp avatar mrjoelkemp commented on July 28, 2024

Hey @mistic. Thanks for the issue! Can you provide an example of how you're using require.resolve?

Based on my assumptions on how you're using it, we'd need to add support for it in the commonjs detective. I could definitely see your future example being a test case here: https://github.com/dependents/node-detective-cjs/blob/master/test/test.js#L33.

Here is where we sniff for require(): https://github.com/dependents/node-detective-cjs/blob/master/index.js#L13-L26. You could add support for require.resolve there by looking for a resolve function call that's an attribute of a require object.

If you're unfamiliar with ASTs, you're basically iterating through the keys in a big object and looking for a particular part of it (if it exists). Here's a good tool for seeing the AST representation of some code to look for the part of the object that represents require.resolve(''): https://astexplorer.net/#/gist/ed8f609760da184363377d975063552b/45f0e4dae0e876853a9997fde5faeeb7137e4746.

I'm super open to a PR in node-detective-cjs with the fix.

from node-precinct.

mrjoelkemp avatar mrjoelkemp commented on July 28, 2024

Hey @mistic. Similar support was recently added by a contributor for supporting require.main.require. That (#47) could be a good starting point if you or another contributor would like to address this issue.

from node-precinct.

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.