@bpmn-io/codemods 0.2.0 → 0.3.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/esm/README.md +4 -4
- package/esm/lib/resolve.js +13 -1
- package/package.json +2 -2
package/esm/README.md
CHANGED
|
@@ -52,11 +52,12 @@ For every `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts` and `.tsx` file below the target
|
|
|
52
52
|
- Relative and bare (`node_modules`) specifiers are both handled.
|
|
53
53
|
- TypeScript / JSX sources are written with a `.js` specifier (NodeNext
|
|
54
54
|
convention), even though the file on disk is `.ts`/`.tsx`.
|
|
55
|
+
- Relative directory imports are expanded to `<dir>/index.js` when an
|
|
56
|
+
`index` file exists in that directory (e.g. `./lib` → `./lib/index.js`).
|
|
55
57
|
4. Specifiers that already carry an extension, and bare package roots
|
|
56
58
|
(e.g. `diagram-js`, `react`), are left untouched.
|
|
57
|
-
5. Anything that still cannot be resolved (e.g. a
|
|
58
|
-
|
|
59
|
-
review — never silently changed.
|
|
59
|
+
5. Anything that still cannot be resolved (e.g. a genuinely missing file) is
|
|
60
|
+
**reported** for manual review — never silently changed.
|
|
60
61
|
|
|
61
62
|
Only the source string is edited; surrounding formatting is preserved exactly.
|
|
62
63
|
|
|
@@ -74,5 +75,4 @@ By design, the mod does **not**:
|
|
|
74
75
|
|
|
75
76
|
- rewrite `require()` calls,
|
|
76
77
|
- rewrite dynamic imports with a non-literal argument (`import(name)`),
|
|
77
|
-
- add `/index.js` for directory imports,
|
|
78
78
|
- guess at unresolvable imports — these are reported instead.
|
package/esm/lib/resolve.js
CHANGED
|
@@ -86,7 +86,19 @@ export function resolveImport(specifier, fromFile, options = {}) {
|
|
|
86
86
|
function resolveRelative(specifier, fromFile) {
|
|
87
87
|
const base = path.resolve(path.dirname(fromFile), specifier);
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const direct = resolveCandidates(base, specifier, RELATIVE_CANDIDATES);
|
|
90
|
+
if (direct) return direct;
|
|
91
|
+
|
|
92
|
+
// directory import: specifier points to a directory, try <dir>/index.*
|
|
93
|
+
if (isDirectory(base)) {
|
|
94
|
+
return resolveCandidates(
|
|
95
|
+
path.join(base, 'index'),
|
|
96
|
+
specifier + '/index',
|
|
97
|
+
RELATIVE_CANDIDATES
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return null;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
104
|
function resolveBare(specifier, fromFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bpmn-io/codemods",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A collection of codemods for the bpmn.io ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/bpmn-io/
|
|
11
|
+
"url": "https://github.com/bpmn-io/codemods"
|
|
12
12
|
},
|
|
13
13
|
"author": {
|
|
14
14
|
"name": "Nico Rehwaldt",
|