@reliverse/pathkit 1.1.8 → 1.1.9
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/bin/mod.js +12 -0
- package/package.json +1 -1
package/bin/mod.js
CHANGED
|
@@ -582,6 +582,14 @@ async function convertImportsExt({
|
|
|
582
582
|
`(?:import\\s+(?:[\\s\\S]*?)\\s+from\\s+|import\\s*\\(\\s*)\\s*(['"])([^'"]+${fromExtStr.replace(".", "\\.")})(\\1)`,
|
|
583
583
|
"g"
|
|
584
584
|
);
|
|
585
|
+
function shouldSkipPath(path2) {
|
|
586
|
+
if (path2.startsWith("node:") || path2.startsWith("bun:") || path2.startsWith("npm:") || path2.startsWith("jsr:") || path2.startsWith("node_modules"))
|
|
587
|
+
return true;
|
|
588
|
+
if (path2.startsWith("@") || !path2.includes("/")) return true;
|
|
589
|
+
if (path2.startsWith("http://") || path2.startsWith("https://")) return true;
|
|
590
|
+
if (extTo !== "none" && path2.endsWith(`.${extTo}`)) return true;
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
585
593
|
try {
|
|
586
594
|
const entries = await fs.readdir(targetDir, { withFileTypes: true });
|
|
587
595
|
const results = [];
|
|
@@ -606,6 +614,10 @@ async function convertImportsExt({
|
|
|
606
614
|
const quote = match[1];
|
|
607
615
|
const importPath = match[2];
|
|
608
616
|
if (!importPath) continue;
|
|
617
|
+
if (shouldSkipPath(importPath)) {
|
|
618
|
+
match = importRegex.exec(updated);
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
609
621
|
let replacementPath;
|
|
610
622
|
if (extFrom === "none") {
|
|
611
623
|
replacementPath = importPath + toExtStr;
|