Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support access paths for Node.js builtin modules (standard library) #6

Open
werifu opened this issue Mar 14, 2023 · 1 comment

Comments

@werifu
Copy link

werifu commented Mar 14, 2023

I need the feature to recognize and analyze calls to Node standard library while Jelly does not support it yet.

My planning solution:

  1. Download the source code of the standard lib from https://github.com/nodejs/node/tree/main/lib and cache them in a cache directory like /tmp/node-lib/ if cache does not exist.
    The version of code can be determined by process.version
  2. Resolve the path of a builtin module with the code having been downloaded in this part:
    requireModule(str: string, resultVar: ConstraintVar | undefined, path: NodePath): ModuleInfo | DummyModuleInfo | undefined { // see requireModule in modulefinder.ts
  3. Process them as a 3rd party dependency and I think it can work
  4. Clear cache after finishing all analysis

Some details

  1. Downloading the source code should be completed before starting the analysis to avoid importing the complexity of async behaviors in many sync functions
  2. Provide some options about this:
    a. --ignore-builtin to disable this feature and ignore all calls to standard library such as http.get() just like what it is now. It will not download code.
    b. --ignore-dependencies will not analyze code inside builtin modules, which is the same as 3rd party lib.
    b. --cache-dir to specify the cache directory
    c. --keep-cache to keep the source code cache when analysis is finished.

How about my solution? I am working for this feature since I need it urgently. If it's okay after discussion, I'll open a PR when I finish it.

@amoeller
Copy link
Member

Hi @werifu, thanks for looking into this! Improving the support for the Node.js standard library is on our TODO. I'm not sure the best approach is to include the library source code in the analysis, if that's what you suggest. Contact me on [email protected], then we can talk about different approaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants