Skip to content

Commit a090181

Browse files
authored
chore(docs): add doc for --previewVersion (#537)
1 parent a9b9f0c commit a090181

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pnpm exec pkg-pr-new publish './artifacts/*.tgz'
146146
```
147147

148148
> [!NOTE]
149-
> Prebuilt tarballs are uploaded **as-is**: pkg.pr.new will not repack them. If one tarball references another tarball being published in the same call, pkg.pr.new will print a warning and that reference will not be rewritten to a pkg.pr.new URL. Repack with the resolved version yourself if you need cross-package linking.
149+
> Prebuilt tarballs are uploaded **as-is**: pkg.pr.new will not repack them. If one tarball references another tarball being published in the same call, pkg.pr.new will print a warning and that reference will not be rewritten to a pkg.pr.new URL. Repack with the resolved version yourself if you need cross-package linking. `--previewVersion` is also unsupported with prebuilt tarballs for the same reason.
150150
151151
> [!CAUTION]
152152
> In CI environments, avoid `npx`, `pnpm dlx`, `yarn dlx`, and `bunx` for this step. Install `pkg-pr-new` as a dependency and execute it from the lockfile (`npm exec`, `pnpm exec`, `yarn`, or `bun run`).
@@ -203,6 +203,20 @@ Without `--bin`:
203203
npm i https://pkg.pr.new/pkg-pr-new@a832a55
204204
```
205205

206+
By default, preview packages keep the `version` from your source `package.json`. That can clash with a later npm release of the same version: a lockfile may keep resolving `1.0.0` to the pkg.pr.new tarball instead of the published package.
207+
208+
Use `--previewVersion` to rewrite every published package's `version` to `0.0.0-preview-<sha>` before packing (working tree is restored afterward):
209+
210+
```sh
211+
pnpm exec pkg-pr-new publish --previewVersion './packages/*'
212+
```
213+
214+
For example, `1.0.0` becomes `0.0.0-preview-a832a55`. The `0.0.0-` prefix cannot satisfy a normal semver range for a real release, so lockfile collisions with npm versions are avoided.
215+
216+
In monorepos, sibling `dependencies` / `devDependencies` / `optionalDependencies` are still rewritten to pkg.pr.new URLs as usual. With `--peerDeps`, cross-package `peerDependencies` are updated to the preview version as well.
217+
218+
> [!NOTE] > `--previewVersion` only works with source directories. It is not supported when publishing prebuilt `.tgz` / `.tar.gz` inputs — rewrite the version before packing, or pass directories instead.
219+
206220
You can control publishing comments with `--comment`:
207221

208222
```sh

0 commit comments

Comments
 (0)