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

add missing jsdoc imports and defs #3

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const onImport = tracingChannel('module.import');
/**
* @typedef {import('./module_job.js').ModuleJobBase} ModuleJobBase
* @typedef {import('url').URL} URL
* @typedef {import('internal/modules/esm/hooks.js').HooksProxy} HooksProxy
*/

/**
Expand Down Expand Up @@ -109,6 +110,28 @@ let hooksProxy;
* @typedef {ArrayBuffer|TypedArray|string} ModuleSource
*/

/**
* @typedef {Object} LoadResult
* @property {ModuleFormat} format
* @property {ModuleSource} source
*/

/**
* @typedef {Object} ResolveResult
* @property {string} format
* @property {URL['href']} url
*/

/**
* @typedef {Object} Customizations
Copy link
Owner

Choose a reason for hiding this comment

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

I think you want object (little o)

Copy link
Owner

Choose a reason for hiding this comment

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

I think this definition already exists in customization_hooks too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed the first one, couldn't find a definition in customization_hooks

* @property {boolean} allowImportMetaResolve
* @property {(url: string, context: object) => Promise<LoadResult>} load
* @property {(originalSpecifier: string, parentURL: string, importAttributes: Record<string, string>) => Promise<ResolveResult>} resolve
* @property {(originalSpecifier: string, parentURL: string, importAttributes: Record<string, string>) => ResolveResult} resolveSync
* @property {(specifier: string, parentURL: string) => any} register
* @property {() => void} forceLoadHooks
*/

/**
* This class covers the base machinery of module loading. To add custom
* behavior you can pass a customizations object and this object will be
Expand Down Expand Up @@ -150,6 +173,7 @@ class ModuleLoader {
* to this property and failure to do so will cause undefined
* behavior when invoking `import.meta.resolve`.
* @see {ModuleLoader.setCustomizations}
* @type {Customizations}
*/
#customizations;

Expand Down Expand Up @@ -203,7 +227,7 @@ class ModuleLoader {
*
* Calling this function alters how modules are loaded and should be
* invoked with care.
* @param {object} customizations
* @param {Customizations} customizations
*/
setCustomizations(customizations) {
this.#customizations = customizations;
Expand Down Expand Up @@ -679,7 +703,7 @@ class ModuleLoader {
/**
* Similar to {@link resolve}, but the results are always synchronously returned. If there are any
* asynchronous resolve hooks from module.register(), it will block until the results are returned
* from the loader thread for this to be synchornous.
* from the loader thread for this to be synchronous.
* This is here to support `import.meta.resolve()`, `require()` in imported CJS, and
* `module.registerHooks()` hooks.
*
Expand Down