[Proposal] Change design of package @docusaurus/core.
Change design of package @docusaurus/core. This code has implicit dependencies and is hard for newbs. Logic this package interwined with infrastructure code. Modules interact with file system, network and third-party libraries. Tests also have problems. By tests hard understand what does package. Tests is written for individuals files and they probably check implementation, not interface, that user interact with one.
💥 Proposal
To fix this problems, propose remove external dependencies from modules from folder commands. And later move features to custom webpack loaders and plugins.
Steps necessary to perform for that.
-
Write integration tests. Tests should checks
commandscorecteness interact with external environment. -
Replace code that interact with fs, network and 3rd-party libraries to wrappers.
-
Change requirements for
commands. That modules shouldn't interact with infrastructure now, only call explicit injected functions. Move wrappers to individual files. Pass every dependency explicit to constructor. In tests instead of external dependencies use mocks. -
Source tests could be removed because module tests from
commandsand integration tests should cover all possible cases. -
Features from commands step-by-step move to webpack loaders and plugins. Requirements and сonsequently tests should change also step-by-step. Finally, instead of methods createConfig and modules
commandsshould be files with webpack config.
Have you read the Contributing Guidelines on issues?
Yes
Sorry but I have a hard time understanding this proposal.
If you have a concrete thing you can improve PRs are welcome, but please don't refactor everything at once because it's really hard to review for me.
The idea is solid although the language is hardly understandable.
By my understanding, the OP is asking for:
- Tests to be fully E2E instead of testing internal impl; (which I partially agree, E2E tests should be improved, but unit tests are also necessary)
- Separate side-effects (fs, web request...) from pure core logic (I don't know how that's possible but the idea is sound, like how functional programmers do things);
- The CLI should only call Node.js / Webpack handles (also requested in #4841).
Actually, closing in favor of #3056 and #4841