-
Notifications
You must be signed in to change notification settings - Fork 28
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
feature: set runtime config (support next/config) #72
feature: set runtime config (support next/config) #72
Conversation
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.
Thanks for the PR @alexandermendes, looks good! 🚀
I have one request though: if I'm not mistaken, serverRuntimeConfig
should only be accessible on server while publicRuntimeConfig
should be accessible on both, server
and client
. Could you add some tests that ensure this is the case? We have a lot of test examples that are using getServerSideProps
/ getInitialProps
you can look at.
src/utils.ts
Outdated
export function getNextConfig({ pathToConfig }: { pathToConfig: string }) { | ||
const config = loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfig); | ||
|
||
setConfig(config); |
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.
It's a bit confusing that getter
mutates some "global" state (has side effects). Could we pull that out and let the callee execute it?
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.
Yeah good point, was avoiding moving too much around but agree it's confusing, updating!
It's not immediately obvious where the best place might be to do this 🤔 There are those I have pushed up an idea there, but it's not ideal as calling |
Hi @alexandermendes, thanks for joining us! We're in the usual trouble of simulating server and client environments at the same time, we're definitely finding our patterns :) Would it be feasible switching Extra considerationsGiven the example provided by docs, As long as we don't find a way of properly separating server and client environments we might not be able to fully support Would it be an acceptable first step implementing a partial Happy to hear your thoughts. 🙌 |
Hi, yeah I haven't looked too deeply, but I think Just implementing |
Hi @alexandermendes, it seems we might be able to ship a solution for client/server environment sooner or later. Would you like to get back on this when we'll be able to merge #73? PS. You might also rebase over #73 and change PR branch target to try and see whether this could work with the new client/server approach. |
Hi @alexandermendes! #73 has been merged, and now master should have enough surface area to hook in At a first sight, a plausible solution might consist of updating global An optimistic approach might consider doing this switch directly in Given the current complexity of these client + server states I'd suggest to fully cover the feature with tests and then try out a working implementation. Cheers (and thanks)! |
With #90 being merged, we're in an ideal position to add |
Closed in favor of #102. |
Hi, this looks like a really useful library so far! I just came across this while trying it out for the first time.
What kind of change does this PR introduce?
Sets the Next.js runtime config, so we can test pages that make use of
next/config
.What is the current behaviour?
The runtime config is not set.
What is the new behaviour?
The runtime config is set!
Does this PR introduce a breaking change?
Nope.
Other information:
Please check if the PR fulfills these requirements: