From b59b0a7e007f5d2a05bbdd0041ea4aa171e50fa9 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Wed, 29 May 2024 22:01:42 +0200 Subject: [PATCH] fix barrel optmization case --- .../webpack/loaders/next-flight-loader/index.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/next/src/build/webpack/loaders/next-flight-loader/index.ts b/packages/next/src/build/webpack/loaders/next-flight-loader/index.ts index 01804c6d078572..7978d4e35d1fe3 100644 --- a/packages/next/src/build/webpack/loaders/next-flight-loader/index.ts +++ b/packages/next/src/build/webpack/loaders/next-flight-loader/index.ts @@ -104,20 +104,17 @@ export default function transformSource( let esmSource = `\ import { createProxy } from "${MODULE_PROXY_PATH}" -const proxy = createProxy(String.raw\`${this.resourcePath}\`) +const proxy = createProxy(String.raw\`${resourceKey}\`) ` let cnt = 0 for (const ref of clientRefs) { if (ref === '') { - esmSource += `\nexports[''] = proxy[''];` + esmSource += `exports[''] = proxy['']\n` } else if (ref === 'default') { - esmSource += `\ -export default createProxy(String.raw\`${resourceKey}#default\`); -` + esmSource += `export default createProxy(String.raw\`${resourceKey}#default\`)\n` } else { - esmSource += ` -const e${cnt} = proxy["${ref}"]; -export { e${cnt++} as ${ref} };` + esmSource += `const e${cnt} = proxy["${ref}"];\n` + esmSource += `export { e${cnt} as ${ref} };\n` } }