Skip to content

Commit cc5646e

Browse files
committed
chore: merge main
2 parents 95d3eb8 + a5e98e6 commit cc5646e

File tree

63 files changed

+1469
-1089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1469
-1089
lines changed

docs/.vitepress/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,11 @@ export default defineConfig({
486486
languages: ['ts', 'js', 'json'],
487487
codeTransformers: [transformerTwoslash()],
488488
config(md) {
489-
md.use(groupIconMdPlugin)
489+
md.use(groupIconMdPlugin, {
490+
titleBar: {
491+
includeSnippet: true,
492+
},
493+
})
490494
md.use(markdownItImageSize, {
491495
publicDir: path.resolve(import.meta.dirname, '../public'),
492496
})

docs/guide/api-environment-plugins.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ The hook can choose to:
146146
147147
## Per-environment State in Plugins
148148
149-
Given that the same plugin instance is used for different environments, the plugin state needs to be keyed with `this.environment`. This is the same pattern the ecosystem has already been using to keep state about modules using the `ssr` boolean as key to avoid mixing client and ssr modules state. A `Map<Environment, State>` can be used to keep the state for each environment separately. Note that for backward compatibility, `buildStart` and `buildEnd` are only called for the client environment without the `perEnvironmentStartEndDuringDev: true` flag.
149+
Given that the same plugin instance is used for different environments, the plugin state needs to be keyed with `this.environment`. This is the same pattern the ecosystem has already been using to keep state about modules using the `ssr` boolean as key to avoid mixing client and ssr modules state. A `Map<Environment, State>` can be used to keep the state for each environment separately. Note that for backward compatibility, `buildStart` and `buildEnd` are only called for the client environment without the `perEnvironmentStartEndDuringDev: true` flag. Same for `watchChange` and the `perEnvironmentWatchChangeDuringDev: true` flag.
150150
151151
```js
152152
function PerEnvironmentCountTransformedModulesPlugin() {
@@ -227,6 +227,43 @@ export default defineConfig({
227227
228228
The `applyToEnvironment` hook is called at config time, currently after `configResolved` due to projects in the ecosystem modifying the plugins in it. Environment plugins resolution may be moved before `configResolved` in the future.
229229
230+
## Application-Plugin Communication
231+
232+
`environment.hot` allows plugins to communicate with the code on the application side for a given environment. This is the equivalent of [the Client-server Communication feature](/guide/api-plugin#client-server-communication), but supports environments other than the client environment.
233+
234+
:::warning Note
235+
236+
Note that this feature is only available for environments that supports HMR.
237+
238+
:::
239+
240+
### Managing the Application Instances
241+
242+
Be aware that there might be multiple application instances running in the same environment. For example, if you multiple tabs open in the browser, each tab is a separate application instance and have a separate connection to the server.
243+
244+
When a new connection is established, a `vite:client:connect` event is emitted on the environment's `hot` instance. When the connection is closed, a `vite:client:disconnect` event is emitted.
245+
246+
Each event handler receives the `NormalizedHotChannelClient` as the second argument. The client is an object with a `send` method that can be used to send messages to that specific application instance. The client reference is always the same for the same connection, so you can keep it to track the connection.
247+
248+
### Example Usage
249+
250+
The plugin side:
251+
252+
```js
253+
configureServer(server) {
254+
server.environments.ssr.hot.on('my:greetings', (data, client) => {
255+
// do something with the data,
256+
// and optionally send a response to that application instance
257+
client.send('my:foo:reply', `Hello from server! You said: ${data}`)
258+
})
259+
260+
// broadcast a message to all application instances
261+
server.environments.ssr.hot.send('my:foo', 'Hello from server!')
262+
}
263+
```
264+
265+
The application side is same with the Client-server Communication feature. You can use the `import.meta.hot` object to send messages to the plugin.
266+
230267
## Environment in Build Hooks
231268
232269
In the same way as during dev, plugin hooks also receive the environment instance during build, replacing the `ssr` boolean.

docs/guide/api-environment-runtimes.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,27 +316,45 @@ import { createServer, RemoteEnvironmentTransport, DevEnvironment } from 'vite'
316316
function createWorkerEnvironment(name, config, context) {
317317
const worker = new Worker('./worker.js')
318318
const handlerToWorkerListener = new WeakMap()
319+
const client = {
320+
send(payload: HotPayload) {
321+
worker.postMessage(payload)
322+
},
323+
}
319324

320325
const workerHotChannel = {
321326
send: (data) => worker.postMessage(data),
322327
on: (event, handler) => {
323-
if (event === 'connection') return
328+
// client is already connected
329+
if (event === 'vite:client:connect') return
330+
if (event === 'vite:client:disconnect') {
331+
const listener = () => {
332+
handler(undefined, client)
333+
}
334+
handlerToWorkerListener.set(handler, listener)
335+
worker.on('exit', listener)
336+
return
337+
}
324338

325339
const listener = (value) => {
326340
if (value.type === 'custom' && value.event === event) {
327-
const client = {
328-
send(payload) {
329-
worker.postMessage(payload)
330-
},
331-
}
332341
handler(value.data, client)
333342
}
334343
}
335344
handlerToWorkerListener.set(handler, listener)
336345
worker.on('message', listener)
337346
},
338347
off: (event, handler) => {
339-
if (event === 'connection') return
348+
if (event === 'vite:client:connect') return
349+
if (event === 'vite:client:disconnect') {
350+
const listener = handlerToWorkerListener.get(handler)
351+
if (listener) {
352+
worker.off('exit', listener)
353+
handlerToWorkerListener.delete(handler)
354+
}
355+
return
356+
}
357+
340358
const listener = handlerToWorkerListener.get(handler)
341359
if (listener) {
342360
worker.off('message', listener)
@@ -363,6 +381,8 @@ await createServer({
363381

364382
:::
365383

384+
Make sure to implement the `vite:client:connect` / `vite:client:disconnect` events in the `on` / `off` methods when those methods exist. `vite:client:connect` event should be emitted when the connection is established, and `vite:client:disconnect` event should be emitted when the connection is closed. The `HotChannelClient` object passed to the event handler must have the same reference for the same connection.
385+
366386
A different example using an HTTP request to communicate between the runner and the server:
367387

368388
```ts

docs/guide/rolldown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,4 @@ const plugin = {
345345
}
346346
```
347347

348-
This is because [Rolldown supports non-JavaScript modules](https://rolldown.rs/guide/in-depth/module-types) and infers the module type from extensions unless specified.
348+
This is because [Rolldown supports non-JavaScript modules](https://rolldown.rs/in-depth/module-types) and infers the module type from extensions unless specified.

docs/guide/static-deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Now the `preview` command will launch the server at `http://localhost:8080`.
6363

6464
2. Go to your GitHub Pages configuration in the repository settings page and choose the source of deployment as "GitHub Actions", this will lead you to create a workflow that builds and deploys your project, a sample workflow that installs dependencies and builds using npm is provided:
6565

66-
<<< ./static-deploy-github-pages.yaml#content
66+
<<< ./static-deploy-github-pages.yaml#content [.github/workflows/deploy.yml]
6767

6868
## GitLab Pages and GitLab CI
6969

docs/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"docs-serve": "vitepress serve"
1010
},
1111
"devDependencies": {
12-
"@shikijs/vitepress-twoslash": "^3.13.0",
13-
"@types/express": "^5.0.3",
12+
"@shikijs/vitepress-twoslash": "^3.14.0",
13+
"@types/express": "^5.0.4",
1414
"feed": "^5.1.0",
1515
"gsap": "^3.13.0",
1616
"markdown-it-image-size": "^15.0.1",
1717
"vitepress": "^2.0.0-alpha.12",
18-
"vitepress-plugin-group-icons": "^1.6.4",
19-
"vitepress-plugin-llms": "^1.8.0",
18+
"vitepress-plugin-group-icons": "^1.6.5",
19+
"vitepress-plugin-llms": "^1.8.1",
2020
"vue": "^3.5.22",
21-
"vue-tsc": "^3.1.1"
21+
"vue-tsc": "^3.1.2"
2222
}
2323
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@types/estree": "^1.0.8",
5151
"@types/etag": "^1.8.4",
5252
"@types/less": "^3.0.8",
53-
"@types/node": "^22.18.11",
53+
"@types/node": "^22.18.12",
5454
"@types/picomatch": "^4.0.2",
5555
"@types/stylus": "^0.48.43",
5656
"@types/ws": "^8.18.1",
@@ -61,7 +61,7 @@
6161
"eslint-plugin-regexp": "^2.10.0",
6262
"execa": "^9.6.0",
6363
"globals": "^16.4.0",
64-
"lint-staged": "^16.2.4",
64+
"lint-staged": "^16.2.6",
6565
"picocolors": "^1.1.1",
6666
"playwright-chromium": "^1.56.1",
6767
"prettier": "3.6.2",
@@ -70,7 +70,7 @@
7070
"simple-git-hooks": "^2.13.1",
7171
"tsx": "^4.20.6",
7272
"typescript": "~5.9.2",
73-
"typescript-eslint": "^8.46.1",
73+
"typescript-eslint": "^8.46.2",
7474
"vite": "workspace:*",
7575
"vitest": "^4.0.4"
7676
},
@@ -91,7 +91,7 @@
9191
"eslint --cache --fix"
9292
]
9393
},
94-
"packageManager": "pnpm@10.18.3",
94+
"packageManager": "pnpm@10.19.0",
9595
"stackblitz": {
9696
"startCommand": "pnpm --filter='./packages/vite' run dev"
9797
}

packages/create-vite/LICENSE

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ ISC, MIT
152152
## @clack/core, @clack/prompts
153153
License: MIT
154154
By: Nate Moore
155-
Repositories: git+https://github.com/bombshell-dev/clack.git, git+https://github.com/bombshell-dev/clack.git
155+
Repositories: https://github.com/bombshell-dev/clack, https://github.com/bombshell-dev/clack
156156

157157
> MIT License
158158
>
@@ -169,7 +169,7 @@ Repositories: git+https://github.com/bombshell-dev/clack.git, git+https://github
169169
## cross-spawn
170170
License: MIT
171171
By: André Cruz
172-
Repository: git@github.com:moxystudio/node-cross-spawn.git
172+
Repository: https://github.com/moxystudio/node-cross-spawn
173173

174174
> The MIT License (MIT)
175175
>
@@ -198,7 +198,7 @@ Repository: [email protected]:moxystudio/node-cross-spawn.git
198198
## isexe, which
199199
License: ISC
200200
By: Isaac Z. Schlueter
201-
Repositories: git+https://github.com/isaacs/isexe.git, git://github.com/isaacs/node-which.git
201+
Repositories: https://github.com/isaacs/isexe, https://github.com/isaacs/node-which
202202

203203
> The ISC License
204204
>
@@ -221,7 +221,7 @@ Repositories: git+https://github.com/isaacs/isexe.git, git://github.com/isaacs/n
221221
## mri
222222
License: MIT
223223
By: Luke Edwards
224-
Repository: lukeed/mri
224+
Repository: https://github.com/lukeed/mri
225225

226226
> The MIT License (MIT)
227227
>
@@ -250,7 +250,7 @@ Repository: lukeed/mri
250250
## path-key, shebang-regex
251251
License: MIT
252252
By: Sindre Sorhus
253-
Repositories: sindresorhus/path-key, sindresorhus/shebang-regex
253+
Repositories: https://github.com/sindresorhus/path-key, https://github.com/sindresorhus/shebang-regex
254254

255255
> MIT License
256256
>
@@ -267,7 +267,7 @@ Repositories: sindresorhus/path-key, sindresorhus/shebang-regex
267267
## picocolors
268268
License: ISC
269269
By: Alexey Raspopov
270-
Repository: alexeyraspopov/picocolors
270+
Repository: https://github.com/alexeyraspopov/picocolors
271271

272272
> ISC License
273273
>
@@ -290,7 +290,7 @@ Repository: alexeyraspopov/picocolors
290290
## shebang-command
291291
License: MIT
292292
By: Kevin Mårtensson
293-
Repository: kevva/shebang-command
293+
Repository: https://github.com/kevva/shebang-command
294294

295295
> MIT License
296296
>

packages/create-vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"cross-spawn": "^7.0.6",
3838
"mri": "^1.2.0",
3939
"picocolors": "^1.1.1",
40-
"tsdown": "^0.15.8"
40+
"tsdown": "^0.15.10"
4141
}
4242
}

packages/create-vite/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ async function init() {
661661

662662
if (useRolldownVite) {
663663
// renovate: datasource=npm depName=rolldown-vite
664-
const rolldownViteVersion = '7.1.17'
664+
const rolldownViteVersion = '7.1.19'
665665
const pkgVersion = `npm:rolldown-vite@${rolldownViteVersion}`
666666
pkg.devDependencies.vite = pkgVersion
667667
switch (pkgManager) {
@@ -777,7 +777,7 @@ function pkgFromUserAgent(userAgent: string | undefined): PkgInfo | undefined {
777777

778778
function setupReactSwc(root: string, isTs: boolean) {
779779
// renovate: datasource=npm depName=@vitejs/plugin-react-swc
780-
const reactSwcPluginVersion = '4.1.0'
780+
const reactSwcPluginVersion = '4.2.0'
781781

782782
editFile(path.resolve(root, 'package.json'), (content) => {
783783
return content.replace(

0 commit comments

Comments
 (0)