Skip to content

Commit aa754f6

Browse files
committed
Add ignoredBuiltDependencies and onlyBuiltDependencies
1 parent 4f5b2b1 commit aa754f6

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

packages/create-vue-lib/src/template/base/config/pnpm-workspace.yaml.ejs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ packages:
1010
- 'playground'
1111
<%_ } _%>
1212
<%_ } _%>
13+
14+
ignoredBuiltDependencies:
15+
- simple-git-hooks
16+
17+
onlyBuiltDependencies:
18+
<%_ if (config.includeTailwind) { _%>
19+
- '@tailwindcss/oxide'
20+
<%_ } _%>
21+
- esbuild

packages/docs/src/why.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ Many projects also use `simple-git-hooks` to impose restrictions on the commit m
5656

5757
We use a `postinstall` target in `scripts` to update the git hooks, ensuring they stay up to date for anyone developing the package. The documentation for `simple-git-hooks` warns against doing that, but it's important to note that the `postinstall` is in the project's root `package.json`, not the `package.json` that's published to the npm registry. It's only a problem if it's published to the registry.
5858

59+
`simple-git-hooks` also includes its own `postinstall` script. It's similar to our project's `postinstall`, but it only runs when `simple-git-hooks` is first installed. As it's redundant it's disabled via `ignoredBuiltDependencies` in `pnpm-workspace.yaml`.
60+
61+
## `pnpm-workspace.yaml`
62+
63+
Since version 10, pnpm no longer runs `postinstall` scripts in the packages it installs, instead showing a warning. To avoid the warning, these need to be explicitly enabled or disabled in `pnpm-workspace.yaml`, using `onlyBuiltDependencies` or `ignoredBuiltDependencies` respectively.
64+
65+
There are 3 packages where this is currently relevant:
66+
67+
- `simple-git-hooks` - disabled. The `postinstall` script installs the hooks, but the scaffolded project already has its own `postinstall` target that does the same thing.
68+
- `esbuild` - enabled. This is a dependency of Vite. The `postinstall` script checks the installation is correct and attempts to fix it if not. It also performs some performance tweaks. See [esbuild#4085](https://github.com/evanw/esbuild/issues/4085) and [esbuild#4288](https://github.com/evanw/esbuild/issues/4288) for more information.
69+
- `@tailwindcss/oxide` - enabled. The `postinstall` script checks the installation is correct and attempts to fix it if not. See [tailwindcss#17929](https://github.com/tailwindlabs/tailwindcss/pull/17929) for more information.
70+
71+
Both `esbuild` and `@tailwindcss/oxide` have platform-specific binaries that are listed as `optionalDependencies` in their `package.json` files. These should be installed automatically by pnpm, but in some edge cases that can fail and the `postinstall` script will attempt to fix that problem by installing those binaries directly. In normal usage that shouldn't be required.
72+
73+
It should be safe to disable all of these `postinstall` scripts in `pnpm-workspace.yaml` if you prefer.
74+
5975
## `.gitignore`
6076

6177
The `.gitignore` is similar to `create-vue`.

pnpm-workspace.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
packages:
22
- 'packages/*'
3+
4+
ignoredBuiltDependencies:
5+
- simple-git-hooks
6+
7+
onlyBuiltDependencies:
8+
- esbuild

0 commit comments

Comments
 (0)