-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Update default extensions to match node #145
base: main
Are you sure you want to change the base?
Conversation
Extension list sourced from https://nodejs.org/api/modules.html#modules_file_modules Fixes browserify#137
This overlaps with #20 - #20 (comment) may be relevant here. |
Given @substack and @bmeck's comments in #137, I think this is the preferred approach over using
Anyone else want to chime in/review? |
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 is not my preferred approach; either it should stay as-is, or it should dynamically look up require.extensions.
If the docs are incorrect, let’s fix them.
What's your reasoning? The readme says "implements the node
|
The require.resolve algorithm depends on the runtime value of Hardcoding the array is a breaking change that also isn't consistent with require.resolve, so I see no value in ever doing that. |
Not supporting a mutable The issue is that the default value for this module's I agree with the other commenters in #137 that inferring defaults from a global mutable is a bad idea. The fix for the bug is to align this package's defaults with node's defaults. |
The fix for the bug is to make the package behave the same way node does, which means dynamically looking up require.extensions. I'm going to continue to block any change to this package's defaults that aren't changing it to |
The issue is that the default value for this module's extensions option is different from node's default module resolution extensions. Agreed. So basically this package doesn't do what it claims to do. YES? Either it uses module load strategy or it doesn't. And as @TehShrike pointed out it doesn't therefore even the name of the library is out of touch. Not being a curmudgeon by any means. But facts don't seem to care about our opinions. Is there another library out there I can use? It's not my fault companies decided to use a (now) deprecated feature as an early node supporter. I still have to deal with this and I'd have to drop tape due to resolve and I <3 BOTH projects. /cc @ljharb |
A new module could be published, |
Yes I don't think @ljharb realizes how serious this is For people using both tools. For instance is BLOOMBERG right for using I feel a strawman is being thrown up telling people HOW they should write their code when the real issue after all is a project named I can close whatever in respective repos as the client has moved on from resolve and tape. Unfortunate but I'd still make the changes. With people revisiting their resolution strategies (much to do with ESM / On second thought |
The browserify issue is a different one; anyone who's using The issue here is deciding which of the following is preferable:
My preference between 2 and 3 is decidedly "3". My overall preference is to avoid breaking changes - which cause pain for users - when they are not sufficiently motivated. I'm not yet convinced that "pedantically matching node's resolve algorithm" is actually useful enough to warrant the breaking change. |
"pedantically matching node's resolve algorithm" is the whole point of this package. |
A breaking change to do what this library actually says the name says it does is a worthy change in my book. At least have the readme say otherwise as you suggested. Trust me I can definitely pick up what you are laying down as well @ljharb. Like I said I no longer have a dog in the fight. People who use tape will have their hands tied behind their backs tho...if they're concerned about file extensions. Seems to be a hot topic these days. I'd prepare. |
P.S. To be clear I still feel @TehShrike's work SHOULD be merged in. After all we are simply devs who just want to use this library and nothing more. I thought the whole point of this project was to help people who had some janky legacy resolution coding to maintain without choice...I'm guilty as charged. Please let me know what to do with my respective issues/PR @ljharb. |
Extension list sourced from https://nodejs.org/api/modules.html#modules_file_modules Fixes browserify#137
59c4cd8
to
a578a0f
Compare
@TehShrike I haven't changed my position; but for this PR to be merged, it would need tests that would fail without the change. |
@ljharb FWIW I know you mentioned earlier awaiting node progress. However to your point in the comment above would it be ok to do an extension lookup Thanks in advance. 🙏 |
Added some tests. Let me know if they seem insufficient. |
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 think it's also useful to have a test with a foo.js
, foo.node
, and foo.json
, and specify which one gets picked with both 1) default extensions and 2) a list of two of them. I'd then want to merge that test into master, so that this PR's diff would illustrate the breaking change.
Ah yeah, asserting default extension order makes sense
Josh
…________________________________
From: Jordan Harband <notifications@github.com>
Sent: Tuesday, September 11, 2018 18:16
To: browserify/resolve
Cc: Josh Duff; Mention
Subject: Re: [browserify/resolve] Update default extensions to match node (#145)
@ljharb commented on this pull request.
I think it's also useful to have a test with a foo.js, foo.node, and foo.json, and specify which one gets picked with both 1) default extensions and 2) a list of two of them. I'd then want to merge that test into master, so that this PR's diff would illustrate the breaking change.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#145 (review)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABFsbW_xCsx_CMDZCt3LvyoHzRxlvIWfks5uaEQwgaJpZM4RTcwU>.
|
This fixes an issue where
browserify
/resolve
's default behavior does not match node's behavior.Per the discussion in #137, I updated the hardcoded list of extensions instead of sourcing it from some global.
Extension list sourced from https://nodejs.org/api/modules.html#modules_file_modules
Fixes #137. Closes #138. Closes #20. Closes #166.