diff --git a/changes/hotupdate-hook.md b/changes/hotupdate-hook.md index 9a660c2d..c3decb0a 100644 --- a/changes/hotupdate-hook.md +++ b/changes/hotupdate-hook.md @@ -1,20 +1,20 @@ -# HMR `hotUpdate` Plugin Hook +# HMR `hotUpdate` プラグインフック -::: tip Feedback -Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) +::: tip フィードバック +[Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358)でフィードバックをお寄せください。 ::: -We're planning to deprecate the `handleHotUpdate` plugin hook in favor of [`hotUpdate` hook](/guide/api-environment#the-hotupdate-hook) to be [Environment API](/guide/api-environment.md) aware, and handle additional watch events with `create` and `delete`. +[Environment API](/guide/api-environment.md)を意識するために、`handleHotUpdate` プラグインフックを非推奨とし、[`hotUpdate` フック](/guide/api-environment#the-hotupdate-hook)を使用し、`create` と `delete` で追加の監視イベントを処理する予定です。 -Affected scope: `Vite Plugin Authors` +影響範囲: `Vite プラグイン作成者` -::: warning Future Deprecation -`hotUpdate` was first introduced in `v6.0`. The deprecation of `handleHotUpdate` is planned for `v7.0`. We don't yet recommend moving away from `handleHotUpdate` yet. If you want to experiment and give us feedback, you can use the `future.removePluginHookHandleHotUpdate` to `"warn"` in your vite config. +::: warning 将来の廃止予定 +`hotUpdate` は `v6.0` で初めて導入されました。`handleHotUpdate` の廃止は `v7.0` で予定されています。現時点では、まだ `handleHotUpdate` からの移行は推奨していません。もし実験して私たちにフィードバックをしたいのであれば、vite config で `future.removePluginHookHandleHotUpdate` を `"warn"` に指定してください。 ::: -## Motivation +## 動機 -The [`handleHotUpdate` hook](/guide/api-plugin.md#handlehotupdate) allows to perform custom HMR update handling. A list of modules to be updated is passed in the `HmrContext` +[`handleHotUpdate` フック](/guide/api-plugin.md#handlehotupdate) はカスタム HMR 更新処理を行うことができます。更新するモジュールのリストは `HmrContext` に渡されます ```ts interface HmrContext { @@ -26,9 +26,9 @@ interface HmrContext { } ``` -This hook is called once for all environments, and the passed modules have mixed information from the Client and SSR environments only. Once frameworks move to custom environments, a new hook that is called for each of them is needed. +このフックはすべての環境に対して一度だけ呼び出され、渡されたモジュールはクライアント環境と SSR 環境だけの情報が混在しています。フレームワークがカスタム環境に移行すると、それぞれの環境に対して呼び出される新しいフックが必要になります。 -The new `hotUpdate` hook works in the same way as `handleHotUpdate` but it is called for each environment and receives a new `HotUpdateContext` instance: +新しい `hotUpdate` フックは `handleHotUpdate` と同じように動作しますが、環境ごとに呼び出され、新しい `HotUpdateContext` インスタンスを受け取ります: ```ts interface HotUpdateContext { @@ -41,31 +41,31 @@ interface HotUpdateContext { } ``` -The current dev environment can be accessed like in other Plugin hooks with `this.environment`. The `modules` list will now be module nodes from the current environment only. Each environment update can define different update strategies. +現在の開発環境は他のプラグインフックのように `this.environment` でアクセスできます。`modules` のリストには現在の環境のモジュールノードのみが表示されます。各環境の更新は異なる更新ストラテジーを定義できます。 -This hook is also now called for additional watch events and not only for `'update'`. Use `type` to differentiate between them. +このフックは `'update'` だけでなく、追加の監視イベントでも呼び出されるようになりました。これらを区別するには `type` を使用します。 -## Migration Guide +## 移行ガイド -Filter and narrow down the affected module list so that the HMR is more accurate. +HMR がより正確になるように、影響を受けるモジュールのリストをフィルタリングして絞り込みます。 ```js handleHotUpdate({ modules }) { return modules.filter(condition) } -// Migrate to: +// 以下に移行: hotUpdate({ modules }) { return modules.filter(condition) } ``` -Return an empty array and perform a full reload: +空の配列を返して完全なリロードを実行します: ```js handleHotUpdate({ server, modules, timestamp }) { - // Invalidate modules manually + // モジュールを手動で無効化 const invalidatedModules = new Set() for (const mod of modules) { server.moduleGraph.invalidateModule( @@ -79,10 +79,10 @@ handleHotUpdate({ server, modules, timestamp }) { return [] } -// Migrate to: +// 以下に移行: hotUpdate({ modules, timestamp }) { - // Invalidate modules manually + // モジュールを手動で無効化 const invalidatedModules = new Set() for (const mod of modules) { this.environment.moduleGraph.invalidateModule( @@ -97,7 +97,7 @@ hotUpdate({ modules, timestamp }) { } ``` -Return an empty array and perform complete custom HMR handling by sending custom events to the client: +空の配列を返し、カスタムイベントをクライアントに送信することで、完全なカスタム HMR 処理を行います: ```js handleHotUpdate({ server }) { @@ -109,7 +109,7 @@ handleHotUpdate({ server }) { return [] } -// Migrate to... +// 以下に移行... hotUpdate() { this.environment.hot.send({ diff --git a/changes/index.md b/changes/index.md index 7607ae2d..7511f353 100644 --- a/changes/index.md +++ b/changes/index.md @@ -1,27 +1,27 @@ -# Breaking Changes +# 破壊的変更 -List of breaking changes in Vite including API deprecations, removals, and changes. Most of the changes below can be opt-in using the [`future` option](/config/shared-options.html#future) in your Vite config. +API の非推奨、削除、変更を含む、Vite の変更点のリストです。以下の変更のほとんどは、Vite の設定にある[`future` オプション](/config/shared-options.html#future)を使ってオプトインできます。 -## Planned +## 計画中 -These changes are planned for the next major version of Vite. The deprecation or usage warnings will guide you where possible, and we're reaching out to framework, plugin authors, and users to apply these changes. +これらの変更は Vite の次のメジャーバージョンで予定されています。非推奨または使用上の警告は、可能な限りガイドし、私たちはこれらの変更を適用するようフレームワーク、プラグイン作者、ユーザーに働きかけています。 -- _No planned changes yet_ +- _まだ変更予定はありません_ -## Considering +## 検討中 -These changes are being considered and are often experimental APIs that intend to improve upon current usage patterns. As not all changes are listed here, please check out the [Experimental Label in Vite GitHub Discussions](https://github.com/vitejs/vite/discussions/categories/feedback?discussions_q=label%3Aexperimental+category%3AFeedback) for the full list. +これらの変更は検討中であり、現在の使用パターンを改善するための実験的な API であることが多いです。すべての変更がここに記載されているわけではないので、完全なリストについては [Vite GitHub ディスカッションの experimental ラベル](https://github.com/vitejs/vite/discussions/categories/feedback?discussions_q=label%3Aexperimental+category%3AFeedback) を確認してください。 -We don't recommend switching to these APIs yet. They are included in Vite to help us gather feedback. Please check these proposals and let us know how they work in your use case in each's linked GitHub Discussions. +これらの API に切り替えることはまだお勧めしません。これらの API はフィードバックを集めるために Vite に含まれています。これらの提案を確認し、あなたのユースケースでどのように機能するか、それぞれのリンク先の GitHub Discussions でお知らせください。 -- [`this.environment` in Hooks](/changes/this-environment-in-hooks) -- [HMR `hotUpdate` Plugin Hook](/changes/hotupdate-hook) -- [Move to per-environment APIs](/changes/per-environment-apis) -- [SSR using `ModuleRunner` API](/changes/ssr-using-modulerunner) -- [Shared plugins during build](/changes/shared-plugins-during-build) +- [フック内の `this.environment`](/changes/this-environment-in-hooks) +- [HMR `hotUpdate` プラグインフック](/changes/hotupdate-hook) +- [環境ごとの API への移行](/changes/per-environment-apis) +- [`ModuleRunner` API を使った SSR](/changes/ssr-using-modulerunner) +- [ビルド時の共有プラグイン](/changes/shared-plugins-during-build) -## Past +## 過去 -The changes below has been done or reverted. They are no longer relevant in the current major version. +以下の変更は、すでに終了または差し戻されています。現在のメジャーバージョンではこれらは関係ありません。 -- _No past changes yet_ +- _過去の変更はまだありません_ diff --git a/changes/per-environment-apis.md b/changes/per-environment-apis.md index 93ec216a..0ba6ec19 100644 --- a/changes/per-environment-apis.md +++ b/changes/per-environment-apis.md @@ -1,19 +1,19 @@ -# Move to per-environment APIs +# 環境ごとの API への移行 -::: tip Feedback -Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) +::: tip フィードバック +[Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358)でフィードバックをお寄せください。 ::: -Multiple APIs from ViteDevServer related to module graph has replaced with more isolated Environment APIs. +ViteDevServer のモジュールグラフに関連する複数の API は、より独立した環境 API に置き換えられました。 - `server.moduleGraph` -> [`environment.moduleGraph`](/guide/api-environment#separate-module-graphs) - `server.transformRequest` -> `environment.transformRequest` - `server.warmupRequest` -> `environment.warmupRequest` -Affect scope: `Vite Plugin Authors` +影響範囲: `Vite プラグイン作成者` -::: warning Future Deprecation -The Environment instance was first introduced at `v6.0`. The deprecation of `server.moduleGraph` and other methods that are now in environments is planned for `v7.0`. We don't recommend moving away from server methods yet. To identify your usage, set these in your vite config. +::: warning 将来の廃止予定 +Environment インスタンスは `v6.0` で初めて導入されました。`v7.0` では現在環境にある `server.moduleGraph` やその他のメソッドが廃止される予定です。まだサーバーのメソッドから移行することはお勧めしません。使用状況を明確にするために、vite の設定でこれらを設定してください。 ```ts future: { @@ -24,10 +24,10 @@ future: { ::: -## Motivation +## 動機 -// TODO: +// TODO: (訳注: 原文ママ) -## Migration Guide +## 移行ガイド -// TODO: +// TODO: (訳注: 原文ママ) diff --git a/changes/shared-plugins-during-build.md b/changes/shared-plugins-during-build.md index 3c9fc99f..e64cbeb4 100644 --- a/changes/shared-plugins-during-build.md +++ b/changes/shared-plugins-during-build.md @@ -1,22 +1,22 @@ -# Shared Plugins during Build +# ビルド時の共有プラグイン -::: tip Feedback -Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) +::: tip フィードバック +[Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358)でフィードバックをお寄せください。 ::: -// TODO: -See [Shared plugins during build](/guide/api-environment.md#shared-plugins-during-build). +// TODO: (訳注: 原文ママ) +[ビルド時の共有プラグイン](/guide/api-environment.md#shared-plugins-during-build)を参照してください。 -Affect scope: `Vite Plugin Authors` +影響範囲: `Vite プラグイン作成者` -::: warning Future Default Change -`builder.sharedConfigBuild` was first introduce in `v6.0`. You can set it true to check how your plugins work with a shared config. We're looking for feedback about changing the default in a future major once the plugin ecosystem is ready. +::: warning 将来のデフォルト変更 +`builder.sharedConfigBuild` は `v6.0` で初めて導入されました。これを true に設定することで、プラグインが共有コンフィグでどのように動作するかをチェックできます。プラグインエコシステムの準備が整ったら、将来のメジャーバージョンでデフォルトを変更するためのフィードバックを求めています。 ::: -## Motivation +## 動機 -// TODO: +// TODO: (訳注: 原文ママ) -## Migration Guide +## 移行ガイド -// TODO: +// TODO: (訳注: 原文ママ) diff --git a/changes/ssr-using-modulerunner.md b/changes/ssr-using-modulerunner.md index 130c20f6..b9910fa5 100644 --- a/changes/ssr-using-modulerunner.md +++ b/changes/ssr-using-modulerunner.md @@ -1,21 +1,21 @@ -# SSR using `ModuleRunner` API +# `ModuleRunner` API を使った SSR -::: tip Feedback -Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) +::: tip フィードバック +[Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358)でフィードバックをお寄せください。 ::: -`server.ssrLoadModule` has been replaced by [Module Runner](/guide/api-environment#modulerunner). +`server.ssrLoadModule` は [Module Runner](/guide/api-environment#modulerunner) に置き換えられました。 -Affect scope: `Vite Plugin Authors` +影響範囲: `Vite プラグイン作成者` -::: warning Future Deprecation -`ModuleRunner` was first introduce in `v6.0`. The deprecation of `server.ssrLoadModule` is planned for a future major. To identify your usage, set `future.removeSrLoadModule` to `"warn"` in your vite config. +::: warning 将来の廃止予定 +`ModuleRunner` は `v6.0` で初めて導入されました。`server.ssrLoadModule` の廃止は将来のメジャーバージョンで予定されています。使用状況を明確にするため、vite config で `future.removeSrLoadModule` を `"warn"` に設定してください。 ::: -## Motivation +## 動機 -// TODO: +// TODO: (訳注: 原文ママ) -## Migration Guide +## 移行ガイド -// TODO: +// TODO: (訳注: 原文ママ) diff --git a/changes/this-environment-in-hooks.md b/changes/this-environment-in-hooks.md index 2577ef3c..1d855b78 100644 --- a/changes/this-environment-in-hooks.md +++ b/changes/this-environment-in-hooks.md @@ -1,24 +1,24 @@ -# `this.environment` in Hooks +# フック内の `this.environment` -::: tip Feedback -Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) +::: tip フィードバック +[Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358)でフィードバックをお寄せください。 ::: -Before Vite 6, only two environments were available: `client` and `ssr`. A single `options.ssr` plugin hook argument in `resolveId`, `load` and `transform` allowed plugin authors to differentiate between these two environments when processing modules in plugin hooks. In Vite 6, a Vite application can define any number of named environments as needed. We're introducing `this.environment` in the plugin context to interact with the environment of the current module in hooks. +Vite 6 以前は `client` と `ssr` という 2 つの環境しか利用できませんでした。`resolveId`、`load`、`transform` プラグインフックの `options.ssr` 引数によって、プラグインフックでモジュールを処理する際に、プラグイン作成者はこの 2 つの環境を区別することができました。Vite 6 では、Vite アプリケーションは必要に応じて任意の数の名前付き環境を定義できます。プラグインコンテキストに `this.environment` を導入し、フック内で現在のモジュールの環境と対話できるようにします。 -Affect scope: `Vite Plugin Authors` +影響範囲: `Vite プラグイン作成者` -::: warning Future Deprecation -`this.environment` was introduced in `v6.0`. The deprecation of `options.ssr` is planned for `v7.0`. At that point we'll start recommending migrating your plugins to use the new API. To identify your usage, set `future.removePluginHookSsrArgument` to `"warn"` in your vite config. +::: warning 将来の廃止予定 +`this.environment` は `v6.0` で導入されました。`options.ssr` の廃止は `v7.0` で予定されています。その時点で、新しい API を使うようにプラグインを移行することを推奨します。使用状況を明確にするために、vite の設定で `future.removePluginHookSsrArgument` を `"warn"` に設定してください。 ::: -## Motivation +## 動機 -`this.environment` not only allow the plugin hook implementation to know the current environment name, it also gives access to the environment config options, module graph information, and transform pipeline (`environment.config`, `environment.moduleGraph`, `environment.transformRequest()`). Having the environment instance available in the context allows plugin authors to avoid the dependency of the whole dev server (typically cached at startup through the `configureServer` hook). +`this.environment` はプラグインフックの実装に現在の環境名を知らせるだけでなく、環境設定オプション、モジュールグラフ情報、トランスフォームパイプライン (`environment.config`, `environment.moduleGraph`, `environment.transformRequest()`) にもアクセスできるようにします。環境インスタンスをコンテキストで利用できるようにすることで、プラグイン作成者は開発サーバー全体への依存を避けることができます(通常は `configureServer` フックによって起動時にキャッシュされます)。 -## Migration Guide +## 移行ガイド -For the existing plugin to do a quick migration, replace the `options.ssr` argument with `this.environment.name !== 'client'` in the `resolveId`, `load` and `transform` hooks: +既存のプラグインを素早くマイグレーションするには、`resolveId`、`load`、`transform` フックの `options.ssr` 引数を `this.environment.name !== 'client'` に置き換えてください: ```ts import { Plugin } from 'vite' @@ -31,13 +31,13 @@ export function myPlugin(): Plugin { const isSSR = this.environment.name !== 'client' // [!code ++] if (isSSR) { - // SSR specific logic + // SSR 固有のロジック } else { - // Client specific logic + // クライアント固有のロジック } }, } } ``` -For a more robust long term implementation, the plugin hook should handle for [multiple environments](/guide/api-environment.html#accessing-the-current-environment-in-hooks) using fine-grained environment options instead of relying on the environment name. +より堅牢で長期的な実装のために、プラグインフックは環境名に依存するのではなく、きめ細かい環境オプションを使って[複数の環境](/guide/api-environment.html#accessing-the-current-environment-in-hooks)を扱うべきです。