-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
access the import cache imported packages cache like require.cache #45207
Comments
Duplicate of #45206? |
documenting two hacks below. however, i wish the the exposure of |
import object from "module" - import("module") - require("module") - https://github.com/ganeshkbhat/get-imports/blob/main/index.js |
Posted a hacky solution for anyone needing something in the meantime here, no idea how robust it is but meeting my needs for the time being: |
Nice. I published a package for the same - https://www.npmjs.com/package/get-imported welcome to use. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
access the import cache - imported packages cache like require.cache
What is the problem this feature will solve?
accessing cache will give access to modules imported in a module or a different module. node.js does not have an ast support while languages like python have it. to access modules imported is there a simple hack or a way to access the import cache. it could also be a immutble cache as well.
What is the feature you are proposing to solve the problem?
to access import cache to fetch the modules imported. is there a simple hack or a way to access the import cache. it could also be a immutble cache as well.
Affected URL(s)
https://nodejs.org/api/esm.html#esm_no_require_cache
Description of the problem
How do i access the imported packages cache like require.cache?
I am trying to do something like this:
c.mjs
c.js
test.js
This question comes after
https://stackoverflow.com/questions/74215997/how-do-i-do-console-log-in-esm-or-es6-file-without-having-a-package-json-in-the?noredirect=1#comment131031974_74215997
nodejs/help#2806 (comment)
nodejs/help#2806
Note:
I have read this:
I am aware of this docs - https://nodejs.org/api/esm.html#esm_no_require_cache
A simple hack is also fine.
What alternatives have you considered?
since there is no access to ast, th the only other way is to use a regex to access the import statements which is very crude and can be a serious mistake for the regex parser.
The text was updated successfully, but these errors were encountered: