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 41aaa18
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion resolvers/node/CHANGELOG.md
Expand Up @@ -4,10 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## Unreleased
### Added
- add `.node` extension ([#1663])

## v0.3.2 - 2018-01-05
### Added
- `.mjs` extension detected by default to support `experimental-modules` (#939)
- `.mjs` extension detected by default to support `experimental-modules` ([#939])

### Deps
- update `debug`, `resolve`
Expand Down Expand Up @@ -42,6 +44,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

[#438]: https://github.com/benmosher/eslint-plugin-import/pull/438

[#1663]: https://github.com/benmosher/eslint-plugin-import/issues/1663
[#939]: https://github.com/benmosher/eslint-plugin-import/issues/939
[#531]: https://github.com/benmosher/eslint-plugin-import/issues/531
[#437]: https://github.com/benmosher/eslint-plugin-import/issues/437
Expand Down
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 41aaa18

Please sign in to comment.