Skip to content

Commit 57ebac3

Browse files
committed
FIXUP
1 parent 785ab86 commit 57ebac3

1 file changed

Lines changed: 42 additions & 18 deletions

File tree

crates/vite_task/docs/rfc-add-remove-package-commands.md

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ vite add -D typescript @types/react
7575
vite add react -E
7676

7777
# Add peer dependency
78-
vite add -P react
78+
vite add --save-peer react
7979

8080
# Add optional dependency
8181
vite add -O sharp
@@ -88,6 +88,18 @@ vite add react --filter "app*" # Add to multiple packages (pattern)
8888
vite add utils --filter "!@myorg/core" # Exclude packages
8989
```
9090

91+
##### `vite install` Command with `PACKAGES` arguments
92+
93+
To accommodate the user habits and experience of `npm install <PACKAGES>…`, `vite install <PACKAGES>...` will be specially treated as an alias for the add command.
94+
95+
The following commands will be automatically converted to the add command for processing:
96+
97+
```bash
98+
vite install <PACKAGES>... [OPTIONS]
99+
100+
-> vite add <PACKAGES>... [OPTIONS]
101+
```
102+
91103
#### Remove Command
92104

93105
```bash
@@ -117,28 +129,40 @@ vite remove -g typescript # Remove global package
117129

118130
#### Add Command Mapping
119131

120-
| Vite+ Flag | pnpm | yarn | npm | Description |
121-
| ---------------------- | ------------------------ | --------------------- | --------------------------- | --------------------------------------------------- |
122-
| `<packages>` | `add <packages>` | `add <packages>` | `install <packages>` | Add packages |
123-
| `--filter <pattern>` | `--filter <pattern> add` | `workspace <pkg> add` | `install --workspace <pkg>` | Target specific workspace package(s) |
124-
| `-w, --workspace-root` | `-w` | `-W` | `-w` | Add to workspace root (ignore-workspace-root-check) |
125-
| `--workspace` | `--workspace` | N/A | N/A | Only add if found in workspace (pnpm-specific) |
126-
| `-D, --save-dev` | `-D` | `--dev` / `-D` | `--save-dev` / `-D` | Add as dev dependency |
127-
| `-P, --save-peer` | `--save-peer` | `--peer` / `-P` | `--save-peer` | Add as peer dependency |
128-
| `-O, --save-optional` | `-O` | `--optional` / `-O` | `--save-optional` / `-O` | Add as optional dependency |
129-
| `-E, --save-exact` | `-E` | `--exact` / `-E` | `--save-exact` / `-E` | Save exact version |
130-
| `-g, --global` | `-g` | `global add` | `--global` / `-g` | Install globally |
132+
- https://pnpm.io/cli/add#options
133+
- https://yarnpkg.com/cli/add#options
134+
- https://docs.npmjs.com/cli/v11/commands/npm-install#description
135+
136+
| Vite+ Flag | pnpm | yarn | npm | Description |
137+
| ------------------------------------ | ------------------------ | --------------------- | --------------------------- | --------------------------------------------------- |
138+
| `<packages>` | `add <packages>` | `add <packages>` | `install <packages>` | Add packages |
139+
| `--filter <pattern>` | `--filter <pattern> add` | `workspace <pkg> add` | `install --workspace <pkg>` | Target specific workspace package(s) |
140+
| `-w, --workspace-root` | `-w` | `-W` | `-w` | Add to workspace root (ignore-workspace-root-check) |
141+
| `--workspace` | `--workspace` | N/A | N/A | Only add if found in workspace (pnpm-specific) |
142+
| `-P, --save-prod` | `--save-prod` / `-P` | N/A | `--save-prod` / `-P` | Save to `dependencies`. The default behavior |
143+
| `-D, --save-dev` | `-D` | `--dev` / `-D` | `--save-dev` / `-D` | Save to `devDependencies` |
144+
| `--save-peer` | `--save-peer` | `--peer` / `-P` | `--save-peer` | Save to `peerDependencies` and `devDependencies` |
145+
| `-O, --save-optional` | `-O` | `--optional` / `-O` | `--save-optional` / `-O` | Save to `optionalDependencies` |
146+
| `-E, --save-exact` | `-E` | `--exact` / `-E` | `--save-exact` / `-E` | Save exact version |
147+
| `-g, --global` | `-g` | `global add` | `--global` / `-g` | Install globally |
148+
| `--save-catalog` | `--save-catalog` | `--save-catalog` | N/A | Save the new dependency to the default catalog |
149+
| `--save-catalog-name <catalog_name>` | SAME | N/A | N/A | Save the new dependency to the specified catalog |
150+
| `--allow-build <names>` | SAME | N/A | N/A | A list of package names allowed to run postinstall |
131151

132152
**Note**: For pnpm, `--filter` must come before the command (e.g., `pnpm --filter app add react`). For yarn/npm, it's integrated into the command structure.
133153

134154
#### Remove Command Mapping
135155

136-
| Vite+ Flag | pnpm | yarn | npm | Description |
137-
| ---------------------- | --------------------------- | ------------------------ | ----------------------------- | ------------------------------------ |
138-
| `<packages>` | `remove <packages>` | `remove <packages>` | `uninstall <packages>` | Remove packages |
139-
| `--filter <pattern>` | `--filter <pattern> remove` | `workspace <pkg> remove` | `uninstall --workspace <pkg>` | Target specific workspace package(s) |
140-
| `-w, --workspace-root` | `-w` | (default) | (default) | Remove from workspace root |
141-
| `-g, --global` | `-g` | `global remove` | `--global` / `-g` | Remove global packages |
156+
| Vite+ Flag | pnpm | yarn | npm | Description |
157+
| ---------------------- | --------------------------- | ------------------------ | ----------------------------- | ---------------------------------------------- |
158+
| `<packages>` | `remove <packages>` | `remove <packages>` | `uninstall <packages>` | Remove packages |
159+
| `-D, --save-dev` | `-D` | `--dev` / `-D` | `--save-dev` / `-D` | Only remove from `devDependencies` |
160+
| `-O, --save-optional` | `-O` | `--optional` / `-O` | `--save-optional` / `-O` | Only remove from `optionalDependencies` |
161+
| `-P, --save-prod` | `-P` | `--save-prod` / `-P` | `--save-prod` / `-P` | Only remove from `dependencies` |
162+
| `--filter <pattern>` | `--filter <pattern> remove` | `workspace <pkg> remove` | `uninstall --workspace <pkg>` | Target specific workspace package(s) |
163+
| `-w, --workspace-root` | `-w` | (default) | (default) | Remove from workspace root |
164+
| `-r, --recursive` | `-r` | `--recursive` / `-r` | `--recursive` / `-r` | Remove recursively from all workspace packages |
165+
| `-g, --global` | `-g` | `global remove` | `--global` / `-g` | Remove global packages |
142166

143167
**Note**: Similar to add, `--filter` must precede the command for pnpm.
144168

0 commit comments

Comments
 (0)