-
Notifications
You must be signed in to change notification settings - Fork 286
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
Use googlesitekit-data
imports directly instead of object destructing
#8769
Labels
javascript
Pull requests that update Javascript code
P1
Medium priority
Team S
Issues for Squad 1
Type: Infrastructure
Engineering infrastructure & tooling
Comments
tofumatt
added
P1
Medium priority
Type: Infrastructure
Engineering infrastructure & tooling
javascript
Pull requests that update Javascript code
labels
May 29, 2024
18 tasks
binnieshah
added
Team S
Issues for Squad 1
Next Up
Issues to prioritize for definition
labels
Jun 12, 2024
IB ✔️ |
18 tasks
1 task
QA Update: ✅Verified: I was able to set up a site with all modules and completed basic smoke testing. I could not find any obvious issues. No console errors, or on screen error messages. We will ensure that more through testing is completed during release testing. |
18 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
javascript
Pull requests that update Javascript code
P1
Medium priority
Team S
Issues for Squad 1
Type: Infrastructure
Engineering infrastructure & tooling
Feature Description
Our
googlesitekit-*
modules (eg.googlesitekit-data
,googlesitekit-api
, etc.) are exported as objects with only default entrypoints, meaning to use things likeuseSelect
orwithSelect
, we need to import the whole module, then do object destructuring to get the actual function we want, eg:These webpack aliases are unlike any other code/imports in our codebase—they're sort of awkward, don't allow for auto-imports, and make following the path to
'googlesitekit-*'
modules in VSCode/other TypeScript-aware editors impossible, because they aren’t aliased.This would be a nicer interface:
I forget why we didn't do this at the time, but it might've just been an error of omission that's ballooned to quite a big surface area of a small pain point 😆
We should support importing directly from the module. My proof-of-concept PR removes about 300 lines of code and improves the developer ergonomics/experience a fair bit in doing so: #8753.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Data
module that is available asgooglesitekit.data
should also be exported as named exports fromgooglesitekit-data
, so our internal code can access these functions/constants directly as named imports instead of properties from theData
object.'googlesitekit-data'
in VSCode/other TypeScript-aware tooling to the file that exports these functions, eg.assets/js/googlesitekit/data/index.js
.Implementation Brief
Note: Leave this issue for @tofumatt to work on, as he's already started the proof-of-concept PR for this issue and has a lot of context, as he worked on it during the Hackathon 🙂
googlesitekit-data
'sData
object directly (see: https://github.com/google/site-kit-wp/pull/8753/files#diff-057e8bc0b27b93a085309c427c3856be324d1a340050abe2435491bef9ec77a9R71-R86)tsconfig.json
with an alias forgooglesitekit-data
: (see: https://github.com/google/site-kit-wp/pull/8753/files#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R6-R8)googlesitekit-data
importsPossibly removing(Kept so that functions that interact with the registry/Data
default export to prevent new usagegooglesitekit-data
still work)See: #8753 for the proof-of-concept for this PR.
Test Coverage
QA Brief
No explicit QA instructions; this modifies all of our datastore imports, but should not actually change any behaviour.
It would be best to set up a site with all modules and do basic smoke testing after this is merged. If there are no issues, everything is good 😄
Changelog entry
The text was updated successfully, but these errors were encountered: