Skip to content

Commit

Permalink
resolvers/node: [New] add .node extension
Browse files Browse the repository at this point in the history
Fixes #802
  • Loading branch information
ljharb committed Feb 18, 2020
1 parent 12971f5 commit a1af591
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resolvers/node/index.js
Expand Up @@ -28,7 +28,7 @@ function opts(file, config) {
return Object.assign({
// more closely matches Node (#333)
// plus 'mjs' for native modules! (#939)
extensions: ['.mjs', '.js', '.json'],
extensions: ['.mjs', '.js', '.json', '.node'],
},
config,
{
Expand Down
Empty file.
Empty file added resolvers/node/test/native.node
Empty file.
13 changes: 12 additions & 1 deletion resolvers/node/test/paths.js
Expand Up @@ -40,10 +40,21 @@ describe("default options", function () {
.equal(path.resolve(__dirname, './native.mjs'))
})

it("finds .node modules, with lowest precedence", function () {
expect(node.resolve('./native.node', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './native.node'))
})

it("finds .node modules", function () {
expect(node.resolve('./dot-node', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './dot-node.node'))
})

it("still finds .js if explicit", function () {
expect(node.resolve('./native.js', './test/file.js'))
.to.have.property('path')
.equal(path.resolve(__dirname, './native.js'))
})

})

0 comments on commit a1af591

Please sign in to comment.