-
Notifications
You must be signed in to change notification settings - Fork 90
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
Synchronous catalog config from a global var + types #3166
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3166 +/- ##
==========================================
- Coverage 35.12% 34.98% -0.14%
==========================================
Files 660 661 +1
Lines 28964 28957 -7
Branches 4241 4239 -2
==========================================
- Hits 10174 10132 -42
- Misses 17609 17639 +30
- Partials 1181 1186 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
127188c
to
53e605c
Compare
Actually, deployment change is only relevant for OPEN, so we can merge this PR without waiting for that change. |
57e834a
to
590ea3a
Compare
Sorry, I wasn't clear about getter I thought about something like this: // utilsConfig.ts
const config = readAndValidateConfigOnStart()
export default function getConfig() {
return config
} // some-module.ts
import getConfig from 'utils/Config'
const { noDownload } = getConfig() It's almost the same as in the previous iteration ( |
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.
If your last iteration (590ea3a) is a trade-off for my feedback, then it's better to revert it, because I like previous iteration more, and, probably, you too
right now the code looks almost exactly like this
you can do that with the current implementation if you need (via
i don't quite get that argument, please elaborate on this. what would some actual examples of this look like? |
i've addressed your feedback (added desktop flag and refactored printing logic a little bit) and did some refactoring to isolate side-effects (make
why?
nope |
The main difference. In my pseudocode config validated and created only once, and then you can use the same object over and over |
Ok, I see. Now I see, that you actually ignored my feedback on getter, and that's kinda ok :) |
If I care more about API, then implementation, because implementation is a subject to change, but API is what should be more or less stable in collaborative code. API wasn't clear for me If you want to replace all: import * as Config from 'utils/Config'
const { noDownload } = useConfig() to import cfg from `constants/config`
const { noDownload } = cfg or import { noDownload } from `constants/config` then I OK with that, though I would prefer import getConfig from `config`
const { noDownload } = getConfig() |
|
i haven't ignored it and implemented that logic in
yeah it will (after we replace all the
ok makes sense
yeah more or less
that's not quite feasible due to how webpack and ES modules work
ok i'm glad we can more or less agree on the api surface, but i still don't see a compelling reason to keep the extra unnecessary step of calling the function instead of just accessing the result directly (tho i'm still open to being convinced otherwise) |
Future needs for refactoring will convince you :) |
In order to simplify access to the config data throughout the app (to a simple
import cfg from 'utils/Config'
) and setup of some tools (such as sentry),I've decided to refactor the config system to use a synchronous JS file which sets a global variable that later can be accessed by the app code.
This requires a change in deployment which will come soon (later today).
UPD: Actually, deployment change is only relevant for OPEN, so we can merge this PR without waiting for that change.
In order for local catalog instance to continue functioning, one should rename
config.json
file instatic-dev
folder toconfig.js
and prepend the contents withwindow.QUILT_CATALOG_CONFIG =
TODO