@putout/plugin-esm 7.3.0 → 7.4.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.
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
} from 'putout';
|
|
9
9
|
import * as getImports from '#get-imports';
|
|
10
10
|
import * as changeImports from '#change-imports';
|
|
11
|
-
import {findPackage} from '#find-package';
|
|
12
11
|
|
|
13
12
|
const {
|
|
14
13
|
getFilename,
|
|
15
14
|
readFileContent,
|
|
16
15
|
writeFileContent,
|
|
16
|
+
findFileUp,
|
|
17
17
|
} = operator;
|
|
18
18
|
|
|
19
19
|
const {parse: parseJson} = JSON;
|
|
@@ -101,7 +101,7 @@ const createGetPackageType = (importsCache = new Map()) => (file) => {
|
|
|
101
101
|
if (importsCache.has(dir))
|
|
102
102
|
return importsCache.get(dir);
|
|
103
103
|
|
|
104
|
-
const [, packagePath] =
|
|
104
|
+
const [, packagePath] = findFileUp(file, 'package.json');
|
|
105
105
|
|
|
106
106
|
if (!packagePath) {
|
|
107
107
|
importsCache.set(dir, 'commonjs');
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from 'putout';
|
|
13
13
|
import * as getImports from '#get-imports';
|
|
14
14
|
import * as changeImports from '#change-imports';
|
|
15
|
-
import {findPackage} from '#find-package';
|
|
16
15
|
|
|
17
16
|
const isString = (a) => typeof a === 'string';
|
|
18
17
|
|
|
@@ -20,6 +19,7 @@ const {
|
|
|
20
19
|
getFilename,
|
|
21
20
|
readFileContent,
|
|
22
21
|
writeFileContent,
|
|
22
|
+
findFileUp,
|
|
23
23
|
} = operator;
|
|
24
24
|
|
|
25
25
|
const {entries} = Object;
|
|
@@ -99,7 +99,7 @@ const createGetPrivateImports = (importsCache = new Map(), emptyMap = new Map())
|
|
|
99
99
|
if (importsCache.has(dir))
|
|
100
100
|
return [dir, importsCache.get(dir)];
|
|
101
101
|
|
|
102
|
-
const [packageDirectory, packagePath] =
|
|
102
|
+
const [packageDirectory, packagePath] = findFileUp(file, 'package.json');
|
|
103
103
|
|
|
104
104
|
if (!packagePath) {
|
|
105
105
|
importsCache.set(dir, {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-esm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.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",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"imports": {
|
|
14
14
|
"#get-imports": "./lib/shorten-imported-file/get-imports/index.js",
|
|
15
|
-
"#change-imports": "./lib/resolve-imported-file/change-imports/index.js"
|
|
16
|
-
"#find-package": "./lib/apply-privately-imported-file/find-package.js"
|
|
15
|
+
"#change-imports": "./lib/resolve-imported-file/change-imports/index.js"
|
|
17
16
|
},
|
|
18
17
|
"release": false,
|
|
19
18
|
"tag": false,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {operator} from 'putout';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
getFileType,
|
|
5
|
-
readDirectory,
|
|
6
|
-
getFilename,
|
|
7
|
-
getParentDirectory,
|
|
8
|
-
} = operator;
|
|
9
|
-
|
|
10
|
-
export const findPackage = (file) => {
|
|
11
|
-
const parentDirectory = getParentDirectory(file);
|
|
12
|
-
|
|
13
|
-
if (!parentDirectory)
|
|
14
|
-
return [];
|
|
15
|
-
|
|
16
|
-
const directoryName = getFilename(parentDirectory);
|
|
17
|
-
|
|
18
|
-
for (const currentFile of readDirectory(parentDirectory)) {
|
|
19
|
-
const type = getFileType(currentFile);
|
|
20
|
-
|
|
21
|
-
if (type === 'directory')
|
|
22
|
-
continue;
|
|
23
|
-
|
|
24
|
-
const currentName = getFilename(currentFile);
|
|
25
|
-
|
|
26
|
-
if (currentName.endsWith('package.json'))
|
|
27
|
-
return [directoryName, currentFile];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return findPackage(parentDirectory);
|
|
31
|
-
};
|