diff --git a/package-lock.json b/package-lock.json index b4766a0..3c79089 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cldmv/uuid", - "version": "1.1.6", + "version": "1.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cldmv/uuid", - "version": "1.1.6", + "version": "1.1.7", "license": "Apache-2.0", "devDependencies": { "@cldmv/fix-headers": "^1.2.2", diff --git a/package.json b/package.json index 1ac1c4a..7665aae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cldmv/uuid", - "version": "1.1.6", + "version": "1.1.7", "description": "Extended RFC 4122 and RFC 9562 UUID implementation with custom variant structures, issuer-based identification, and timestamp variants", "main": "./index.cjs", "module": "./index.mjs", @@ -16,7 +16,8 @@ "import": "./src/uuid.mjs" }, "import": "./dist/uuid.mjs" - } + }, + "./package.json": "./package.json" }, "type": "module", "engines": { diff --git a/tests/package-exports.test.vitest.mjs b/tests/package-exports.test.vitest.mjs new file mode 100644 index 0000000..4a4a0f7 --- /dev/null +++ b/tests/package-exports.test.vitest.mjs @@ -0,0 +1,40 @@ +/** + * @Project: @cldmv/uuid + * @Filename: /tests/package-exports.test.vitest.mjs + * @Date: 2026-08-09T00:00:00-08:00 (1786233600) + * @Author: Nate Corcoran + * @Email: + * ----- + * @Last modified by: Nate Corcoran (Shinrai@users.noreply.github.com) + * @Last modified time: 2026-08-09T00:00:00-08:00 (1786233600) + * ----- + * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved. + */ + +import { test, expect, describe } from "vitest"; +import { readFileSync } from "node:fs"; +import { spawnSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); + +describe("package exports", () => { + test("the exports map exposes ./package.json", () => { + // Tooling resolves `/package.json` to locate a package's directory on disk; + // omitting it from `exports` makes that throw ERR_PACKAGE_PATH_NOT_EXPORTED. (#6) + const pkg = JSON.parse(readFileSync(path.join(repoRoot, "package.json"), "utf8")); + expect(pkg.exports["./package.json"]).toBe("./package.json"); + }); + + test("Node can resolve @cldmv/uuid/package.json through the exports map", () => { + // Real Node resolution (self-referencing the package by name from the repo root), + // not Vitest's resolver — before the fix this exits non-zero with + // ERR_PACKAGE_PATH_NOT_EXPORTED. + const res = spawnSync(process.execPath, ["--input-type=module", "-e", "import.meta.resolve('@cldmv/uuid/package.json');"], { + cwd: repoRoot, + encoding: "utf8" + }); + expect(res.status).toBe(0); + }); +});