Imports
Imports in a the monorepository MUST follow some rules. Depending on the context, they will be absolute, relative or using a specific pattern. This is because TSC does not update the imports on compilation, and the result is often broken, thus, the need for a specific loader like Webpack (used by default in the Angular Apps and Nest Backend).
Azure functions
Imports for now are relative, but should be moved to absolute or using the @wiotm-libs
pattern. Webpackifing the functions to build them rather than just using TSC is an option for later.
Apps
Imports in the core/apps
folder can be absolute, relative, or using the @wiotm-libs
pattern (see the root tsconfig.json
). As much as possible, try to be consistent.
Shared
Imports in the core/shared
folder MUST be relative, and CAN NOT use @wiotm-libs
. This is because we compile this folder as library to be served as an NPM dependency, and at the moment, the compile does not modify those imports.
It is strictly FORBIDDEN to import anything outside of NPM dependencies from outside this folder, the library must be considered as a standalone thing.
If you wish to pass environment information to the modules/components/services of the libs, you can use the envToken
(see the core/shared/client/angular/injection
folder).
VSCode extension
For a better readability of the imports, you should use the TypeScript Import Sorter
extension of VSCode. Don't forget to activate the Sort on before save
option in your VSCode preferences.