@vxrn/resolve 1.14.4 → 1.14.5
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/dist/cjs/index.cjs +48 -40
- package/dist/cjs/index.native.js +57 -50
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/index.test.cjs +29 -16
- package/dist/cjs/index.test.native.js +29 -16
- package/dist/cjs/index.test.native.js.map +1 -1
- package/dist/esm/index.js +21 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +21 -15
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +25 -20
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/index.test.mjs +26 -13
- package/dist/esm/index.test.mjs.map +1 -1
- package/dist/esm/index.test.native.js +26 -13
- package/dist/esm/index.test.native.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,61 +2,69 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var index_exports = {};
|
|
33
35
|
__export(index_exports, {
|
|
34
36
|
resolvePath: () => resolvePath
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var import_node_module = __toESM(require("node:module"), 1)
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
var import_node_module = __toESM(require("node:module"), 1);
|
|
40
|
+
var import_node_path = require("node:path");
|
|
41
|
+
var import_node_fs = require("node:fs");
|
|
40
42
|
const resolvePath = (path, from = process.cwd()) => {
|
|
41
|
-
const require2 = import_node_module.default.createRequire(from.endsWith("/") ? from : from + "/")
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (isRelative || isBuiltin)
|
|
43
|
+
const require2 = import_node_module.default.createRequire(from.endsWith("/") ? from : from + "/");
|
|
44
|
+
const resolved = require2.resolve(path, {
|
|
45
|
+
paths: [from]
|
|
46
|
+
});
|
|
47
|
+
const isRelative = path.startsWith("./") || path.startsWith("../");
|
|
48
|
+
const isBuiltin = path.startsWith("node:");
|
|
49
|
+
if (isRelative || isBuiltin) {
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
48
52
|
try {
|
|
49
53
|
const pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
paths: [from]
|
|
55
|
+
});
|
|
56
|
+
const pkgJson = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8"));
|
|
57
|
+
const pkgDir = (0, import_node_path.dirname)(pkgJsonPath);
|
|
58
|
+
const exportsImport = pkgJson.exports?.["."]?.import;
|
|
55
59
|
if (exportsImport) {
|
|
56
|
-
const importPath = typeof exportsImport
|
|
57
|
-
if (importPath)
|
|
60
|
+
const importPath = typeof exportsImport === "string" ? exportsImport : exportsImport.default;
|
|
61
|
+
if (importPath) {
|
|
62
|
+
return (0, import_node_path.join)(pkgDir, importPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (pkgJson.module) {
|
|
66
|
+
return (0, import_node_path.join)(pkgDir, pkgJson.module);
|
|
58
67
|
}
|
|
59
|
-
if (pkgJson.module) return (0, import_node_path.join)(pkgDir, pkgJson.module);
|
|
60
68
|
} catch {}
|
|
61
69
|
return resolved;
|
|
62
70
|
};
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -4,65 +4,72 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var index_exports = {};
|
|
35
37
|
__export(index_exports, {
|
|
36
38
|
resolvePath: () => resolvePath
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var import_module = __toESM(require("module"), 1)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
var _pkgJson_exports_,
|
|
53
|
-
_pkgJson_exports,
|
|
54
|
-
pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
55
|
-
paths: [from]
|
|
56
|
-
}),
|
|
57
|
-
pkgJson = JSON.parse((0, import_fs.readFileSync)(pkgJsonPath, "utf8")),
|
|
58
|
-
pkgDir = (0, import_path.dirname)(pkgJsonPath),
|
|
59
|
-
exportsImport = (_pkgJson_exports = pkgJson.exports) === null || _pkgJson_exports === void 0 || (_pkgJson_exports_ = _pkgJson_exports["."]) === null || _pkgJson_exports_ === void 0 ? void 0 : _pkgJson_exports_.import;
|
|
60
|
-
if (exportsImport) {
|
|
61
|
-
var importPath = typeof exportsImport == "string" ? exportsImport : exportsImport.default;
|
|
62
|
-
if (importPath) return (0, import_path.join)(pkgDir, importPath);
|
|
63
|
-
}
|
|
64
|
-
if (pkgJson.module) return (0, import_path.join)(pkgDir, pkgJson.module);
|
|
65
|
-
} catch {}
|
|
41
|
+
var import_module = __toESM(require("module"), 1);
|
|
42
|
+
var import_path = require("path");
|
|
43
|
+
var import_fs = require("fs");
|
|
44
|
+
var resolvePath = function (path) {
|
|
45
|
+
var from = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd();
|
|
46
|
+
var require2 = import_module.default.createRequire(from.endsWith("/") ? from : from + "/");
|
|
47
|
+
var resolved = require2.resolve(path, {
|
|
48
|
+
paths: [from]
|
|
49
|
+
});
|
|
50
|
+
var isRelative = path.startsWith("./") || path.startsWith("../");
|
|
51
|
+
var isBuiltin = path.startsWith("node:");
|
|
52
|
+
if (isRelative || isBuiltin) {
|
|
66
53
|
return resolved;
|
|
67
|
-
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
var _pkgJson_exports_, _pkgJson_exports;
|
|
57
|
+
var pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
58
|
+
paths: [from]
|
|
59
|
+
});
|
|
60
|
+
var pkgJson = JSON.parse((0, import_fs.readFileSync)(pkgJsonPath, "utf8"));
|
|
61
|
+
var pkgDir = (0, import_path.dirname)(pkgJsonPath);
|
|
62
|
+
var exportsImport = (_pkgJson_exports = pkgJson.exports) === null || _pkgJson_exports === void 0 ? void 0 : (_pkgJson_exports_ = _pkgJson_exports["."]) === null || _pkgJson_exports_ === void 0 ? void 0 : _pkgJson_exports_.import;
|
|
63
|
+
if (exportsImport) {
|
|
64
|
+
var importPath = typeof exportsImport === "string" ? exportsImport : exportsImport.default;
|
|
65
|
+
if (importPath) {
|
|
66
|
+
return (0, import_path.join)(pkgDir, importPath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (pkgJson.module) {
|
|
70
|
+
return (0, import_path.join)(pkgDir, pkgJson.module);
|
|
71
|
+
}
|
|
72
|
+
} catch (unused) {}
|
|
73
|
+
return resolved;
|
|
74
|
+
};
|
|
68
75
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","resolvePath","module","exports","import_module","__toESM","require","import_path","import_fs","path","from","arguments","length","process","cwd","require2","default","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","_pkgJson_exports_","_pkgJson_exports","pkgJsonPath","pkgJson","JSON","parse","readFileSync","pkgDir","dirname","exportsImport","import","importPath"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","resolvePath","module","exports","import_module","__toESM","require","import_path","import_fs","path","from","arguments","length","process","cwd","require2","default","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","_pkgJson_exports_","_pkgJson_exports","pkgJsonPath","pkgJson","JSON","parse","readFileSync","pkgDir","dirname","exportsImport","import","importPath"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAmB,CAAAK,aAAA;AACnB,IAAAK,aAAA,GAAAC,OAA8B,CAAAC,OAAA;AAC9B,IAAAC,WAAA,GAAAD,OAA6B;AAMtB,IAAAE,SAAM,GAAAF,OAAe,KAAc;AACxC,IAAAL,WAAM,YAAAA,CAAUQ,IAAA;EAChB,IAAAC,IAAM,GAAAC,SAAW,CAAAC,MAAQ,QAAQD,SAAQ,QAAQ,KAAO,IAAAA,SAAA,MAAAE,OAAA,CAAAC,GAAA;EAGxD,IAAAC,QAAM,GAAAX,aAAkB,CAAAY,OAAW,CAAAC,aAAc,CAAAP,IAAA,CAAAQ,QAAW,CAAK,OAAAR,IAAA,GAAAA,IAAA;EACjE,IAAAS,QAAM,GAAAJ,QAAiB,CAAAK,OAAA,CAAAX,IAAW;IAClCY,KAAI,GACFX,IAAA;EAIF;EACE,IAAAY,UAAM,GAAAb,IAAA,CAAcc,UAAQ,UAAWd,IAAI,CAAAc,UAAA,MAAiB;EAC5D,IAAAC,SAAM,GAAAf,IAAU,CAAAc,UAAK,QAAM;EAC3B,IAAAD,UAAM,IAAAE,SAAS;IAGf,OAAML,QAAA;EACN;EAEE;IAEA,IAAAM,iBAAgB,EAAAC,gBAAA;IACd,IAAAC,WAAO,GAAAZ,QAAA,CAAAK,OAAA,IAAKX,IAAA,eAAkB;MAChCY,KAAA,GACFX,IAAA;IAIE;IACF,IAAAkB,OAAA,GAAAC,IAAA,CAAAC,KAAA,KAAAtB,SAAA,CAAAuB,YAAA,EAAAJ,WAAA;IACF,IAAAK,MAAQ,OAAAzB,WAAA,CAAA0B,OAAA,EAAAN,WAAA;IAER,IAAAO,aAAA,IAAAR,gBAAA,GAAAE,OAAA,CAAAzB,OAAA,cAAAuB,gBAAA,wBAAAD,iBAAA,GAAAC,gBAAA,mBAAAD,iBAAA,uBAAAA,iBAAA,CAAAU,MAAA;IAEA,IAAAD,aAAO;MACT,IAAAE,UAAA,UAAAF,aAAA,gBAAAA,aAAA,GAAAA,aAAA,CAAAlB,OAAA","ignoreList":[]}
|
package/dist/cjs/index.test.cjs
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
|
-
var import_vitest = require("vitest")
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_index = require("./index.cjs");
|
|
3
|
+
var import_node_fs = require("node:fs");
|
|
4
4
|
(0, import_vitest.describe)("resolvePath", () => {
|
|
5
5
|
(0, import_vitest.describe)("basic resolution", () => {
|
|
6
6
|
(0, import_vitest.it)("resolves node builtins", () => {
|
|
7
|
-
(0, import_vitest.expect)((0, import_index.resolvePath)("node:path")).toBe("node:path")
|
|
8
|
-
|
|
7
|
+
(0, import_vitest.expect)((0, import_index.resolvePath)("node:path")).toBe("node:path");
|
|
8
|
+
(0, import_vitest.expect)((0, import_index.resolvePath)("node:fs")).toBe("node:fs");
|
|
9
|
+
});
|
|
10
|
+
(0, import_vitest.it)("resolves npm packages", () => {
|
|
9
11
|
const path = (0, import_index.resolvePath)("vitest");
|
|
10
|
-
(0, import_vitest.expect)(path).toBeTruthy()
|
|
11
|
-
|
|
12
|
+
(0, import_vitest.expect)(path).toBeTruthy();
|
|
13
|
+
(0, import_vitest.expect)((0, import_node_fs.existsSync)(path)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
(0, import_vitest.it)("resolves relative paths from cwd", () => {
|
|
12
16
|
const path = (0, import_index.resolvePath)("./package.json");
|
|
13
|
-
(0, import_vitest.expect)(path).toContain("package.json")
|
|
17
|
+
(0, import_vitest.expect)(path).toContain("package.json");
|
|
18
|
+
(0, import_vitest.expect)((0, import_node_fs.existsSync)(path)).toBe(true);
|
|
14
19
|
});
|
|
15
|
-
})
|
|
20
|
+
});
|
|
21
|
+
(0, import_vitest.describe)("respects from parameter", () => {
|
|
16
22
|
(0, import_vitest.it)("resolves relative paths from specified directory", () => {
|
|
17
23
|
const path = (0, import_index.resolvePath)("./package.json", process.cwd());
|
|
18
|
-
(0, import_vitest.expect)(path).toBe(process.cwd() + "/package.json")
|
|
19
|
-
|
|
24
|
+
(0, import_vitest.expect)(path).toBe(process.cwd() + "/package.json");
|
|
25
|
+
(0, import_vitest.expect)((0, import_node_fs.existsSync)(path)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
(0, import_vitest.it)("resolves npm packages from specified directory", () => {
|
|
20
28
|
const path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
21
29
|
(0, import_vitest.expect)(path).toContain("vitest");
|
|
22
30
|
});
|
|
23
|
-
})
|
|
31
|
+
});
|
|
32
|
+
(0, import_vitest.describe)("ESM entry point detection", () => {
|
|
24
33
|
(0, import_vitest.it)('returns ESM entry when exports["."].import is a string', () => {
|
|
25
34
|
const path = (0, import_index.resolvePath)("@vxrn/resolve", process.cwd());
|
|
26
35
|
(0, import_vitest.expect)(path).toBeTruthy();
|
|
27
|
-
})
|
|
36
|
+
});
|
|
37
|
+
(0, import_vitest.it)('returns ESM entry when exports["."].import.default exists', () => {
|
|
28
38
|
const path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
29
|
-
(0, import_vitest.expect)(path).toContain("dist/index.js")
|
|
30
|
-
|
|
39
|
+
(0, import_vitest.expect)(path).toContain("dist/index.js");
|
|
40
|
+
(0, import_vitest.expect)(path).not.toContain(".cjs");
|
|
41
|
+
});
|
|
42
|
+
(0, import_vitest.it)("falls back to module field when exports not available", () => {
|
|
31
43
|
const path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
32
44
|
(0, import_vitest.expect)(path).toBeTruthy();
|
|
33
|
-
})
|
|
45
|
+
});
|
|
46
|
+
(0, import_vitest.it)("falls back to main/require.resolve when no ESM entry", () => {
|
|
34
47
|
const path = (0, import_index.resolvePath)("resolve", process.cwd());
|
|
35
48
|
(0, import_vitest.expect)(path).toContain("resolve");
|
|
36
49
|
});
|
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var import_vitest = require("vitest")
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_index = require("./index.native.js");
|
|
5
|
+
var import_fs = require("fs");
|
|
6
6
|
(0, import_vitest.describe)("resolvePath", function () {
|
|
7
7
|
(0, import_vitest.describe)("basic resolution", function () {
|
|
8
8
|
(0, import_vitest.it)("resolves node builtins", function () {
|
|
9
|
-
(0, import_vitest.expect)((0, import_index.resolvePath)("node:path")).toBe("node:path")
|
|
10
|
-
|
|
9
|
+
(0, import_vitest.expect)((0, import_index.resolvePath)("node:path")).toBe("node:path");
|
|
10
|
+
(0, import_vitest.expect)((0, import_index.resolvePath)("node:fs")).toBe("node:fs");
|
|
11
|
+
});
|
|
12
|
+
(0, import_vitest.it)("resolves npm packages", function () {
|
|
11
13
|
var path = (0, import_index.resolvePath)("vitest");
|
|
12
|
-
(0, import_vitest.expect)(path).toBeTruthy()
|
|
13
|
-
|
|
14
|
+
(0, import_vitest.expect)(path).toBeTruthy();
|
|
15
|
+
(0, import_vitest.expect)((0, import_fs.existsSync)(path)).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
(0, import_vitest.it)("resolves relative paths from cwd", function () {
|
|
14
18
|
var path = (0, import_index.resolvePath)("./package.json");
|
|
15
|
-
(0, import_vitest.expect)(path).toContain("package.json")
|
|
19
|
+
(0, import_vitest.expect)(path).toContain("package.json");
|
|
20
|
+
(0, import_vitest.expect)((0, import_fs.existsSync)(path)).toBe(true);
|
|
16
21
|
});
|
|
17
|
-
})
|
|
22
|
+
});
|
|
23
|
+
(0, import_vitest.describe)("respects from parameter", function () {
|
|
18
24
|
(0, import_vitest.it)("resolves relative paths from specified directory", function () {
|
|
19
25
|
var path = (0, import_index.resolvePath)("./package.json", process.cwd());
|
|
20
|
-
(0, import_vitest.expect)(path).toBe(process.cwd() + "/package.json")
|
|
21
|
-
|
|
26
|
+
(0, import_vitest.expect)(path).toBe(process.cwd() + "/package.json");
|
|
27
|
+
(0, import_vitest.expect)((0, import_fs.existsSync)(path)).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
(0, import_vitest.it)("resolves npm packages from specified directory", function () {
|
|
22
30
|
var path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
23
31
|
(0, import_vitest.expect)(path).toContain("vitest");
|
|
24
32
|
});
|
|
25
|
-
})
|
|
33
|
+
});
|
|
34
|
+
(0, import_vitest.describe)("ESM entry point detection", function () {
|
|
26
35
|
(0, import_vitest.it)('returns ESM entry when exports["."].import is a string', function () {
|
|
27
36
|
var path = (0, import_index.resolvePath)("@vxrn/resolve", process.cwd());
|
|
28
37
|
(0, import_vitest.expect)(path).toBeTruthy();
|
|
29
|
-
})
|
|
38
|
+
});
|
|
39
|
+
(0, import_vitest.it)('returns ESM entry when exports["."].import.default exists', function () {
|
|
30
40
|
var path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
31
|
-
(0, import_vitest.expect)(path).toContain("dist/index.js")
|
|
32
|
-
|
|
41
|
+
(0, import_vitest.expect)(path).toContain("dist/index.js");
|
|
42
|
+
(0, import_vitest.expect)(path).not.toContain(".cjs");
|
|
43
|
+
});
|
|
44
|
+
(0, import_vitest.it)("falls back to module field when exports not available", function () {
|
|
33
45
|
var path = (0, import_index.resolvePath)("vitest", process.cwd());
|
|
34
46
|
(0, import_vitest.expect)(path).toBeTruthy();
|
|
35
|
-
})
|
|
47
|
+
});
|
|
48
|
+
(0, import_vitest.it)("falls back to main/require.resolve when no ESM entry", function () {
|
|
36
49
|
var path = (0, import_index.resolvePath)("resolve", process.cwd());
|
|
37
50
|
(0, import_vitest.expect)(path).toContain("resolve");
|
|
38
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["import_vitest","require","import_index","import_fs","describe","it","expect","resolvePath","toBe","path","toBeTruthy","existsSync","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_index","import_fs","describe","it","expect","resolvePath","toBe","path","toBeTruthy","existsSync","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,aAAA,GAA4BC,OAAA;AAC5B,IAAAC,YAAA,GAAAD,OAA2B;AAAA,IAE3BE,SAAA,GAAAF,OAAA,KAAS;AACP,IAAAD,aAAA,CAAAI,QAAA,eAAS,cAAoB;EAC3B,IAAAJ,aAAA,CAAAI,QAAG,kCAAgC;IACjC,IAAAJ,aAAA,CAAAK,EAAA,0BAAO,cAAY;MACnB,IAAAL,aAAA,CAAAM,MAAA,MAAOJ,YAAA,CAAAK,WAAA,EAAY,WAAU,CAAE,EAAAC,IAAK,YAAS;MAC9C,IAAAR,aAAA,CAAAM,MAAA,MAAAJ,YAAA,CAAAK,WAAA,cAAAC,IAAA;IAED;IACE,IAAAR,aAAM,CAAAK,EAAO,yBAAY,cAAQ;MACjC,IAAAI,IAAA,OAAAP,YAAO,CAAAK,WAAM,UAAW;MACxB,IAAAP,aAAA,CAAAM,MAAA,EAAAG,IAAO,EAAAC,UAAA;MACR,IAAAV,aAAA,CAAAM,MAAA,MAAAH,SAAA,CAAAQ,UAAA,EAAAF,IAAA,GAAAD,IAAA;IAED;IACE,IAAAR,aAAM,CAAAK,EAAO,oCAAY,cAAgB;MACzC,IAAAI,IAAA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,aAAM,CAAAK,EAAO,yDAAmC;MAChD,IAAAI,IAAA,OAAAP,YAAO,CAAAK,WAAM,UAAW,EAAAM,OAAA,CAAAC,GAAA;MACzB,IAAAd,aAAA,CAAAM,MAAA,EAAAG,IAAA,EAAAC,UAAA;IAED;IAEE,IAAAV,aAAM,CAAAK,EAAO,wDAAoC;MACjD,IAAAI,IAAA,OAAAP,YAAO,CAAAK,WAAM,WAAU,EAASM,OAAA,CAAAC,GAAA;MACjC,IAAAd,aAAA,CAAAM,MAAA,EAAAG,IAAA,EAAAG,SAAA;IACF;EACF","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,25 +2,31 @@ import module from "node:module";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
const resolvePath = (path, from = process.cwd()) => {
|
|
5
|
-
const require2 = module.createRequire(from.endsWith("/") ? from : from + "/")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (isRelative || isBuiltin)
|
|
5
|
+
const require2 = module.createRequire(from.endsWith("/") ? from : from + "/");
|
|
6
|
+
const resolved = require2.resolve(path, {
|
|
7
|
+
paths: [from]
|
|
8
|
+
});
|
|
9
|
+
const isRelative = path.startsWith("./") || path.startsWith("../");
|
|
10
|
+
const isBuiltin = path.startsWith("node:");
|
|
11
|
+
if (isRelative || isBuiltin) {
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
12
14
|
try {
|
|
13
15
|
const pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
paths: [from]
|
|
17
|
+
});
|
|
18
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
19
|
+
const pkgDir = dirname(pkgJsonPath);
|
|
20
|
+
const exportsImport = pkgJson.exports?.["."]?.import;
|
|
19
21
|
if (exportsImport) {
|
|
20
|
-
const importPath = typeof exportsImport
|
|
21
|
-
if (importPath)
|
|
22
|
+
const importPath = typeof exportsImport === "string" ? exportsImport : exportsImport.default;
|
|
23
|
+
if (importPath) {
|
|
24
|
+
return join(pkgDir, importPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (pkgJson.module) {
|
|
28
|
+
return join(pkgDir, pkgJson.module);
|
|
22
29
|
}
|
|
23
|
-
if (pkgJson.module) return join(pkgDir, pkgJson.module);
|
|
24
30
|
} catch {}
|
|
25
31
|
return resolved;
|
|
26
32
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,MAAMC,WAAA,GAAcA,CAACC,IAAA,EAAcC,IAAA,GAAOC,OAAA,CAAQC,GAAA,CAAI,MAAc;EACzE,MAAMC,QAAA,GAAUT,MAAA,CAAOU,aAAA,CAAcJ,IAAA,CAAKK,QAAA,CAAS,GAAG,IAAIL,IAAA,GAAOA,IAAA,GAAO,GAAG;
|
|
1
|
+
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,MAAMC,WAA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esm/index.mjs
CHANGED
|
@@ -2,25 +2,31 @@ import module from "node:module";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
const resolvePath = (path, from = process.cwd()) => {
|
|
5
|
-
const require2 = module.createRequire(from.endsWith("/") ? from : from + "/")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (isRelative || isBuiltin)
|
|
5
|
+
const require2 = module.createRequire(from.endsWith("/") ? from : from + "/");
|
|
6
|
+
const resolved = require2.resolve(path, {
|
|
7
|
+
paths: [from]
|
|
8
|
+
});
|
|
9
|
+
const isRelative = path.startsWith("./") || path.startsWith("../");
|
|
10
|
+
const isBuiltin = path.startsWith("node:");
|
|
11
|
+
if (isRelative || isBuiltin) {
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
12
14
|
try {
|
|
13
15
|
const pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
paths: [from]
|
|
17
|
+
});
|
|
18
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
19
|
+
const pkgDir = dirname(pkgJsonPath);
|
|
20
|
+
const exportsImport = pkgJson.exports?.["."]?.import;
|
|
19
21
|
if (exportsImport) {
|
|
20
|
-
const importPath = typeof exportsImport
|
|
21
|
-
if (importPath)
|
|
22
|
+
const importPath = typeof exportsImport === "string" ? exportsImport : exportsImport.default;
|
|
23
|
+
if (importPath) {
|
|
24
|
+
return join(pkgDir, importPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (pkgJson.module) {
|
|
28
|
+
return join(pkgDir, pkgJson.module);
|
|
22
29
|
}
|
|
23
|
-
if (pkgJson.module) return join(pkgDir, pkgJson.module);
|
|
24
30
|
} catch {}
|
|
25
31
|
return resolved;
|
|
26
32
|
};
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,MAAMC,WAAA,GAAcA,CAACC,IAAA,EAAcC,IAAA,GAAOC,OAAA,CAAQC,GAAA,CAAI,MAAc;EACzE,MAAMC,QAAA,GAAUT,MAAA,CAAOU,aAAA,CAAcJ,IAAA,CAAKK,QAAA,CAAS,GAAG,IAAIL,IAAA,GAAOA,IAAA,GAAO,GAAG;
|
|
1
|
+
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,MAAMC,WAAA,GAAcA,CAACC,IAAA,EAAcC,IAAA,GAAOC,OAAA,CAAQC,GAAA,CAAI,MAAc;EACzE,MAAMC,QAAA,GAAUT,MAAA,CAAOU,aAAA,CAAcJ,IAAA,CAAKK,QAAA,CAAS,GAAG,IAAIL,IAAA,GAAOA,IAAA,GAAO,GAAG;EAC3E,MAAMM,QAAA,GAAWH,QAAA,CAAQI,OAAA,CAAQR,IAAA,EAAM;IAAES,KAAA,EAAO,CAACR,IAAI;EAAE,CAAC;EAGxD,MAAMS,UAAA,GAAaV,IAAA,CAAKW,UAAA,CAAW,IAAI,KAAKX,IAAA,CAAKW,UAAA,CAAW,KAAK;EACjE,MAAMC,SAAA,GAAYZ,IAAA,CAAKW,UAAA,CAAW,OAAO;EACzC,IAAID,UAAA,IAAcE,SAAA,EAAW;IAC3B,OAAOL,QAAA;EACT;EAGA,IAAI;IACF,MAAMM,WAAA,GAAcT,QAAA,CAAQI,OAAA,CAAQ,GAAGR,IAAI,iBAAiB;MAAES,KAAA,EAAO,CAACR,IAAI;IAAE,CAAC;IAC7E,MAAMa,OAAA,GAAUC,IAAA,CAAKC,KAAA,CAAMlB,YAAA,CAAae,WAAA,EAAa,MAAM,CAAC;IAC5D,MAAMI,MAAA,GAASrB,OAAA,CAAQiB,WAAW;IAGlC,MAAMK,aAAA,GAAgBJ,OAAA,CAAQK,OAAA,GAAU,GAAG,GAAGC,MAAA;IAC9C,IAAIF,aAAA,EAAe;MAEjB,MAAMG,UAAA,GACJ,OAAOH,aAAA,KAAkB,WAAWA,aAAA,GAAgBA,aAAA,CAAcI,OAAA;MACpE,IAAID,UAAA,EAAY;QACd,OAAOxB,IAAA,CAAKoB,MAAA,EAAQI,UAAU;MAChC;IACF;IAGA,IAAIP,OAAA,CAAQnB,MAAA,EAAQ;MAClB,OAAOE,IAAA,CAAKoB,MAAA,EAAQH,OAAA,CAAQnB,MAAM;IACpC;EACF,QAAQ,CAER;EAEA,OAAOY,QAAA;AACT","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -2,29 +2,34 @@ import module from "module";
|
|
|
2
2
|
import { dirname, join } from "path";
|
|
3
3
|
import { readFileSync } from "fs";
|
|
4
4
|
var resolvePath = function (path) {
|
|
5
|
-
var from = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (isRelative || isBuiltin)
|
|
5
|
+
var from = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd();
|
|
6
|
+
var require2 = module.createRequire(from.endsWith("/") ? from : from + "/");
|
|
7
|
+
var resolved = require2.resolve(path, {
|
|
8
|
+
paths: [from]
|
|
9
|
+
});
|
|
10
|
+
var isRelative = path.startsWith("./") || path.startsWith("../");
|
|
11
|
+
var isBuiltin = path.startsWith("node:");
|
|
12
|
+
if (isRelative || isBuiltin) {
|
|
13
|
+
return resolved;
|
|
14
|
+
}
|
|
13
15
|
try {
|
|
14
|
-
var _pkgJson_exports_,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exportsImport = (_pkgJson_exports = pkgJson.exports) === null || _pkgJson_exports === void 0 || (_pkgJson_exports_ = _pkgJson_exports["."]) === null || _pkgJson_exports_ === void 0 ? void 0 : _pkgJson_exports_.import;
|
|
16
|
+
var _pkgJson_exports_, _pkgJson_exports;
|
|
17
|
+
var pkgJsonPath = require2.resolve(`${path}/package.json`, {
|
|
18
|
+
paths: [from]
|
|
19
|
+
});
|
|
20
|
+
var pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
21
|
+
var pkgDir = dirname(pkgJsonPath);
|
|
22
|
+
var exportsImport = (_pkgJson_exports = pkgJson.exports) === null || _pkgJson_exports === void 0 ? void 0 : (_pkgJson_exports_ = _pkgJson_exports["."]) === null || _pkgJson_exports_ === void 0 ? void 0 : _pkgJson_exports_.import;
|
|
22
23
|
if (exportsImport) {
|
|
23
|
-
var importPath = typeof exportsImport
|
|
24
|
-
if (importPath)
|
|
24
|
+
var importPath = typeof exportsImport === "string" ? exportsImport : exportsImport.default;
|
|
25
|
+
if (importPath) {
|
|
26
|
+
return join(pkgDir, importPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (pkgJson.module) {
|
|
30
|
+
return join(pkgDir, pkgJson.module);
|
|
25
31
|
}
|
|
26
|
-
|
|
27
|
-
} catch {}
|
|
32
|
+
} catch (unused) {}
|
|
28
33
|
return resolved;
|
|
29
34
|
};
|
|
30
35
|
export { resolvePath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","arguments","length","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","_pkgJson_exports_","_pkgJson_exports","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,IAAAC,WAAM,YAAAA,CAA6BC,IAAA;EACxC,IAAAC,IAAM,GAAAC,SAAU,CAAAC,MAAO,QAAAD,SAAmB,QAAS,KAAG,IAAIA,SAAO,GAAO,GAAGE,
|
|
1
|
+
{"version":3,"names":["module","dirname","join","readFileSync","resolvePath","path","from","arguments","length","process","cwd","require2","createRequire","endsWith","resolved","resolve","paths","isRelative","startsWith","isBuiltin","_pkgJson_exports_","_pkgJson_exports","pkgJsonPath","pkgJson","JSON","parse","pkgDir","exportsImport","exports","import","importPath","default"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,MAAA,MAAY;AACnB,SAASC,OAAA,EAASC,IAAA,QAAY;AAC9B,SAASC,YAAA,QAAoB;AAMtB,IAAAC,WAAM,YAAAA,CAA6BC,IAAA;EACxC,IAAAC,IAAM,GAAAC,SAAU,CAAAC,MAAO,QAAAD,SAAmB,QAAS,KAAG,IAAIA,SAAO,GAAO,GAAGE,OAAA,CAAAC,GAAA;EAC3E,IAAAC,QAAM,GAAAX,MAAW,CAAAY,aAAgB,CAAAN,IAAM,CAAAO,QAAS,CAAC,IAAI,GAAGP,IAAA,GAAAA,IAAA;EAGxD,IAAAQ,QAAM,GAAAH,QAAa,CAAKI,OAAA,CAAAV,IAAW;IACnCW,KAAM,GACFV,IAAA;EAEJ;EAGA,IAAIW,UAAA,GAAAZ,IAAA,CAAAa,UAAA,UAAAb,IAAA,CAAAa,UAAA;EACF,IAAAC,SAAM,GAAAd,IAAA,CAAAa,UAAsB,QAAQ;EACpC,IAAAD,UAAM,IAAUE,SAAK,EAAM;IAC3B,OAAML,QAAS;EAGf;EACA;IAEE,IAAAM,iBACE,EAAAC,gBAAO;IACT,IAAAC,WAAI,GAAYX,QAAA,CAAAI,OAAA,IAAAV,IAAA;MACdW,KAAA,GACFV,IAAA;IAIF;IACE,IAAAiB,OAAO,GAAKC,IAAA,CAAAC,KAAQ,CAAAtB,YAAc,CAAAmB,WAAA;IACpC,IAAAI,MAAA,GAAAzB,OAAA,CAAAqB,WAAA;IACF,IAAAK,aAAQ,IAAAN,gBAAA,GAAAE,OAAA,CAAAK,OAAA,cAAAP,gBAAA,wBAAAD,iBAAA,GAAAC,gBAAA,mBAAAD,iBAAA,uBAAAA,iBAAA,CAAAS,MAAA;IAER,IAAAF,aAAA;MAEA,IAAOG,UAAA,UAAAH,aAAA,gBAAAA,aAAA,GAAAA,aAAA,CAAAI,OAAA;MACT,IAAAD,UAAA","ignoreList":[]}
|
package/dist/esm/index.test.mjs
CHANGED
|
@@ -4,33 +4,46 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
describe("resolvePath", () => {
|
|
5
5
|
describe("basic resolution", () => {
|
|
6
6
|
it("resolves node builtins", () => {
|
|
7
|
-
expect(resolvePath("node:path")).toBe("node:path")
|
|
8
|
-
|
|
7
|
+
expect(resolvePath("node:path")).toBe("node:path");
|
|
8
|
+
expect(resolvePath("node:fs")).toBe("node:fs");
|
|
9
|
+
});
|
|
10
|
+
it("resolves npm packages", () => {
|
|
9
11
|
const path = resolvePath("vitest");
|
|
10
|
-
expect(path).toBeTruthy()
|
|
11
|
-
|
|
12
|
+
expect(path).toBeTruthy();
|
|
13
|
+
expect(existsSync(path)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it("resolves relative paths from cwd", () => {
|
|
12
16
|
const path = resolvePath("./package.json");
|
|
13
|
-
expect(path).toContain("package.json")
|
|
17
|
+
expect(path).toContain("package.json");
|
|
18
|
+
expect(existsSync(path)).toBe(true);
|
|
14
19
|
});
|
|
15
|
-
})
|
|
20
|
+
});
|
|
21
|
+
describe("respects from parameter", () => {
|
|
16
22
|
it("resolves relative paths from specified directory", () => {
|
|
17
23
|
const path = resolvePath("./package.json", process.cwd());
|
|
18
|
-
expect(path).toBe(process.cwd() + "/package.json")
|
|
19
|
-
|
|
24
|
+
expect(path).toBe(process.cwd() + "/package.json");
|
|
25
|
+
expect(existsSync(path)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
it("resolves npm packages from specified directory", () => {
|
|
20
28
|
const path = resolvePath("vitest", process.cwd());
|
|
21
29
|
expect(path).toContain("vitest");
|
|
22
30
|
});
|
|
23
|
-
})
|
|
31
|
+
});
|
|
32
|
+
describe("ESM entry point detection", () => {
|
|
24
33
|
it('returns ESM entry when exports["."].import is a string', () => {
|
|
25
34
|
const path = resolvePath("@vxrn/resolve", process.cwd());
|
|
26
35
|
expect(path).toBeTruthy();
|
|
27
|
-
})
|
|
36
|
+
});
|
|
37
|
+
it('returns ESM entry when exports["."].import.default exists', () => {
|
|
28
38
|
const path = resolvePath("vitest", process.cwd());
|
|
29
|
-
expect(path).toContain("dist/index.js")
|
|
30
|
-
|
|
39
|
+
expect(path).toContain("dist/index.js");
|
|
40
|
+
expect(path).not.toContain(".cjs");
|
|
41
|
+
});
|
|
42
|
+
it("falls back to module field when exports not available", () => {
|
|
31
43
|
const path = resolvePath("vitest", process.cwd());
|
|
32
44
|
expect(path).toBeTruthy();
|
|
33
|
-
})
|
|
45
|
+
});
|
|
46
|
+
it("falls back to main/require.resolve when no ESM entry", () => {
|
|
34
47
|
const path = resolvePath("resolve", process.cwd());
|
|
35
48
|
expect(path).toContain("resolve");
|
|
36
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","expect","it","resolvePath","existsSync","toBe","path","toBeTruthy","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAE3BJ,QAAA,CAAS,eAAe,MAAM;EAC5BA,QAAA,CAAS,oBAAoB,MAAM;IACjCE,EAAA,CAAG,0BAA0B,MAAM;MACjCD,MAAA,CAAOE,WAAA,CAAY,WAAW,CAAC,EAAEE,IAAA,CAAK,WAAW,
|
|
1
|
+
{"version":3,"names":["describe","expect","it","resolvePath","existsSync","toBe","path","toBeTruthy","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAE3BJ,QAAA,CAAS,eAAe,MAAM;EAC5BA,QAAA,CAAS,oBAAoB,MAAM;IACjCE,EAAA,CAAG,0BAA0B,MAAM;MACjCD,MAAA,CAAOE,WAAA,CAAY,WAAW,CAAC,EAAEE,IAAA,CAAK,WAAW;MACjDJ,MAAA,CAAOE,WAAA,CAAY,SAAS,CAAC,EAAEE,IAAA,CAAK,SAAS;IAC/C,CAAC;IAEDH,EAAA,CAAG,yBAAyB,MAAM;MAChC,MAAMI,IAAA,GAAOH,WAAA,CAAY,QAAQ;MACjCF,MAAA,CAAOK,IAAI,EAAEC,UAAA,CAAW;MACxBN,MAAA,CAAOG,UAAA,CAAWE,IAAI,CAAC,EAAED,IAAA,CAAK,IAAI;IACpC,CAAC;IAEDH,EAAA,CAAG,oCAAoC,MAAM;MAC3C,MAAMI,IAAA,GAAOH,WAAA,CAAY,gBAAgB;MACzCF,MAAA,CAAOK,IAAI,EAAEE,SAAA,CAAU,cAAc;MACrCP,MAAA,CAAOG,UAAA,CAAWE,IAAI,CAAC,EAAED,IAAA,CAAK,IAAI;IACpC,CAAC;E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AI,CAAC;MACjDT,MAAA,CAAOK,IAAI,EAAEE,SAAA,CAAU,SAAS;IAClC,CAAC;EACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -4,33 +4,46 @@ import { existsSync } from "fs";
|
|
|
4
4
|
describe("resolvePath", function () {
|
|
5
5
|
describe("basic resolution", function () {
|
|
6
6
|
it("resolves node builtins", function () {
|
|
7
|
-
expect(resolvePath("node:path")).toBe("node:path")
|
|
8
|
-
|
|
7
|
+
expect(resolvePath("node:path")).toBe("node:path");
|
|
8
|
+
expect(resolvePath("node:fs")).toBe("node:fs");
|
|
9
|
+
});
|
|
10
|
+
it("resolves npm packages", function () {
|
|
9
11
|
var path = resolvePath("vitest");
|
|
10
|
-
expect(path).toBeTruthy()
|
|
11
|
-
|
|
12
|
+
expect(path).toBeTruthy();
|
|
13
|
+
expect(existsSync(path)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it("resolves relative paths from cwd", function () {
|
|
12
16
|
var path = resolvePath("./package.json");
|
|
13
|
-
expect(path).toContain("package.json")
|
|
17
|
+
expect(path).toContain("package.json");
|
|
18
|
+
expect(existsSync(path)).toBe(true);
|
|
14
19
|
});
|
|
15
|
-
})
|
|
20
|
+
});
|
|
21
|
+
describe("respects from parameter", function () {
|
|
16
22
|
it("resolves relative paths from specified directory", function () {
|
|
17
23
|
var path = resolvePath("./package.json", process.cwd());
|
|
18
|
-
expect(path).toBe(process.cwd() + "/package.json")
|
|
19
|
-
|
|
24
|
+
expect(path).toBe(process.cwd() + "/package.json");
|
|
25
|
+
expect(existsSync(path)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
it("resolves npm packages from specified directory", function () {
|
|
20
28
|
var path = resolvePath("vitest", process.cwd());
|
|
21
29
|
expect(path).toContain("vitest");
|
|
22
30
|
});
|
|
23
|
-
})
|
|
31
|
+
});
|
|
32
|
+
describe("ESM entry point detection", function () {
|
|
24
33
|
it('returns ESM entry when exports["."].import is a string', function () {
|
|
25
34
|
var path = resolvePath("@vxrn/resolve", process.cwd());
|
|
26
35
|
expect(path).toBeTruthy();
|
|
27
|
-
})
|
|
36
|
+
});
|
|
37
|
+
it('returns ESM entry when exports["."].import.default exists', function () {
|
|
28
38
|
var path = resolvePath("vitest", process.cwd());
|
|
29
|
-
expect(path).toContain("dist/index.js")
|
|
30
|
-
|
|
39
|
+
expect(path).toContain("dist/index.js");
|
|
40
|
+
expect(path).not.toContain(".cjs");
|
|
41
|
+
});
|
|
42
|
+
it("falls back to module field when exports not available", function () {
|
|
31
43
|
var path = resolvePath("vitest", process.cwd());
|
|
32
44
|
expect(path).toBeTruthy();
|
|
33
|
-
})
|
|
45
|
+
});
|
|
46
|
+
it("falls back to main/require.resolve when no ESM entry", function () {
|
|
34
47
|
var path = resolvePath("resolve", process.cwd());
|
|
35
48
|
expect(path).toContain("resolve");
|
|
36
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","expect","it","resolvePath","existsSync","toBe","path","toBeTruthy","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAE3BJ,QAAA,CAAS,eAAe,YAAM;EAC5BA,QAAA,CAAS,oBAAoB,YAAM;IACjCE,EAAA,CAAG,0BAA0B,YAAM;MACjCD,MAAA,CAAOE,WAAA,CAAY,WAAW,CAAC,EAAEE,IAAA,CAAK,WAAW,
|
|
1
|
+
{"version":3,"names":["describe","expect","it","resolvePath","existsSync","toBe","path","toBeTruthy","toContain","process","cwd","not"],"sources":["../../src/index.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAE3BJ,QAAA,CAAS,eAAe,YAAM;EAC5BA,QAAA,CAAS,oBAAo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AAC,GAAQ,GAAI;MAEtDT,MAAA,CAAOK,IAAI,EAAEC,UAAA,CAAW;IAC1B,CAAC;IAEDL,EAAA,CAAG,6DAA6D,YAAM;MAEpE,IAAAI,IAAM,GAAAH,WAAO,SAAY,EAAAM,OAAU,CAAAC,GAAQ,GAAI;MAC/CT,MAAA,CAAOK,IAAI,EAAEE,SAAA,CAAU,eAAe;MACtCP,MAAA,CAAOK,IAAI,EAAEK,GAAA,CAAIH,SAAA,CAAU,MAAM;IACnC,CAAC;IAEDN,EAAA,CAAG,yDAAyD,YAAM;MAEhE,IAAAI,IAAM,GAAAH,WAAO,SAAY,EAAAM,OAAU,CAAAC,GAAQ,GAAI;MAC/CT,MAAA,CAAOK,IAAI,EAAEC,UAAA,CAAW;IAC1B,CAAC;IAEDL,EAAA,CAAG,wDAAwD,YAAM;MAE/D,IAAAI,IAAM,GAAAH,WAAO,UAAY,EAAAM,OAAW,CAAAC,GAAQ,GAAI;MAChDT,MAAA,CAAOK,IAAI,EAAEE,SAAA,CAAU,SAAS;IAClC,CAAC;EACH,CAAC;AACH,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/resolve",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "2.0.0-rc.
|
|
34
|
+
"@tamagui/build": "2.0.0-rc.36-1775258360494",
|
|
35
35
|
"vitest": "^4.1.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|