-
Notifications
You must be signed in to change notification settings - Fork 3k
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
implement require.extensions
#18478
implement require.extensions
#18478
Conversation
Updated 6:23 PM PT - Mar 26th, 2025
✅ @paperclover, your commit 965794b5fceaaf7975f16cd01aa9b65dc03cd9f9 passed in 🧪 try this PR locally: bunx bun-pr 18478 |
this will be rewritten to not use ProxyObject |
the pr is reworked to not use a ProxyObject. instead of fixing issues in the direct calls, i have removed those implementations as i do not think it is important to support. |
a58dabc
to
fc93602
Compare
auto* name = propertyName.publicName(); | ||
if (!name->startsWith("."_s)) return; | ||
BunString ext = Bun::toString(name); | ||
uint32_t kind = 0; |
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 should be an enum
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 chose not to use an enum because it is used for a single parameter in one very specific function. the enum would have to be manually transcribed anyways, so it doesn't make it safer (until we get translate-c++)
const i = bun.strings.indexOfCharPos(basename, '.', next) orelse | ||
return null; | ||
next = i + 1; | ||
if (i == 0) continue; |
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.
should this i == 0
check be deleted? "foo/.bar"
won't get a custom function if i'm understanding correctly
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 have had it hit. this is also a closer port to what node does here
This reverts commit 70ddfb5.
Closes #15795
Closes #15566
See BUN-11234
Closes BUN-11893
Closes BUN-11705
Closes Unitech/pm2#5964
require.extensions
now contains the newly added extensions that Node 22-23 addsrequire.extensions
can be mutated to affect resolution and module loadingextensions['.js']
,extensions['.json']
, or another into a new extension will add a fast path