@putout/plugin-esm 4.8.0 β 4.10.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/README.md
CHANGED
|
@@ -112,7 +112,7 @@ export * as ns from 'x';
|
|
|
112
112
|
|
|
113
113
|
### inline-export
|
|
114
114
|
|
|
115
|
-
Check out in π[**Putout Editor**](https://putout.cloudcmd.io
|
|
115
|
+
Check out in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9a3983d269745da89c1c7560f3b7fac/3ecb9aa6b910ce3816605bae11c8dd86bdc457e5).
|
|
116
116
|
|
|
117
117
|
#### β Example of incorrect code
|
|
118
118
|
|
|
@@ -320,13 +320,17 @@ Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f9f34acddb
|
|
|
320
320
|
#### β Example of incorrect code
|
|
321
321
|
|
|
322
322
|
```js
|
|
323
|
-
import json from './mod.json' with {
|
|
323
|
+
import json from './mod.json' with {
|
|
324
|
+
type: 'json',
|
|
325
|
+
};
|
|
324
326
|
```
|
|
325
327
|
|
|
326
328
|
#### β
Example of correct code
|
|
327
329
|
|
|
328
330
|
```js
|
|
329
|
-
import json from './mod.json' with {
|
|
331
|
+
import json from './mod.json' with {
|
|
332
|
+
type: 'json',
|
|
333
|
+
};
|
|
330
334
|
```
|
|
331
335
|
|
|
332
336
|
### sort-imports-by-specifiers
|
|
@@ -368,7 +372,9 @@ Check out in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9f85897b9
|
|
|
368
372
|
#### β Example of incorrect code
|
|
369
373
|
|
|
370
374
|
```js
|
|
371
|
-
import json from './foo.json' assert {
|
|
375
|
+
import json from './foo.json' assert {
|
|
376
|
+
type: 'json',
|
|
377
|
+
};
|
|
372
378
|
|
|
373
379
|
import('foo.json', {
|
|
374
380
|
assert: {
|
|
@@ -380,7 +386,9 @@ import('foo.json', {
|
|
|
380
386
|
#### β
Example of correct code
|
|
381
387
|
|
|
382
388
|
```js
|
|
383
|
-
import json from './foo.json' with {
|
|
389
|
+
import json from './foo.json' with {
|
|
390
|
+
type: 'json',
|
|
391
|
+
};
|
|
384
392
|
|
|
385
393
|
import('foo.json', {
|
|
386
394
|
with: {
|
|
@@ -21,8 +21,12 @@ export const filter = (path) => {
|
|
|
21
21
|
const specifiers = path.get('specifiers');
|
|
22
22
|
|
|
23
23
|
for (const spec of specifiers) {
|
|
24
|
-
const {local} = spec.node;
|
|
24
|
+
const {local, exported} = spec.node;
|
|
25
25
|
const {name} = local;
|
|
26
|
+
|
|
27
|
+
if (name !== exported.name)
|
|
28
|
+
return false;
|
|
29
|
+
|
|
26
30
|
const binding = scope.bindings[name];
|
|
27
31
|
|
|
28
32
|
if (!binding)
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
isVariableDeclarator,
|
|
8
8
|
} = types;
|
|
9
9
|
|
|
10
|
-
export const report = () => `
|
|
10
|
+
export const report = () => `Merge declaration with export`;
|
|
11
11
|
|
|
12
12
|
export const fix = ({path, bindingPath}) => {
|
|
13
13
|
const {parentPath} = bindingPath;
|
|
@@ -29,9 +29,12 @@ export const traverse = ({push}) => ({
|
|
|
29
29
|
if (!isExportSpecifier(spec))
|
|
30
30
|
return;
|
|
31
31
|
|
|
32
|
-
const {local} = spec;
|
|
33
|
-
|
|
32
|
+
const {local, exported} = spec;
|
|
34
33
|
const {name} = local;
|
|
34
|
+
|
|
35
|
+
if (name !== exported.name)
|
|
36
|
+
return;
|
|
37
|
+
|
|
35
38
|
const binding = path.scope.bindings[name];
|
|
36
39
|
|
|
37
40
|
if (!binding)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {types, operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {remove} = operator;
|
|
3
|
+
const {remove, compareAny} = operator;
|
|
4
4
|
const {values} = Object;
|
|
5
5
|
|
|
6
6
|
const {
|
|
@@ -57,7 +57,6 @@ function processImports(push, imports) {
|
|
|
57
57
|
continue;
|
|
58
58
|
|
|
59
59
|
const count = importDefaults.get(value) || 0;
|
|
60
|
-
|
|
61
60
|
const importDefaultCount = count + specifiers.filter(isImportDefaultSpecifier).length;
|
|
62
61
|
|
|
63
62
|
importDefaults.set(value, importDefaultCount);
|
|
@@ -83,6 +82,9 @@ function processImports(push, imports) {
|
|
|
83
82
|
|
|
84
83
|
const [path, ...imports] = list;
|
|
85
84
|
|
|
85
|
+
if (compareAny(path, imports))
|
|
86
|
+
continue;
|
|
87
|
+
|
|
86
88
|
push({
|
|
87
89
|
path,
|
|
88
90
|
imports,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-esm",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.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",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@putout/eslint-flat": "^3.0.0",
|
|
41
41
|
"@putout/plugin-declare": "*",
|
|
42
42
|
"@putout/plugin-declare-before-reference": "*",
|
|
43
|
+
"@putout/plugin-merge-destructuring-properties": "*",
|
|
43
44
|
"@putout/plugin-nodejs": "*",
|
|
44
45
|
"@putout/plugin-putout": "*",
|
|
45
46
|
"@putout/plugin-reuse-duplicate-init": "*",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"c8": "^10.0.0",
|
|
50
51
|
"eslint": "^9.0.0",
|
|
51
52
|
"eslint-plugin-n": "^17.0.0",
|
|
52
|
-
"eslint-plugin-putout": "^
|
|
53
|
+
"eslint-plugin-putout": "^28.0.0",
|
|
53
54
|
"madrun": "^11.0.0",
|
|
54
55
|
"montag": "^1.2.1",
|
|
55
56
|
"nodemon": "^3.0.1",
|