@putout/plugin-esm 9.11.1 → 10.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.
- package/lib/apply-js-imported-file/index.js +3 -3
- package/lib/apply-name-to-imported-file/get-imports-tuples.js +1 -1
- package/lib/apply-name-to-imported-file/transform-named-import.js +2 -2
- package/lib/apply-namespace-to-imported-file/transform-namespace-import.js +2 -2
- package/lib/apply-privately-imported-file/index.js +3 -3
- package/lib/resolve-imported-file/build-resolved.js +5 -5
- package/lib/resolve-imported-file/index.js +3 -3
- package/lib/shorten-imported-file/index.js +3 -3
- package/package.json +5 -5
|
@@ -22,8 +22,8 @@ const getMessage = (a) => a.message;
|
|
|
22
22
|
const applyJS = (a) => a.replace(/\.[cm]js$/, '.js');
|
|
23
23
|
|
|
24
24
|
export const report = (file, {from, to}) => `Apply 'js' imported source: '${from}' -> '${to}'`;
|
|
25
|
-
export const fix = (file, {
|
|
26
|
-
transform(ast,
|
|
25
|
+
export const fix = (file, {ast, from, to}) => {
|
|
26
|
+
transform(ast, {
|
|
27
27
|
rules: {
|
|
28
28
|
'change-imports': ['on', {
|
|
29
29
|
from,
|
|
@@ -59,7 +59,7 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
59
59
|
if (error)
|
|
60
60
|
continue;
|
|
61
61
|
|
|
62
|
-
const places = transform(ast,
|
|
62
|
+
const places = transform(ast, {
|
|
63
63
|
plugins: [
|
|
64
64
|
['get-imports', getImports],
|
|
65
65
|
],
|
|
@@ -6,7 +6,7 @@ const {getFilename} = operator;
|
|
|
6
6
|
const getMessage = (a) => a.message;
|
|
7
7
|
|
|
8
8
|
export const getImportsTuples = (file, content, ast) => {
|
|
9
|
-
const places = transform(ast,
|
|
9
|
+
const places = transform(ast, {
|
|
10
10
|
fix: false,
|
|
11
11
|
plugins: [
|
|
12
12
|
['get-imports', getImportsPlugin],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {transform} from 'putout';
|
|
2
2
|
import * as applyNamedImportPlugin from './apply-named-import/index.js';
|
|
3
3
|
|
|
4
|
-
export const transformNamedImport = (ast, {name, source
|
|
5
|
-
transform(ast,
|
|
4
|
+
export const transformNamedImport = (ast, {name, source}) => {
|
|
5
|
+
transform(ast, {
|
|
6
6
|
rules: {
|
|
7
7
|
'apply-named-import': ['on', {
|
|
8
8
|
name,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {transform} from 'putout';
|
|
2
2
|
import * as applyNamespaceImportPlugin from './apply-namespace-import/index.js';
|
|
3
3
|
|
|
4
|
-
export const transformNamespaceImport = (ast, {source,
|
|
5
|
-
transform(ast,
|
|
4
|
+
export const transformNamespaceImport = (ast, {source, name}) => {
|
|
5
|
+
transform(ast, {
|
|
6
6
|
rules: {
|
|
7
7
|
'apply-namespace-import': ['on', {
|
|
8
8
|
name,
|
|
@@ -20,8 +20,8 @@ const getMessage = (a) => a.message;
|
|
|
20
20
|
export const report = (file, {from, to, filename}) => {
|
|
21
21
|
return `Apply private import: '${from}' -> '${to}' in '${filename}'`;
|
|
22
22
|
};
|
|
23
|
-
export const fix = (file, {
|
|
24
|
-
transform(ast,
|
|
23
|
+
export const fix = (file, {ast, from, to}) => {
|
|
24
|
+
transform(ast, {
|
|
25
25
|
rules: {
|
|
26
26
|
'change-imports': ['on', {
|
|
27
27
|
from,
|
|
@@ -59,7 +59,7 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
59
59
|
|
|
60
60
|
const ast = parse(content);
|
|
61
61
|
|
|
62
|
-
const places = transform(ast,
|
|
62
|
+
const places = transform(ast, {
|
|
63
63
|
plugins: [
|
|
64
64
|
['get-imports', getImports],
|
|
65
65
|
],
|
|
@@ -27,6 +27,11 @@ export const buildResolved = ({dir, imports, rootPath, crawlFile}) => {
|
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
if (crawlFile(rootPath, withJs).length) {
|
|
31
|
+
result.push([relative, `${relative}.js`]);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
if (relative.startsWith('..')) {
|
|
31
36
|
result.push(parseMainFromDotDot({
|
|
32
37
|
relative,
|
|
@@ -36,11 +41,6 @@ export const buildResolved = ({dir, imports, rootPath, crawlFile}) => {
|
|
|
36
41
|
}));
|
|
37
42
|
continue;
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
if (crawlFile(rootPath, withJs).length) {
|
|
41
|
-
result.push([relative, `${relative}.js`]);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return result.filter(Boolean);
|
|
@@ -21,8 +21,8 @@ export const report = (file, {from, to, filename}) => {
|
|
|
21
21
|
return `Resolve import source: '${from}' -> '${to}' in '${filename}'`;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const fix = (file, {
|
|
25
|
-
transform(ast,
|
|
24
|
+
export const fix = (file, {ast, from, to}) => {
|
|
25
|
+
transform(ast, {
|
|
26
26
|
rules: {
|
|
27
27
|
'change-imports': ['on', {
|
|
28
28
|
from,
|
|
@@ -53,7 +53,7 @@ export const scan = (rootPath, {push, trackFile, crawlFile}) => {
|
|
|
53
53
|
|
|
54
54
|
const ast = parse(content);
|
|
55
55
|
|
|
56
|
-
const places = transform(ast,
|
|
56
|
+
const places = transform(ast, {
|
|
57
57
|
plugins: [
|
|
58
58
|
['get-imports-source', getImports],
|
|
59
59
|
],
|
|
@@ -25,8 +25,8 @@ export const report = (file, {from, to}) => {
|
|
|
25
25
|
const name = getFilename(file);
|
|
26
26
|
return `Shorten import source: '${from}' -> '${to}' in '${name}'`;
|
|
27
27
|
};
|
|
28
|
-
export const fix = (file, {
|
|
29
|
-
transform(ast,
|
|
28
|
+
export const fix = (file, {ast, from, to}) => {
|
|
29
|
+
transform(ast, {
|
|
30
30
|
rules: {
|
|
31
31
|
'change-imports': ['on', {
|
|
32
32
|
from,
|
|
@@ -60,7 +60,7 @@ export const scan = (rootPath, {push, trackFile}) => {
|
|
|
60
60
|
if (error)
|
|
61
61
|
continue;
|
|
62
62
|
|
|
63
|
-
const places = transform(ast,
|
|
63
|
+
const places = transform(ast, {
|
|
64
64
|
plugins: [
|
|
65
65
|
['get-imports', getImports],
|
|
66
66
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-esm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.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",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"c8": "^10.0.0",
|
|
62
62
|
"eslint": "^10.0.0",
|
|
63
63
|
"eslint-plugin-n": "^17.0.0",
|
|
64
|
-
"eslint-plugin-putout": "^
|
|
65
|
-
"madrun": "^
|
|
64
|
+
"eslint-plugin-putout": "^31.0.0",
|
|
65
|
+
"madrun": "^13.0.0",
|
|
66
66
|
"montag": "^1.2.1",
|
|
67
67
|
"nodemon": "^3.0.1",
|
|
68
|
-
"redlint": "^
|
|
68
|
+
"redlint": "^6.0.0",
|
|
69
69
|
"supertape": "^12.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"putout": ">=
|
|
72
|
+
"putout": ">=42"
|
|
73
73
|
},
|
|
74
74
|
"license": "MIT",
|
|
75
75
|
"engines": {
|