-
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
doc: add Customization section and subsections to related sub systems #50419
doc: add Customization section and subsections to related sub systems #50419
Conversation
Review requested:
|
@GeoffreyBooth I checked npm, and there are currently no packages registered with the keyword |
f7d823d
to
84ee8d7
Compare
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.
If we’re standardizing on nodejs-plugin
for the package.json
keywords
field, then why is the standardized export nodejs-customization
? Shouldn’t these be the same?
I don’t think we should involve --env-file
in this unless we land a semver-major change to go out in a future version of Node that automatically loads .env
. Otherwise it’s just an extra step with no purpose, and you could cut it out and replace the “use --env-file=.env
“ part with “use --import nodejs-plugin/nodejs-customization
“. Also because I think it’s likely that we build on --env-file
to add support for a legit config file, such as one in JSON, and that would be a better place to persist this than in an .env
file; especially if a future version of Node autoloads that config file.
doc/api/customization.md
Outdated
|
||
> Stability: 1.0 - Early development | ||
|
||
Node.js has multiple APIs for customizing behaviour and can easily be invoked |
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.
Node.js has multiple APIs for customizing behaviour and can easily be invoked | |
Node.js has multiple APIs for customizing behavior and can easily be invoked |
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.
Gah. I think VS Code uses my system language for spell check. (This project has confused the heck outta spell check on my iPhone)
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.
I use this extension: https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker
It allows you to have custom settings by workspace, so you can create a Node workspace and configure cSpell
within that workspace to use US English.
doc/api/customization.md
Outdated
support it provides; for a plugin extending support for typescript would contain | ||
`typescript` in its keywords; avoid red-herrings such as `typescript` as a | ||
keyword when the library does not extend support for typescript but is merely | ||
itself written in typescript. Failing to avoid these red-herrings will cause |
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.
support it provides; for a plugin extending support for typescript would contain | |
`typescript` in its keywords; avoid red-herrings such as `typescript` as a | |
keyword when the library does not extend support for typescript but is merely | |
itself written in typescript. Failing to avoid these red-herrings will cause | |
support it provides; a plugin adding Node.js support for TypeScript should contain | |
`typescript` in its keywords, to avoid matches such as `typescript` as a | |
keyword when the library does not add support for TypeScript but is merely | |
itself written in TypeScript. Using nonstandard keywords will cause |
itself written in typescript. Failing to avoid these red-herrings will cause | ||
your package to be listed for things it does not do, aggravating users. | ||
|
||
These steps configure Node.js with a customization plugin: |
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 section mixes instructions for package authors writing a plugin with instructions for using such a plugin. I feel like those should be separate sections, as end users aren’t going to care about how a plugin should be authored.
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.
I'll add a heading ("Setting up a plugin") between 28 and 30
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.
We should probably put the “Using a plugin” section first, as it applies to more people. (Not sure if “setting up” means authoring or consuming.)
doc/api/customization.md
Outdated
search`][], as well as a website. | ||
1. Once installed, in order to get Node.js to automatically use it, create a | ||
[`.env`][`--env-file`] file containing an [`--import`][] for your chosen | ||
plugin, like `NODE_OPTIONS="--import=example-nodejs-plugin"`. |
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.
If we’re using the standardized export that you mentioned above, this would be
plugin, like `NODE_OPTIONS="--import=example-nodejs-plugin"`. | |
plugin, like `NODE_OPTIONS="--import=example-nodejs-plugin/nodejs-customization"`. |
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.
OH!! Actually, this is an interesting point, and I think absolves us from a not-great entry-point name: We "control" this --import
, so if the --import
itself specifies the entry-point, I think that means it's safe to use whatever we want (so this would be okay):
{
"name": "example-nodejs-plugin",
"exports": {
"register": "whatever.mjs"
},
"keywords": ["nodejs-plugin", "…"]
}
NODE_OPTIONS="--import=example-nodejs-plugin/register"
The problem before would exist if node automatically calls the entry-point whenever any package is --import
ed; but if we include the entry-point in the --import
's specifier, then we're safe (and this only happens when the user manually puts it there, or in future, when the wizard automates it).
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.
Right, but that’s also why it’s not that important that it be standardized. I think the only benefit of standardization is so that the wizard we eventually create knows what export to use.
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.
[…] the wizard we eventually create knows what export to use.
Yes, exactly.
doc/api/module.md
Outdated
|
||
* A [`resolve` hook][resolve hook] that sets `format` for applicable modules to | ||
the format it handles, such as `'typescript'`. | ||
* A [`load` hook][load hook] that transpiles the external format (as signalled |
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.
* A [`load` hook][load hook] that transpiles the external format (as signalled | |
* A [`load` hook][load hook] that transpiles the external format (as signaled |
RE AFAIK, there is no design or implementation in progress (only some stalled discussions) to support a different kind of config file. |
There’s no design or implementation in progress for automatically loading |
True. But it's what we've got, which is better than what we don't. I think it's still a better experience. I added both options with explanations for both. |
I think these instructions need to be essentially the algorithm for the wizard; the wizard just automates these steps. And what if the user already has a |
Yes, that is the intention. Yet you keep suggesting/requesting things that are contrary to that. I imagine we would need a util that reads the current |
Setting the keyword `nodejs-plugin` is important for users to find the | ||
package (which may be automated). It should also contain the official name(s) | ||
for the support it provides; a plugin extending Node.js support for TypeScript | ||
should contain `typescript` in its keywords; a customization package that does | ||
not extend Node.js support for TypeScript should not contain `typescript` (such | ||
as when the library is itself merely written in TypeScript). Incorrect keywords | ||
will cause a package to be listed for things it does not do, aggravating users. |
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.
nit: I'm not fan of documenting non-technical patterns in the Node documentation.
Adding the npm keyword is useless from a technical perspective, whether users want to use them or not is more a subjective guideline than a "you must do this for the loader to be compatible with Node.js".
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.
The plan is that it would be a requirement for the wizard we plan to build, so that the wizard can find packages to suggest. But to your point, perhaps it’s better to exclude this until the wizard actually exists, and any steps that are required specifically for wizard compatibility (as opposed to general Node compatibility) could be added later as part of the PR that adds the wizard.
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.
I'm not fan of documenting non-technical patterns in the Node documentation.
@arcanis are you talking about this part?
Incorrect keywords will cause a package to be listed for things it does not do, aggravating users.
I'm trying to avoid users complaining (to node) of erroneous results from authors throwing in red-herrings.
What is described here is critical for the automated process (in whatever form). To limit changes for authors, these instructions need to be available as soon as possible.
Adding the npm keyword is useless from a technical perspective, whether users want to use them or not is more a subjective guideline than a "you must do this for the loader to be compatible with Node.js".
I'm confused—this seems to directly contradict what you told me:
I think uses the npm tags as part of the search, so if all loaders have similar tags that will probably help
So unless what Geoffrey said above (that tags are just keywords lifted from package.json) is incorrect, this is necessary. Or have I missed something completely?
The tag needs to be "claimed" immediately, regardless of how it gets there.
1. Install the plugin via your preferred package manager. For finding the | ||
plugin, package managers provide often a CLI utility, such as [`npm | ||
search`][], as well as a website. | ||
2. Once installed, in order to get Node.js to use it, you have 2 options: |
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.
A third option for Yarn users is to add the NODE_OPTIONS
variable to .env.yarn
, which gets automatically injected into all yarn node
calls.
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.
Hmm, this may be more convenient, but if it works for only a minority of uses, I think it would be better for node to have 1 implementation that works for all.
No, I’m suggesting that it be simplified as much as possible, so that a wizard can achieve it. Adding The definitive source of how an app is run is the This also covers adding support for tests but possibly not for production, say, like if the user wants this support added to a Alternatively we can expand on |
Huh? That's not true at all O.o
Users so inclined can merely do in lieu of specifying
That sounds mostly six of one, half a dozen of the other, with the pjson scripts route slightly more complicated. But if that gets this feature landed, I'm very content to accept that and end these months of wheel-spinning.
IMO that would be the ideal. I remember there were several enthusiastic advocates of this during the discussions for |
This is a split from #49704 with just doc updates (the code change in 49704 will subsequently require 1 more sentence added to the docs added here).