Skip to content
Florian Mettetal edited this page Jul 29, 2018 · 2 revisions

Abstraction pattern

  1. routes are layouts that import components
  2. components import modules, whether first or third party
  3. first party modules should be treated like and expected to behave like third party modules

Dependencies

For example when writing a module locally in a tgr-app.

The new module is placed in a "modules" directory because the end-goal is to refactor it into a standalone ts-react-module which can then be installed via npm from a private registry.

This means that there is some duplication between the new module's file structure and that of the parent-app.

.
├── helpers/   # dependencies that need to be included in the refactor, could violate DRY
├── types/     # dependencies that need to be included in the refactor, could violate DRY
├── theme.scss # dependencies that need to be included in the refactor, could violate DRY

Additionally, a module shouldn't import anything from outside of its directory, if it does - that thing that should be copied into the module directory and imported locally. Better yet, if its a common enough piece of code, move it into a new module folder and follow this abstraction pattern.

Clone this wiki locally