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

doc: correct customization hook types & clarify descriptions #56454

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

Conversation

JakobJingleheimer
Copy link
Member

No description provided.

@JakobJingleheimer JakobJingleheimer added doc Issues and PRs related to the documentations. fast-track PRs that do not need to wait for 48 hours to land. loaders Issues and PRs related to ES module loaders labels Jan 3, 2025
@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 Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Fast-track has been requested by @JakobJingleheimer. Please 👍 to approve.

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.54%. Comparing base (19d58c5) to head (8af2410).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #56454   +/-   ##
=======================================
  Coverage   88.53%   88.54%           
=======================================
  Files         657      657           
  Lines      190724   190788   +64     
  Branches    36600    36613   +13     
=======================================
+ Hits       168867   168924   +57     
- Misses      15031    15043   +12     
+ Partials     6826     6821    -5     
Files with missing lines Coverage Δ
lib/internal/modules/customization_hooks.js 100.00% <100.00%> (ø)

... and 42 files with indirect coverage changes

@@ -1143,12 +1143,13 @@ changes:
* `context` {Object}
* `conditions` {string\[]} Export conditions of the relevant `package.json`
* `format` {string|null|undefined} The format optionally supplied by the
`resolve` hook chain
`resolve` hook chain. This can be any string value, not necessarily a valid return value.
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 a bit confusing... in particular the second part.

Copy link
Member Author

@JakobJingleheimer JakobJingleheimer Jan 3, 2025

Choose a reason for hiding this comment

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

format is both an input and an output of this function. The input is not necessarily a valid output.

This comment was marked as resolved.

This comment was marked as resolved.

ignored)
`'builtin' | 'commonjs' | 'json' | 'module' | 'wasm'`
* `format` {string|null|undefined} A hint to the `load` hook (it might be ignored). It can be any
string value (`'css'`, `'yaml'`, etc).
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit odd to offer examples of formats that Node doesn't support. Maybe use only supported ones, or write something like "string value (supported such as json or unsupported such as css)"?

Copy link
Contributor

Choose a reason for hiding this comment

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

"This would commonly be a [module format](link to the module formats table), but could also be any arbitrary string."

Copy link
Member Author

@JakobJingleheimer JakobJingleheimer Jan 4, 2025

Choose a reason for hiding this comment

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

It seems a bit odd to offer examples of formats that Node doesn't support.

Actually, it's the opposite—it's the purpose of this feature: One of the main utilities of loaders is to extend what node can support. It's actually far less common to set ResolveFnOutput.format to a module format.

But how about

  * `format` {string|null|undefined} A hint to the `load` hook (it might be ignored). It can be a
     module format (such as `'commonjs'` or `'module'`) or an arbitrary value like `'css'` or `'yaml'`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fast-track PRs that do not need to wait for 48 hours to land. loaders Issues and PRs related to ES module loaders 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.

5 participants