Skip to content

Commit

Permalink
fix: move the invalidFunctions check before the no-functions one (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz authored Apr 24, 2023
1 parent dc74ffe commit cf43f44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .changeset/modern-crews-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@cloudflare/next-on-pages': patch
---

move the invalidFunctions check before the no-functions one

currently if a build contains only invalid functions we'd be presenting a log
saying that no function was found and simply return the static assets as if
everything is correct, this is because we check for invalid functions only
after checking if there are any (valid) ones, this change moves the invalid
functions check so that is performed first, making sure that the described case
successfully errors
10 changes: 5 additions & 5 deletions src/buildApplication/buildApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ async function prepareAndBuildWorker(
options.experimentalMinify
);

if (invalidFunctions.size > 0) {
printInvalidFunctionsErrorMessage(Array.from(invalidFunctions));
exit(1);
}

if (functionsMap.size === 0) {
cliLog('No functions detected.');
return;
Expand All @@ -99,11 +104,6 @@ async function prepareAndBuildWorker(
exit(1);
}

if (invalidFunctions.size > 0) {
printInvalidFunctionsErrorMessage(Array.from(invalidFunctions));
exit(1);
}

const staticAssets = await getVercelStaticAssets();

const processedVercelOutput = processVercelOutput(
Expand Down

0 comments on commit cf43f44

Please sign in to comment.