-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Site Editor on WP.com: Initial explorations, take two #44928
base: trunk
Are you sure you want to change the base?
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~110 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~611403 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~2621 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~224 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
*/ | ||
function wpcomFetchAddSitePrefix( options, next ) { | ||
if ( options.path && ! options.global && options.path.indexOf( '/sites/' ) === -1 ) { | ||
options.path = '/sites/' + _currentSiteId + options.path; |
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.
This whole module is very interesting. Any ideas how we would be able to get this to work server-side? Where would the middleware be able to get the current site ID from? Is this already solved elsewhere?
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.
This whole module is very interesting. Any ideas how we would be able to get this to work server-side?
Could you elaborate? We could probably implement those endpoints in PHP and pass through to the 'actual' ones. I'm not quite sure why we would do that, since it seems it would require us to keep a much more explicit list of existing endpoints (which would mean higher maintenance burden etc) 🤔
Where would the middleware be able to get the current site ID from? Is this already solved elsewhere?
I lifted this stuff mostly from the gutenberg-wpcom
plugin, and that's using a _currentSiteId
global that's attached to window
somehow by another plugin (I think).
Alternatively, I think that on the client side, we should be able to store the current site ID somewhere in Redux/@wordpress/data
state and have the middleware pull it from there.
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.
By "server side" I meant the Calypso Node server, in the case of SSR, for example.
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.
Ahh, sorry for misreading. I haven't really thought about that yet TBH. It's true that a lot of @wordpress/
packages don't work particularly well on the server side, but we might be able to make them. (Here's an old exploration by a Team Calypso alum: WordPress/gutenberg#16227.)
e82c8e0
to
b336e3c
Compare
b336e3c
to
4f51179
Compare
4f51179
to
cafa15e
Compare
This PR has been marked as stale due to lack of activity within the last 30 days. |
Rebased version of #39373. Relevant for discussions around a server-decoupled Gutenberg (such as p9oQ9f-iN-p2).
cc/ @saramarcondes
Original PR desc below.
Changes proposed in this Pull Request
Take two of #36771.
For context, see pbAok1-dh-p2#comment-589
I'm customizing
apiFetch
, based on D37093-code. This might be generic enough to make sense across Calypso -- allapiFetch
requests made there should go through the WP.com proxy, change the root topublic-api.wordpress.com
, add/sites/123456
, etc.TODO
request
fromwpcom-proxy-request
(rather than fromdata-stores
) once wpcom-proxy-request: Return Promise if no callback specified #39683 has been merged.Testing instructions
Go to http://calypso.localhost:3000/custom-editor
cc @Automattic/cylon