fix(webpack): handle new webpack chunk format

This commit is contained in:
Daniel Roe 2024-12-19 10:00:24 +00:00
parent 784a28df97
commit d293c06d2a
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -88,9 +88,18 @@ export function dynamicRequire ({ dir, ignore, inline }: Options): Plugin {
}
}
type WebpackChunk = {
id: string
ids: string[]
modules: Record<string, unknown>
__webpack_id__?: string
__webpack_ids__?: string[]
__webpack_modules__?: Record<string, unknown>
}
async function getWebpackChunkMeta (src: string) {
const chunk = await importModule<{ id: string, ids: string[], modules: Record<string, unknown> }>(src) || {}
const { id, ids, modules } = chunk
const chunk = await importModule<WebpackChunk>(src) || {}
const { __webpack_id__, __webpack_ids__, __webpack_modules__, id = __webpack_id__, ids = __webpack_ids__, modules = __webpack_modules__ } = chunk
if (!id && !ids) {
return null // Not a webpack chunk
}