Skip to content

Commit

Permalink
add better error when edge runtime is used inside node
Browse files Browse the repository at this point in the history
  • Loading branch information
conico974 committed Mar 23, 2024
1 parent 059db68 commit ae46f82
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packages/open-next/src/build/copyTracedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,26 @@ export async function copyTracedFiles(

const computeCopyFilesForPage = (pagePath: string) => {
const fullFilePath = `server/${pagePath}.js`;
const requiredFiles = JSON.parse(
readFileSync(
path.join(standaloneNextDir, `${fullFilePath}.nft.json`),
"utf8",
),
);
let requiredFiles;
try {
requiredFiles = JSON.parse(
readFileSync(
path.join(standaloneNextDir, `${fullFilePath}.nft.json`),
"utf8",
),
);
} catch (e) {
//TODO: add a link to the docs
throw new Error(
`
--------------------------------------------------------------------------------
${pagePath} cannot use the edge runtime.
OpenNext requires edge runtime function to be defined in a separate function.
See the docs for more information on how to bundle edge runtime functions.
--------------------------------------------------------------------------------
`,
);
}
const dir = path.dirname(fullFilePath);
extractFiles(
requiredFiles.files,
Expand Down

0 comments on commit ae46f82

Please sign in to comment.