Added `publishConfig` for public access in package.json and enhanced build scripts with prepublish and packing hooks. Removed outdated example code and streamlined the README.md to focus on essential package functionality and tooling, improving clarity for users.
16 lines
786 B
JavaScript
16 lines
786 B
JavaScript
// npm ignores publishConfig field overrides, so the tarball's exports are
|
|
// rewritten here to point at dist; postpack.mjs restores the src exports
|
|
// that workspace consumers (Vite) rely on.
|
|
import { copyFileSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
|
const pkgPath = new URL("../package.json", import.meta.url);
|
|
copyFileSync(pkgPath, new URL("../package.json.orig", import.meta.url));
|
|
|
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
pkg.exports = {
|
|
".": { types: "./dist/index.d.ts", default: "./dist/index.js" },
|
|
"./jsx-runtime": { types: "./dist/jsx-runtime.d.ts", default: "./dist/jsx-runtime.js" },
|
|
"./jsx-dev-runtime": { types: "./dist/jsx-runtime.d.ts", default: "./dist/jsx-runtime.js" },
|
|
};
|
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|