@putout/plugin-esm 7.7.0 → 8.0.0

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.
@@ -104,7 +104,7 @@ const createGetPackageType = (importsCache = new Map()) => (file) => {
104
104
  if (importsCache.has(dir))
105
105
  return importsCache.get(dir);
106
106
 
107
- const [, packagePath] = findFileUp(file, 'package.json');
107
+ const packagePath = findFileUp(file, 'package.json');
108
108
 
109
109
  if (!packagePath) {
110
110
  importsCache.set(dir, 'commonjs');
@@ -63,7 +63,7 @@ export const scan = (rootPath, {push, trackFile}) => {
63
63
 
64
64
  const importsTuples = getImports(file, content, ast);
65
65
 
66
- const [, privateImports] = getPrivateImports(file, {
66
+ const privateImports = getPrivateImports(file, {
67
67
  aliasBased: true,
68
68
  });
69
69
 
@@ -50,7 +50,7 @@ export const scan = (rootPath, {push, trackFile}) => {
50
50
  if (!content.includes('import'))
51
51
  continue;
52
52
 
53
- const [, privateImports] = getPrivateImports(file);
53
+ const privateImports = getPrivateImports(file);
54
54
 
55
55
  if (!privateImports.size)
56
56
  continue;
@@ -27,13 +27,13 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
27
27
  const {aliasBased = false} = options;
28
28
 
29
29
  if (importsCache.has(dir))
30
- return [dir, importsCache.get(dir)];
30
+ return importsCache.get(dir);
31
31
 
32
- const [packageDirectory, packagePath] = findFileUp(file, 'package.json');
32
+ const packagePath = findFileUp(file, 'package.json');
33
33
 
34
34
  if (!packagePath) {
35
35
  importsCache.set(dir, emptyMap);
36
- return ['', emptyMap];
36
+ return emptyMap;
37
37
  }
38
38
 
39
39
  const packageContent = readFileContent(packagePath);
@@ -42,9 +42,10 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
42
42
  if (error) {
43
43
  importsCache.set(dir, emptyMap);
44
44
 
45
- return ['', emptyMap];
45
+ return emptyMap;
46
46
  }
47
47
 
48
+ const packageDirectory = dirname(getFilename(packagePath));
48
49
  const {imports = {}} = packageJson;
49
50
  const importsEntries = new Map();
50
51
 
@@ -62,9 +63,9 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
62
63
  });
63
64
  }
64
65
 
65
- importsCache.set(packageDirectory, importsEntries);
66
+ importsCache.set(dir, importsEntries);
66
67
 
67
- return [packageDirectory, importsEntries];
68
+ return importsEntries;
68
69
  };
69
70
 
70
71
  function parseProperty(property) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-esm",
3
- "version": "7.7.0",
3
+ "version": "8.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin improves ability to transform ESM code",