Skip to content

Commit

Permalink
fix: build.modulePreload.resolveDependencies is optimizable (#1522)
Browse files Browse the repository at this point in the history
* fix: `build.modulePreload.resolveDependencies` is optimizable

resolve #1521

vitejs/vite@e961b31 の反映です。

* contextの型を更新
  • Loading branch information
shuuji3 authored Aug 11, 2024
1 parent c12829d commit ef50ca7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ type ResolveModulePreloadDependenciesFn = (
url: string,
deps: string[],
context: {
importer: string
hostId: string
hostType: 'html' | 'js'
},
) => string[]
```
`resolveDependencies` 関数は動的インポートごとに依存するチャンクのリストとともに呼び出され、またエントリー HTML ファイルでインポートされたチャンクに対しても呼び出されます。新しい依存関係の配列は、これらのフィルタリングされた依存関係、あるいはそれ以上の依存関係を注入し、そのパスを修正した新しい依存関係配列を返すことができます。`deps` のパスは `build.outDir` からの相対パスです。`hostType === 'js'` の場合は `hostId` への相対パスを返すことができます。この場合、このモジュールを HTML ヘッドにプリロードする際に、絶対パスを取得するために `new URL(dep, import.meta.url)` が使用されます
`resolveDependencies` 関数は動的インポートごとに依存するチャンクのリストとともに呼び出され、またエントリー HTML ファイルでインポートされたチャンクに対しても呼び出されます。新しい依存関係の配列は、これらのフィルタリングされた依存関係、あるいはそれ以上の依存関係を注入し、そのパスを修正した新しい依存関係配列を返すことができます。`deps` のパスは `build.outDir` からの相対パスです。返り値は `build.outDir` からの相対パスでなければなりません
```js twoslash
/** @type {import('vite').UserConfig} */
Expand Down

0 comments on commit ef50ca7

Please sign in to comment.