-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add
"use server"
directive at the start of built files
Next.js needs the `"use server"` directive at the start of index files when creating server component functions.
- Loading branch information
Showing
3 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This is needed because Next.js files with server functions must have | ||
// the "use server" directive at the start of file. | ||
|
||
const { readFileSync, writeFileSync } = require("fs"); | ||
const { join } = require("path"); | ||
|
||
const pathDir = join(__dirname, "dist"); | ||
|
||
const main = () => { | ||
const fixFile = (path) => { | ||
let rows = readFileSync(path).toString().split("\n"); | ||
rows.unshift('"use server";'); | ||
writeFileSync(path, rows.join("\n")); | ||
|
||
console.log("Fixed", path); | ||
}; | ||
|
||
fixFile(join(pathDir, "index.js")); | ||
fixFile(join(pathDir, "index.mjs")); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use server"; | ||
|
||
import { z } from "zod"; | ||
|
||
type UndefinedKeys<T extends object> = { | ||
|