You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
resolve does not preserve require.extensions list and assumes only ['.js'] #137
Although we can achieve our needs with the previous tape issue/pr I feel it behoves resolve to use the default require.extensions list provided by node instead of only assuming ['.js'] here
Please advise and will have a PR & tests up ASAP as we need this or have to call off using tape and resolve. Can also enhance documentation which should close #134 which @ljharb, and @call-a3 are working on as well.
It should be noted that both NODE_PATH and require.extensions have been deprecated for years. They also do not affect the ESM resolution algorithm. I would recommend moving off of relying on their usage.
This way even if someone is on some ancient deprecated api that's technically superfluous to the intent of what the library is assumed to accomplish. Feels quite awkward one would have to pass in the standard require.extensions to override the default require resolve"extensions". P.O.L.A. is real.
Activity
ljharb commentedon Sep 22, 2017
This would be a breaking change;
require.extensionsstarts with.js,.json, and.node.You can certainly use
resolvewithrequire.extensionsvia theextensionsoption, however.TehShrike commentedon Sep 28, 2017
If this package's goal is to implement the node.js
require.resolve()algorithm, isn't this something that should be fixed?Using a truncated default extensions list makes this library default to non-node-like behavior.
Packages like
gotthatrequire('./package')will break when bundled by bundlers that usenode-resolve(which is all bundlers that I'm aware of).bmeck commentedon Sep 28, 2017
It should be noted that both
NODE_PATHandrequire.extensionshave been deprecated for years. They also do not affect the ESM resolution algorithm. I would recommend moving off of relying on their usage.TehShrike commentedon Sep 28, 2017
That makes sense to me. Changing the hardcoded default to match the extensions given in the docs seems preferable.
snuggs commentedon Sep 29, 2017
@TehShrike hence https://github.com/browserify/resolve/pull/138/files
This way even if someone is on some ancient deprecated api that's technically superfluous to the intent of what the library is assumed to accomplish. Feels quite awkward one would have to pass in the standard
require.extensionsto override the default requireresolve"extensions". P.O.L.A. is real.Update default extensions to match node
TehShrike commentedon Mar 7, 2018
Interested parties should go review #145.
Update default extensions to match node
ljharb commentedon Jun 16, 2018
Closing this in favor of #166, to centralize further discussion.