@putout/plugin-esm 2.0.0 → 2.1.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/README.md
CHANGED
|
@@ -69,6 +69,7 @@ Group order:
|
|
|
69
69
|
|
|
70
70
|
- ✅ builtins;
|
|
71
71
|
- ✅ external;
|
|
72
|
+
- ✅ hashed;
|
|
72
73
|
- ✅ internal;
|
|
73
74
|
|
|
74
75
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3cc782acf95211f9d456d63a99032ee1/0674223d050bba572f5271ffdccf8616cb441af5).
|
|
@@ -82,6 +83,7 @@ import react from 'react';
|
|
|
82
83
|
import d from '../hello.js';
|
|
83
84
|
import ss from '../../bb/ss.js';
|
|
84
85
|
import b from './ss.js';
|
|
86
|
+
import parse from '#parser';
|
|
85
87
|
|
|
86
88
|
const c = 5;
|
|
87
89
|
```
|
|
@@ -92,6 +94,7 @@ const c = 5;
|
|
|
92
94
|
import fs from 'node:fs';
|
|
93
95
|
import react from 'react';
|
|
94
96
|
import {lodash} from 'lodash';
|
|
97
|
+
import parse from '#parser';
|
|
95
98
|
import b from './ss.js';
|
|
96
99
|
import d from '../hello.js';
|
|
97
100
|
import ss from '../../bb/ss.js';
|
|
@@ -31,6 +31,7 @@ module.exports.traverse = ({pathStore, push}) => ({
|
|
|
31
31
|
const external = [];
|
|
32
32
|
const internal = [];
|
|
33
33
|
const builtin = [];
|
|
34
|
+
const hashed = [];
|
|
34
35
|
const all = pathStore().filter(isImportDeclaration);
|
|
35
36
|
|
|
36
37
|
if (!all.length)
|
|
@@ -49,12 +50,18 @@ module.exports.traverse = ({pathStore, push}) => ({
|
|
|
49
50
|
continue;
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
if (value.startsWith('#')) {
|
|
54
|
+
hashed.push(current);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
external.push(current);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
const grouped = [
|
|
56
62
|
...builtin,
|
|
57
63
|
...external,
|
|
64
|
+
...hashed,
|
|
58
65
|
...internal,
|
|
59
66
|
];
|
|
60
67
|
|
|
@@ -29,13 +29,21 @@ module.exports.traverse = ({push}) => ({
|
|
|
29
29
|
if (nextPath.node.specifiers.length !== 1)
|
|
30
30
|
return;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const first = source.value;
|
|
33
|
+
const second = nextPath.node.source.value;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const is = isExcluded(first, second, {
|
|
36
|
+
direct: [
|
|
37
|
+
['node:', 'node:'],
|
|
38
|
+
['#', '#'],
|
|
39
|
+
],
|
|
40
|
+
reversed: [
|
|
41
|
+
['./', './'],
|
|
42
|
+
['../', '../'],
|
|
43
|
+
],
|
|
44
|
+
});
|
|
37
45
|
|
|
38
|
-
if (
|
|
46
|
+
if (is)
|
|
39
47
|
return;
|
|
40
48
|
|
|
41
49
|
push({
|
|
@@ -44,3 +52,17 @@ module.exports.traverse = ({push}) => ({
|
|
|
44
52
|
});
|
|
45
53
|
},
|
|
46
54
|
});
|
|
55
|
+
|
|
56
|
+
function isExcluded(first, second, {direct, reversed}) {
|
|
57
|
+
for (const [current, next] of direct) {
|
|
58
|
+
if (first.startsWith(current) && !second.startsWith(next))
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const [current, next] of reversed) {
|
|
63
|
+
if (!first.startsWith(current) && second.startsWith(next))
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
}
|
package/package.json
CHANGED