File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 151151 <!-- オプション -->
152152 <link rel =" modulepreload" href =" assets/shared-B7PI925R.js" />
153153 ```
154+
155+ ::: details ` importedChunks ` の疑似実装
156+ TypeScript での ` importedChunks ` の疑似実装の例(これは、プログラミング言語とテンプレート言語に合わせて調整する必要があります):
157+
158+ ``` ts
159+ import type { Manifest , ManifestChunk } from ' vite'
160+
161+ export default function importedChunks(
162+ manifest : Manifest ,
163+ name : string ,
164+ ): ManifestChunk [] {
165+ const seen = new Set <string >()
166+
167+ function getImportedChunks(chunk : ManifestChunk ): ManifestChunk [] {
168+ const chunks: ManifestChunk [] = []
169+ for (const file of chunk .imports ?? []) {
170+ const importee = manifest [file ]
171+ if (seen .has (file )) {
172+ continue
173+ }
174+ seen .add (file )
175+
176+ chunks .push (... getImportedChunks (importee ))
177+ chunks .push (importee )
178+ }
179+
180+ return chunks
181+ }
182+
183+ return getImportedChunks (manifest [name ])
184+ }
185+ ```
186+
187+ :::
You can’t perform that action at this time.
0 commit comments