From 59da53442c8468636704964511dcfd2f92c85e19 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Mon, 28 Sep 2026 09:21:22 -0700 Subject: [PATCH] feat: export package.json The exports map listed only `.`, so `require("htmljs-parser/package.json")` threw `ERR_PACKAGE_PATH_NOT_EXPORTED` and tools could not report which parser version they run on. Co-Authored-By: Claude Opus 5.5 (1M context) --- .changeset/export-package-json.md | 5 +++++ .../items/2026-08-20-expose-package-json-export.md | 12 ------------ package.json | 3 ++- 3 files changed, 7 insertions(+), 13 deletions(-) create mode 100644 .changeset/export-package-json.md delete mode 100644 agent-feedback/items/2026-08-20-expose-package-json-export.md diff --git a/.changeset/export-package-json.md b/.changeset/export-package-json.md new file mode 100644 index 0000000..b87e470 --- /dev/null +++ b/.changeset/export-package-json.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": minor +--- + +Export `./package.json`, so tools can read which parser version they run on with `require("htmljs-parser/package.json")`. diff --git a/agent-feedback/items/2026-08-20-expose-package-json-export.md b/agent-feedback/items/2026-08-20-expose-package-json-export.md deleted file mode 100644 index efaa5a9..0000000 --- a/agent-feedback/items/2026-08-20-expose-package-json-export.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -type: cleanup -impact: low -effort: low -site: package.json › exports ---- - -# Expose `./package.json` from the exports map - -The exports map lists only `.`, so `require("htmljs-parser/package.json")` throws `ERR_PACKAGE_PATH_NOT_EXPORTED`, and `src/index.ts` exports no `version` either, leaving any tool that reports which parser build it is running on to read the file by hand. The hand-rolled workaround is ambiguous: `grep -o '"version": *"[^"]*"' package.json` matches both the field and the `version` npm script. `@marko/runtime-tags` already maps `"./package.json": "./package.json"`, so the parser every Marko tool depends on is the one package in the chain that cannot report its own version. - -Check: `node -e "require('htmljs-parser/package.json')"` from a project with htmljs-parser installed prints `Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports"`; it should resolve to the file. diff --git a/package.json b/package.json index f2b67ba..82efa0c 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ ".": { "import": "./dist/index.mjs", "default": "./dist/index.js" - } + }, + "./package.json": "./package.json" }, "main": "./dist/index.js", "module": "./dist/index.mjs",