@putout/plugin-esm 10.0.2 → 10.1.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.
- package/lib/apply-privately-imported-file/index.js +3 -5
- package/lib/resolve-imported-file/change-imports/index.js +2 -0
- package/lib/resolve-imported-file/get-imports/index.js +2 -0
- package/lib/resolve-imported-file/index.js +2 -5
- package/lib/shorten-imported-file/get-imports/index.js +2 -0
- package/lib/shorten-imported-file/index.js +0 -4
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
parse,
|
|
4
4
|
print,
|
|
5
5
|
transform,
|
|
6
|
+
findPlaces,
|
|
6
7
|
operator,
|
|
7
8
|
} from 'putout';
|
|
8
9
|
import * as getImports from '#get-imports';
|
|
@@ -20,6 +21,7 @@ const getMessage = (a) => a.message;
|
|
|
20
21
|
export const report = (file, {from, to, filename}) => {
|
|
21
22
|
return `Apply private import: '${from}' -> '${to}' in '${filename}'`;
|
|
22
23
|
};
|
|
24
|
+
|
|
23
25
|
export const fix = (file, {ast, from, to}) => {
|
|
24
26
|
transform(ast, {
|
|
25
27
|
rules: {
|
|
@@ -48,10 +50,6 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
48
50
|
|
|
49
51
|
for (const file of trackFile(rootPath, mask)) {
|
|
50
52
|
const content = readFileContent(file);
|
|
51
|
-
|
|
52
|
-
if (!content.includes('import'))
|
|
53
|
-
continue;
|
|
54
|
-
|
|
55
53
|
const privateImports = getPrivateImports(file);
|
|
56
54
|
|
|
57
55
|
if (!privateImports.size)
|
|
@@ -59,7 +57,7 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
59
57
|
|
|
60
58
|
const ast = parse(content);
|
|
61
59
|
|
|
62
|
-
const places =
|
|
60
|
+
const places = findPlaces(ast, {
|
|
63
61
|
plugins: [
|
|
64
62
|
['get-imports', getImports],
|
|
65
63
|
],
|
|
@@ -11,6 +11,8 @@ export const replace = ({options}) => {
|
|
|
11
11
|
if (!to.endsWith('json'))
|
|
12
12
|
return {
|
|
13
13
|
[`import __imports from '${from}'`]: `import __imports from '${to}'`,
|
|
14
|
+
[`export __exports from '${from}'`]: `export __exports from '${to}'`,
|
|
15
|
+
[`export * from '${from}'`]: `export * from '${to}'`,
|
|
14
16
|
[`import('${from}')`]: `import('${to}')`,
|
|
15
17
|
};
|
|
16
18
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
print,
|
|
5
5
|
transform,
|
|
6
6
|
operator,
|
|
7
|
+
findPlaces,
|
|
7
8
|
} from 'putout';
|
|
8
9
|
import * as changeImports from '#change-imports';
|
|
9
10
|
import * as getImports from './get-imports/index.js';
|
|
@@ -47,13 +48,9 @@ export const scan = (rootPath, {push, trackFile, crawlFile}) => {
|
|
|
47
48
|
|
|
48
49
|
for (const file of trackFile(rootPath, mask)) {
|
|
49
50
|
const content = readFileContent(file);
|
|
50
|
-
|
|
51
|
-
if (!content.includes('import'))
|
|
52
|
-
continue;
|
|
53
|
-
|
|
54
51
|
const ast = parse(content);
|
|
55
52
|
|
|
56
|
-
const places =
|
|
53
|
+
const places = findPlaces(ast, {
|
|
57
54
|
plugins: [
|
|
58
55
|
['get-imports-source', getImports],
|
|
59
56
|
],
|
|
@@ -51,10 +51,6 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
51
51
|
|
|
52
52
|
for (const file of trackFile(rootPath, mask)) {
|
|
53
53
|
const content = readFileContent(file);
|
|
54
|
-
|
|
55
|
-
if (!content.includes('import'))
|
|
56
|
-
continue;
|
|
57
|
-
|
|
58
54
|
const [error, ast] = tryCatch(parse, content);
|
|
59
55
|
|
|
60
56
|
if (error)
|
package/package.json
CHANGED