Add loadConfigFromObject #4
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I think this is a necessary add...for posterity:
Currently, this package reads from whatever’s at
config/{env}.yamlat runtime and decrypts that. Unfortunately, Vercel and Next.js serverless functions only bundle files that are statically referenced at build time. Also unfortunately, YAML files can’t be imported and parsed in Node/TS (unless we add a YAML loader either here or in the consuming app– which just adds another step to this solution).Tried writing/copying a YAML file at runtime, tried to override the bundling decisions in Vercel, did not work.
So to work in Vercel, this package needs to allow the configuration to be loaded from a statically importable object.
Because this feels very unintuitive, I think the consuming app should still have to register this about its environment, supply the config object, and use the object loader specifically (in RC, by checking
process.env.VERCELand passing the JSON) rather than silently allowing this as the fallback. (Maybe it being unintuitive is actually an argument in favor of the fallback?)Release candidate tested in Vercel here, see logs showing that only the JSON is making it into the bundle