-
Notifications
You must be signed in to change notification settings - Fork 152
Add <BUILTIN_MODULES> option for Node.js builtin modules #381
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 <BUILTIN_MODULES> option for Node.js builtin modules #381
Conversation
|
Hello @sdotson! I really like this feature, I think it might be useful. I'm wondering, is it possible to keep only
otherwise they wouldn't mention it in |
04430bd to
010ca09
Compare
6701be2 to
2437b97
Compare
Had a few hiccups with the v6 branch but I think everything is good now @vladislavarsenev |
|
Thank you for the changes! In order to merge, could you please perform |
Sure thing |
|
Merged it, thank you @sdotson! |
Description
Implements the feature requested in #71 to add support for sorting Node.js builtin modules using the
<BUILTIN_MODULES>placeholder in theimportOrderarray.This PR introduces support for the
<BUILTIN_MODULES>special word that allows users to explicitly control where Node.js builtin modules (both traditionalfs,pathetc. and newnode:fs,node:pathprefixed variants) appear in their import order.Changes
<BUILTIN_MODULES>placeholder for use inimportOrderarraymodule.builtinModulesfs) and modern (node:fs) import stylesImplementation Details
require('module').builtinModulesto identify all Node.js builtin modulesfsandnode:fsimport formats<BUILTIN_MODULES>is included inimportOrderExample Usage
Builtin modules at the top:
{ "importOrder": ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^@core/(.*)$", "^[./]"], "importOrderSeparation": true, "importOrderSortSpecifiers": true }Builtin modules after third-party:
{ "importOrder": ["<THIRD_PARTY_MODULES>", "<BUILTIN_MODULES>", "^@core/(.*)$", "^[./]"] }Before:
After (with builtin modules at top):
Testing
node:prefixed importsBackward Compatibility
This change is fully backward compatible:
<BUILTIN_MODULES>inimportOrder, builtin modules are treated as regular third-party importsDocumentation
.jsextensions for ESM compatibility (v6)Fixes #71
Checklist