@putout/plugin-esm 7.7.1 → 8.0.1

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');
@@ -29,7 +29,7 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
29
29
  if (importsCache.has(dir))
30
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);
@@ -45,6 +45,7 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
45
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
 
@@ -21,7 +21,10 @@ const {
21
21
 
22
22
  const getMessage = (a) => a.message;
23
23
 
24
- export const report = (file, {from, to}) => `Shorten import source: '${from}' -> '${to}'`;
24
+ export const report = (file, {from, to}) => {
25
+ const name = getFilename(file);
26
+ return `Shorten import source: '${from}' -> '${to}' in '${name}'`;
27
+ };
25
28
  export const fix = (file, {content, ast, from, to}) => {
26
29
  transform(ast, content, {
27
30
  rules: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-esm",
3
- "version": "7.7.1",
3
+ "version": "8.0.1",
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",