From d293c06d2aecfd7626af11a0c0b07263386d380a Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 19 Dec 2024 10:00:24 +0000 Subject: [PATCH] fix(webpack): handle new webpack chunk format --- .../webpack/src/nitro/plugins/dynamic-require.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/webpack/src/nitro/plugins/dynamic-require.ts b/packages/webpack/src/nitro/plugins/dynamic-require.ts index 5ac05dc353..a948df1028 100644 --- a/packages/webpack/src/nitro/plugins/dynamic-require.ts +++ b/packages/webpack/src/nitro/plugins/dynamic-require.ts @@ -88,9 +88,18 @@ export function dynamicRequire ({ dir, ignore, inline }: Options): Plugin { } } +type WebpackChunk = { + id: string + ids: string[] + modules: Record + __webpack_id__?: string + __webpack_ids__?: string[] + __webpack_modules__?: Record +} + async function getWebpackChunkMeta (src: string) { - const chunk = await importModule<{ id: string, ids: string[], modules: Record }>(src) || {} - const { id, ids, modules } = chunk + const chunk = await importModule(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 }