refactor: use node: like module specifier for built-in modules.#228973
refactor: use node: like module specifier for built-in modules.#228973Cecil0o0 wants to merge 2 commits intomicrosoft:mainfrom
node: like module specifier for built-in modules.#228973Conversation
node: like module specifier.node: like module specifier for built-in modules.
|
Hm, but if we decide that is the right way forward, this would have to be changed across all our TypeScript files including extensions? Thats a ton of files to go through 🤔 |
|
@bpasero I believe we can use both styles of import side-by-side. The main benefit I recall is that Not sure it's worth making a widespread effort to adopt right now though |
|
After read comments, I feel sorry for my unclear description for this pr in my first comment above, I just modified the content, for convenience reason, the main changes and relative reason were concluded below: reason: On the other hand, reason: the scope of this pr may only involve the files that I have already saw, not bigger scope at the moment when I created the pr. |
|
Thanks for following up @Cecil0o0 It sounds like this change is being made for style reasons. I don't think there's enough benefit to make this change. We may revisit this with a larger pass in the future but this is not a priority at this time |


node:prefix used to distinguish whether module is builtin or not, such as module specifier "node:url" represents module "url" inside the Node.js instead of outside.The problem is that use
legacyambiguous module specifier for built-in module, there is a bit morefasionspecific way to specify a built-in module, and which is recommended by Node.js also, like below:such as code from Node.js official website.

and code(in comments) from DefinitelyTyped project.

Here source code at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/url.d.ts#L6
This pr would like to fix that above for improving a bit more readability of module specifier of built-in modulesThis pr would like to make them obviously for representation as built-in modules of Node.js, instead of modules from some registry by package manager.