Skip to content

Commit 708a074

Browse files
committed
use re-export
1 parent 98413f7 commit 708a074

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/next/src/build/webpack/loaders/next-flight-action-entry-loader.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,17 @@ function nextFlightActionEntryLoader(this: any) {
2020
.flat()
2121

2222
return `
23-
const actions = {
2423
${individualActions
25-
.map(([id, path, name]) => {
26-
return `'${id}': () => import(/* webpackMode: "eager" */ ${JSON.stringify(
27-
path
28-
)}).then(mod => mod[${JSON.stringify(name)}]),`
24+
.map(([_, path]) => {
25+
return `import(/* webpackMode: "eager" */ ${JSON.stringify(path)});`
2926
})
3027
.join('\n')}
31-
}
3228
33-
// Using CJS to avoid this to be tree-shaken away due to unused exports.
34-
module.exports = {
3529
${individualActions
36-
.map(([id]) => {
37-
return ` '${id}': actions['${id}'](),`
30+
.map(([id, path, name]) => {
31+
return `export { ${name} as "${id}" } from ${JSON.stringify(path)}`
3832
})
3933
.join('\n')}
40-
}
4134
`
4235
}
4336

packages/next/src/server/app-render/action-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ export async function handleAction({
870870
}
871871
}
872872

873-
const actionHandler = await (
873+
const actionHandler = (
874874
await ComponentMod.__next_app__.require(actionModId)
875875
)[
876876
// `actionId` must exist if we got here, as otherwise we would have thrown an error above

0 commit comments

Comments
 (0)