Refactor package structures to "client" + "server" #5910
Labels
better engineering
Not a bug or feature request
proposal
This issue is a proposal, usually non-trivial change
Have you read the Contributing Guidelines on issues?
Motivation
All packages should have a
client
and aserver
folder. Here's a good model: https://github.com/cmfcmf/docusaurus-search-local/tree/master/srcWhat's wrong with the current setup?
Currently, a plugin's server code is at the root of
src/
while most client code is insrc/theme/
. It's hard to tell which file belongs to Node and which is Webpack, which sometimes leads to server code ending up in client. For most packages the only client folder istheme
; but forplugin-content-docs
, for example, it also includesclient
.Moreover, this makes TS transpilation hard. Had we started with a clear client-server biclassification, a lot of the trouble in #5612 can be avoided. We can simply transpile the two folders with different TSConfigs without worrying about one's output overwriting another. As we go on to work on #5612, we can just watch changes in the client folder, because hot-reloading the server code isn't going to update the website anyways.
What does it take to separate the two folders?
Almost nothing—just move what's currently in
src/
tosrc/server/
and what's insrc/theme/
tosrc/client/theme/
. We can also use twotsconfig
files insrc/server/
andsrc/client/
with different types (we shouldn't have@types/node
in client, for example), and different.eslintconfig
.Self-service
The text was updated successfully, but these errors were encountered: