eslint-import-resolver-node 0.3.7 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +27 -28
  2. package/package.json +5 -4
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const resolve = require('resolve');
3
+ const resolve = require('resolve/sync');
4
4
  const isCoreModule = require('is-core-module');
5
5
  const path = require('path');
6
6
 
@@ -8,34 +8,13 @@ const log = require('debug')('eslint-plugin-import:resolver:node');
8
8
 
9
9
  exports.interfaceVersion = 2;
10
10
 
11
- exports.resolve = function (source, file, config) {
12
- log('Resolving:', source, 'from:', file);
13
- let resolvedPath;
14
-
15
- if (isCoreModule(source)) {
16
- log('resolved to core');
17
- return { found: true, path: null };
18
- }
19
-
20
- try {
21
- const cachedFilter = function (pkg, dir) { return packageFilter(pkg, dir, config); };
22
- resolvedPath = resolve.sync(source, opts(file, config, cachedFilter));
23
- log('Resolved to:', resolvedPath);
24
- return { found: true, path: resolvedPath };
25
- } catch (err) {
26
- log('resolve threw error:', err);
27
- return { found: false };
28
- }
29
- };
30
-
31
11
  function opts(file, config, packageFilter) {
32
- return Object.assign({
33
- // more closely matches Node (#333)
12
+ return Object.assign({ // more closely matches Node (#333)
34
13
  // plus 'mjs' for native modules! (#939)
35
14
  extensions: ['.mjs', '.js', '.json', '.node'],
36
- },
37
- config,
38
- {
15
+ // TODO: semver-major: remove this to match Node's default behavior
16
+ preserveSymlinks: true,
17
+ }, config, {
39
18
  // path.resolve will handle paths relative to CWD
40
19
  basedir: path.dirname(path.resolve(file)),
41
20
  packageFilter,
@@ -49,7 +28,7 @@ function packageFilter(pkg, dir, config) {
49
28
  const file = path.join(dir, 'dummy.js');
50
29
  if (pkg.module) {
51
30
  try {
52
- resolve.sync(String(pkg.module).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
31
+ resolve(String(pkg.module).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
53
32
  pkg.main = pkg.module;
54
33
  found = true;
55
34
  } catch (err) {
@@ -58,7 +37,7 @@ function packageFilter(pkg, dir, config) {
58
37
  }
59
38
  if (!found && pkg['jsnext:main']) {
60
39
  try {
61
- resolve.sync(String(pkg['jsnext:main']).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
40
+ resolve(String(pkg['jsnext:main']).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
62
41
  pkg.main = pkg['jsnext:main'];
63
42
  found = true;
64
43
  } catch (err) {
@@ -67,3 +46,23 @@ function packageFilter(pkg, dir, config) {
67
46
  }
68
47
  return pkg;
69
48
  }
49
+
50
+ exports.resolve = function (source, file, config) {
51
+ log('Resolving:', source, 'from:', file);
52
+ let resolvedPath;
53
+
54
+ if (isCoreModule(source)) {
55
+ log('resolved to core');
56
+ return { found: true, path: null };
57
+ }
58
+
59
+ try {
60
+ const cachedFilter = function (pkg, pkgFileOrDir, maybeDir) { return packageFilter(pkg, maybeDir || pkgFileOrDir, config); };
61
+ resolvedPath = resolve(source, opts(file, config, cachedFilter));
62
+ log('Resolved to:', resolvedPath);
63
+ return { found: true, path: resolvedPath };
64
+ } catch (err) {
65
+ log('resolve threw error:', err);
66
+ return { found: false };
67
+ }
68
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-import-resolver-node",
3
- "version": "0.3.7",
3
+ "version": "0.3.10",
4
4
  "description": "Node default behavior import resolution plugin for eslint-plugin-import.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/import-js/eslint-plugin-import"
16
+ "url": "https://github.com/import-js/eslint-plugin-import",
17
+ "directory": "resolvers/node"
17
18
  },
18
19
  "keywords": [
19
20
  "eslint",
@@ -30,8 +31,8 @@
30
31
  "homepage": "https://github.com/import-js/eslint-plugin-import",
31
32
  "dependencies": {
32
33
  "debug": "^3.2.7",
33
- "is-core-module": "^2.11.0",
34
- "resolve": "^1.22.1"
34
+ "is-core-module": "^2.16.1",
35
+ "resolve": "^2.0.0-next.6"
35
36
  },
36
37
  "devDependencies": {
37
38
  "chai": "^3.5.0",