Closed waldronmatt closed 2 months ago
TIL about publishConfig:
This is a set of config values that will be used at publish-time.
Unfortunately, it appears that the config values are really only applied when you run npm publish
. They are ignored when you run npm pack
.
I was leaning towards no, and then...
EDIT: A previous version of this post recommended publishConfig, operating under the mistaken belief that it could be used to override "exports" during npm publish. As it turns out, npm only uses "publishConfig" to override certain .npmrc fields like registry and tag, whereas pnpm has expanded its use to override package metadata like "main", "types", and "exports". There are a number of reasons you may not wish to strongly couple your deployment logic to pnpm (detailed in the publishConfig section below). My updated recommendation is to use a custom export condition plus customConditions in tsconfig.json.
So, yeah. Yikes.
First I want to say thank you for this tool, it has been extremely helpful to ensure type compliance on packages.
I've recently adopted a technique in my monorepo where I use my package
exports
to point to sourcets
files so VS Code will reflect "live" types even across package boundaries. I usepublishConfig
to point toesm
/cjs
bundles which overridesexports
during the packing and publishing process to npm. This technique has been popularized by colinhacks (Zod author): https://colinhacks.com/essays/live-types-typescript-monorepoIt would be amazing if the cli could support parsing through
publishConfig
exports.