Skip to content

Commit 3f99fbb

Browse files
committed
More docs about publishing to npm
1 parent 940cd79 commit 3f99fbb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/docs/src/publishing.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ You should review that file carefully to ensure it has all the fields set correc
3030

3131
When that file is first created it will contain `"private": true`. That prevents the library from being published by accident. You'll need to remove that line when you're ready to make your first release.
3232

33+
## Check `dependencies` and `peerDependencies`
34+
35+
If you've only worked on applications, you might be used to bumping dependency versions to ensure they're as recent as possible.
36+
37+
But when you're publishing a library you need to be a bit more careful. For example, not every application that wants to use your library will be on the latest version of Vue. You need to decide what the minimum version you want to support is, and test that it actually works against that version.
38+
39+
You also need to be careful about exactly where each dependency is placed: `dependencies`, `peerDependencies` and/or `devDependencies`. In an application it often doesn't matter if dependencies are in the wrong section, but for a library it's important to have everything in the right place.
40+
41+
The default project created by this tool won't have a `dependencies` section, with `vue` listed in `peerDependencies` instead. All other dependencies will be in `devDependencies`, as they're only used to develop the library and aren't needed in the consuming application.
42+
43+
If you've added other dependencies to `dependencies` or `peerDependencies` then you may also need to add them to the `rollupOptions` section of `vite.config.mts`, otherwise they may be bundled in with you library.
44+
45+
## Install dependencies
46+
47+
Ensure your local `node_modules` directory is synced up with the latest code:
48+
49+
```sh
50+
pnpm install
51+
```
52+
3353
## Check the build
3454

3555
You need to build the project before publishing:
@@ -50,7 +70,7 @@ pnpm publish --tag=latest --access=public --dry-run --publish-branch=main
5070

5171
If you have local files that aren't checked into git then you may need to add `--no-git-checks` too.
5272

53-
The dry run will show which files are going to be included in the published package. pnpm should automatically include the `LICENSE` file, taken from the workspace root. The `README.md` isn't taken from the workspace root, so that's copied as part of the build. You should also see `package.json` and the files in `dist`. Files from `src` shouldn't be needed.
73+
The dry run will show which files are going to be included in the published package. pnpm should automatically include the `LICENSE` file, taken from the workspace root. The `README.md` isn't automatically taken from the workspace root, so that's copied as part of the build. You should also see `package.json` and the files in `dist`. Files from `src` shouldn't be needed.
5474

5575
## Authenticating
5676

0 commit comments

Comments
 (0)