Skip to content

Commit

Permalink
Restore warning about combining server actions with export
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Oct 20, 2023
1 parent 586009a commit 664cc6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,25 @@ export async function exportAppImpl(
}
}

let serverActionsManifest
if (options.hasAppDir) {
serverActionsManifest = require(join(
distDir,
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.json'
))
if (options.isInvokedFromCli || isExportOutput) {
if (
Object.keys(serverActionsManifest.node).length > 0 ||
Object.keys(serverActionsManifest.edge).length > 0
) {
throw new ExportError(
`Server Actions are not supported with static export.`
)
}
}
}

// Start the rendering process
const renderOpts: WorkerRenderOptsPartial = {
previewProps: prerenderManifest?.preview,
Expand Down Expand Up @@ -504,11 +523,7 @@ export async function exportAppImpl(
images: nextConfig.images,
...(options.hasAppDir
? {
serverActionsManifest: require(join(
distDir,
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.json'
)),
serverActionsManifest,
}
: {}),
strictNextHead: !!nextConfig.experimental.strictNextHead,
Expand Down
1 change: 1 addition & 0 deletions test/e2e/app-dir/actions/app-action-export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ createNextDescribe(
} catch {}
})

// @TODO turn this test back on whenw e
it('should error when use export output for server actions', async () => {
expect(next.cliOutput).toContain(
`Server Actions are not supported with static export.`
Expand Down

0 comments on commit 664cc6a

Please sign in to comment.