This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
Simplify @shopify/slate-config and refactor where it's used #725
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.
The Problem
Configuration in it's current state suffers from the following problems:
Config schemas are gross
Config files in Slate packages are long, arduous object collections comprised of multiple key values. Right out of the gate, this makes it hard to understand configuration and how to add/remove them.
slate.config.js is complicated
The slate.config.js relies on complex object data structure and weird namespacing which makes it hard to write a config items
Configurations items cannot access other configuration items
This makes it really hard to bubble config values across a project and limits the potential of Slates config files. An example would be if we had a
path.theme
config which established where the root folder of the theme is. It's currently impossible to change that config, and see it propagate to other configurations like where thepaths.dist
andpaths.src
folders are. See the paths item in the current config to see what I mean.Config items are not all unit tested
This introduces room for regressions in future releases, which would really suck for configurable parts of Slate.
A simplified config approach
This PR introduces a simplified configuration approach to Slate. Configuration items in Slate packages are declared in a flat object structure with unique strings as keys:
Configurations items can access other configuration items by setting the value of the configuration item to a function, which receives the configuration instance as an argument:
Because we now have a flat object structure,
slate.config.js
is also simplified. All configurations can be changed by referencing their unique key:Config items can be accessed synchronously in Slate packages by using the
get()
method:TODO in other PRs