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

module: expose resolveLoadAndCache API #55756

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Nov 6, 2024

Opening as draft as I'd like to get some feedback on the API design first. /cc @nodejs/loaders

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Nov 6, 2024
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

Suggested change
`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
Copy link
Contributor Author

@aduh95 aduh95 Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `specifier` {string|URL} Customization hooks to be registered; this should be
* `specifier` {string|URL} Module to resolve and load; this should be

@JakobJingleheimer JakobJingleheimer self-requested a review January 5, 2025 13:36
@@ -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)
Copy link
Member

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

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants