-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
module: expose resolveLoadAndCache
API
#55756
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
it was imported from the `parentURL` in the current process. If the module was | ||
already imported before `resolveLoadAndCache` is called, the cached version is | ||
returned; if not, it will populate the cache so future calls to | ||
`resolveLoadAndCache` or `import` do re-do the work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
`resolveLoadAndCache` or `import` do re-do the work. | |
`resolveLoadAndCache` or `import` do not re-do the work. |
|
||
> Stability: 1 - Experimental | ||
|
||
* `specifier` {string|URL} Customization hooks to be registered; this should be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `specifier` {string|URL} Customization hooks to be registered; this should be | |
* `specifier` {string|URL} Module to resolve and load; this should be |
@@ -392,6 +392,24 @@ ObjectFreeze(compileCacheStatus); | |||
const constants = { __proto__: null, compileCacheStatus }; | |||
ObjectFreeze(constants); | |||
|
|||
async function resolveLoadAndCache(specifier, base = 'data:', importAttributes = kEmptyObject, conditions) { | |||
const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader(); | |||
// TODO: this should hit the cache (and populate it if it finds nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already doing that, no? I see gets and sets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, it appears to do for ModuleLoader
but not CustomizedModuleLoader
. Is that what you mean?
Opening as draft as I'd like to get some feedback on the API design first. /cc @nodejs/loaders