Repository navigation
Conversation
…od config options
| workspace: new URL("./src/", cwd), | ||
| }; | ||
| // staticRouter has no default value of its own, so it is not part of defaultConfig | ||
| const supportedConfigOptions = [...Object.keys(defaultConfig), "staticRouter"]; |
Member
There was a problem hiding this comment.
staticRouter has no default value of its own
hmm...this just seems like an oversight? It's documented
https://greenwoodjs.dev/docs/reference/configuration/#static-router
and captured in the type definition
https://github.com/ProjectEvergreen/greenwood/blob/master/packages/cli/src/types/config.d.ts#L26
Seems like we should just add staticRouter: false to the defaultConfig?
Member
|
Opted to classify this as an enhancement instead of fix, fyi (as I don't really consider anything to be broken here, this is just a nice bit of feedback for users) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issue
Resolves #1769
Documentation
No documentation changes. The set of supported options is already documented at Configuration and is unchanged by this PR.
Summary of Changes
An unsupported top level key in
greenwood.config.jsis currently dropped without any diagnostic. The user config is destructured into a fixed list of names inreadAndMergeConfig, and the merged config is built only from those bindings, so anything else is silently discarded. A near miss typo of a real option (basepathforbasePath) is indistinguishable from an option simply not working.This adds a check right after that destructure which warns once per unrecognized top level key:
It warns, it does not throw. Rejecting an unknown key would be a breaking change: any project that currently carries a stray or forward compatible key builds fine today and would start failing. That call belongs to you, not to this fix, so this only makes the discard visible. It follows the existing non-fatal precedent in this same file, the "more than one custom renderer plugin detected" warning.
Scope is deliberately top level only. Unknown keys nested inside
devServerandpolyfillsare dropped the same way, but those sub-objects are looser (devServer.proxyis already an unvalidated pass through bag), so warning there has a higher chance of false positives. Happy to extend to the nested scopes in a follow up if you want it.The list of supported options is derived from
defaultConfigrather than being a second hand maintained list, so it stays in sync automatically.staticRouteris appended because it is the one supported option with no default value.Testing
New test case
packages/cli/test/cases/build.config.unknown-keys. It builds with a config containing a misspelled real option (basepath), a wholly unknown option (notARealOption), and a supported option (staticRouter), then asserts warnings for the first two and no warning for the third, while the build still succeeds. On master the two warning assertions fail; with this change all pass.I did not fold this into an existing config case because none of them exercise a successful build with unsupported keys, and the point of the test is that the build still exits cleanly. Folding it into one of the
build.config.error-*cases would not have covered the "warn, do not throw" behavior.Overlap with #1746
#1746 (approved, unmerged) also touches
packages/cli/src/lifecycles/config.js, swappingforEachforfor...ofin the plugins loop at lines 156-181. This change sits at lines 78-80 and 122-130, so the hunks do not collide and the two should merge in either order.