Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update default extensions to match node#145

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
TehShrike wants to merge6 commits intobrowserify:main
base:main
Choose a base branch
Loading
fromTehShrike:default-extensions

Conversation

@TehShrike
Copy link

@TehShrikeTehShrike commentedJan 4, 2018
edited by ljharb
Loading

This fixes an issue wherebrowserify/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 fromhttps://nodejs.org/api/modules.html#modules_file_modules

Fixes#137.Closes#138.Closes#20.Closes#166.

@ljharb
Copy link
Member

This overlaps with#20 -#20 (comment) may be relevant here.

@TehShrike
Copy link
Author

require.extensions is used in#138 - this pull request replaces#138 per the discussion in#137, where substack and bmeck recommend against relying on the global.

snuggs reacted with thumbs up emoji

@TehShrike
Copy link
Author

Given @substack and@bmeck's comments in#137, I think this is the preferred approach over usingrequire.extensions.

require.extensions has been deprecated since 0.10.6:https://nodejs.org/api/modules.html#modules_require_extensions

Anyone else want to chime in/review?

Copy link
Member

@ljharbljharb left a 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.

@TehShrike
Copy link
Author

What's your reasoning?

The readme says "implements the noderequire.resolve() algorithm". Changing the readme would not change the fact that this functionality is what people expect this module to provide. The current behavior is a bug. Leaving it as-is is undesirable.

require.extensions is deprecated, and the few other people who have chimed in so far discouraged using it. I would rather we referencedrequire.extensions than leave this bug, but I don't see howrequire.extensions is the better choice over hard-coding the array to match node's documentation.

snuggs reacted with heart emoji

@ljharb
Copy link
Member

ljharb commentedMar 7, 2018
edited
Loading

The require.resolve algorithm depends on the runtime value ofrequire.extensions; deprecated or not, it will NEVER be removed from CJS.

Hardcoding the array is a breaking change thatalso isn't consistent with require.resolve, so I see no value in ever doing that.

@TehShrike
Copy link
Author

Not supporting a mutablerequire.extensions is not what is causing all of the issues that users are experiencing.

The issue is that the default value for this module'sextensions option is different from node's default module resolution extensions.

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.

snuggs reacted with heart emoji

@ljharb
Copy link
Member

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 torequire.extensions (which I think isn't going to be worth the break, so I don't want to change that either).

TehShrike reacted with confused emoji

@snuggs
Copy link

Not supporting a mutable require.extensions is not what is causing all of the issues that users are experiencing.

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

@TehShrike
Copy link
Author

Is there another library out there I can use?

A new module could be published,actually-node-resolve that would just export this module, but overriding the default value ofextensions to['.js', '.json', '.node'].

@snuggs
Copy link

snuggs commentedMar 15, 2018
edited
Loading

Yes I don't think@ljharb realizeshow serious this is

For people using both tools. For instance is BLOOMBERG right for usingapplication/ecmascript in some libraries? That's debatable. As long as those mime types are in the HTML list of valid Javascript Mime types. Even though much of the world STILL usestext/javascript which is not only outdated and was labeled asOBSOLETE but is the "defacto" mime type in the HTML spec (although not even this very site we are on abides).

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 namedresolve doesn't even use the Noderesolve algorithm. I literally had a company state "this issue clearly shows the lib doesn't do what it says it does. It breaks our compliance and we can't use it as you suggested."

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 /.mjs) there will be many (MANY) apps that have no issue divorcing from poor resolver strategies. It's already happening. True may be a breaking change but the reality is the ability to pass extensions was the feature/bug that's causing the problems in the first place.

On second thoughtactually-node-resolve isn't a bad idea@TehShrike. Would have saved two clients I have mandated by SEC from abandoning project. "What kind of 'resolve' is this because it's not node's" Became a louder cry recently than me saying "But you touchedrequire.extensions?"

@ljharb
Copy link
Member

The browserify issue is a different one; anyone who's usingresolve directly can, and should, pass their own list of extensions - whether that'srequire.extensions, or['.es'], or whatever you like. No direct consumer ofresolve is blocked, in any way, from making it behave the way they like.

The issue here is deciding which of the following is preferable:

  1. no change; consumers ofresolve continue to provide a manual list of extensions as they like
  2. change the default to a hardcoded list of the initial value ofrequire.extensions; this is a breaking change, sosome group of users will have tostart providing a manual list of extensions. Anyone that mutatesrequire.extensions (bad practice or not) will also have to provide a manual list of extensions.
  3. change the default to a dynamic lookup ofrequire.extensions. this is also a breaking change, but fewer users than in the previous option will have to provide a manual list of extensions.

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.

@TehShrike
Copy link
Author

"pedantically matching node's resolve algorithm" is the whole point of this package.

@snuggs
Copy link

snuggs commentedMar 15, 2018
edited
Loading

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.

@snuggs
Copy link

snuggs commentedMar 15, 2018
edited
Loading

P.S. To be clear I still feel@TehShrike's workSHOULD 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.

@ljharb
Copy link
Member

@TehShrike I haven't changed my position; but for this PR to be merged, it would need tests that would fail without the change.

@snuggs
Copy link

snuggs commentedJul 11, 2018
edited
Loading

@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|| array matching node docs as per your request? Would like to ensure this goes off without a hitch. Seems like no response so can either add commit to this branch or mirror another. At minimum something must be done with conflict toreadme.markdown

Thanks in advance. 🙏

@TehShrike
Copy link
Author

Added some tests. Let me know if they seem insufficient.

ljharb reacted with thumbs up emoji

Copy link
Member

@ljharbljharb left a 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 afoo.js,foo.node, andfoo.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.

@TehShrike
Copy link
Author

TehShrike commentedSep 11, 2018 via email

Ah yeah, asserting default extension order makes senseJosh
________________________________From: Jordan Harband <notifications@github.com>Sent: Tuesday, September 11, 2018 18:16To: browserify/resolveCc: Josh Duff; MentionSubject: 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>.
ljharb reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ljharbljharbljharb requested changes

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

central issue for "default extensions" resolve does not preserverequire.extensions list and assumes only ['.js']

3 participants

@TehShrike@ljharb@snuggs

[8]ページ先頭

©2009-2025 Movatter.jp