resolve does not preserve `require.extensions` list and assumes only ['.js']
See original GitHub issueGreetings!
Having a situation where we are using tape which does not pass extensions
to resolve. Have opened an issue here https://github.com/substack/tape/issues/395
That being said our situation is we use the .es
ECMAScript extension with the following:
require.extensions ['.es'] = require.extensions ['.js']
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 https://github.com/browserify/resolve/blob/5f6e682396eca043624d0a13286b9015b1e6cfce/lib/sync.js#L23.
An easy enhancement would be to convert:
var extensions = opts.extensions || ['.js'];
to
var extensions = opts.extensions
|| Object.keys (require.extensions)
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 https://github.com/browserify/resolve/issues/134 which @ljharb, and @call-a3 are working on as well.
Thanks in advance! /cc @brandondees
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
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
got
thatrequire('./package')
will break when bundled by bundlers that usenode-resolve
(which is all bundlers that I’m aware of).I think it’s good to not rely too heavily on global runtime vars to configure default values. The whole point of this package instead of using
require.resolve()
is that you can configure its behavior without mutating the global runtime environment variables.