-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudflare): experimental config redirection support #2949
base: v2
Are you sure you want to change the base?
Conversation
Given this is using the cloudflare_pages plugin, this should not have an This is likely to break the Pages CI. Not a problem in real life because the user wouldn't have that. But in terms of testing, I will remove that from the wrangler.toml |
For Pages projects that have a Depending on what you want the DX, you could either require the user to add that field themselves, or you could add it as part of the generation of |
if (mergedConfig.pages_build_output_dir) { | ||
throw new Error( | ||
"`pages_build_output_dir` wrangler config should not be set." | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see that you actively do not want the user to set this.
OK. But in that case you need to provide it automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add after the check?
mergedConfig.pages_build_output_dir = nitro.options.output.publicDir;
Nitro has introduced an experimental (opt-in) way to generate/extend
wrangler.toml
for cloudflare deployments (#2353, #2355).The end goal is to leverage Cloudflare platform features such as Node compat v2 (hybrid) and Async Context with zero-config and ensure we can reliably enable these features.
However, overwriting the user config is not ideal or recommended.
Thanks to the huge huge efforts and collab with the Cloudflare team and @petebacondarwin, a new solution (~> cloudflare/workers-sdk#7442) is coming to allow frameworks like Nitro to generate a merged
wrangler.toml
in dist and config that redirects/points wrangler CLI and pages CI to it.This PR is to experiment this new feature e2e from both sides.
Remarks
cloudflare.wrangler: {}
config is providedEXPERIMENTAL_WRANGLER_CONFIG
env variablerootDir
, it might need to be changed tocwd()
later for monorepo support (pending more tests)wrangler.json
from userwrangler.toml|json
overLocal testing
pnpm build --stub
EXPERIMENTAL_WRANGLER_CONFIG=1 p nitro build playground --preset cloudflare_pages
.wrangler/deploy/config.json
:wrangler.toml
(user)dist/_worker.js/wrangler.json