Requirements
This page outlines suggested requirements for adding UI modularity support, either to amdatu-webresources or as a new amdatu component.
This is a work in progress
Resource Location
It should be possible for any bundle to declare web resources under any path. This is different than the current behavior of amdatu-webresorces that prevents two bundles from providing resources that share a common path (each bundle needs to define one or several paths that it uses exclusively). Even though it is certainly good practice to concentrate resources for a given module under it's own unique path, flexibility is required for modularizing existing applications. It should be possible to take an existing frontend app and simply move resources to other bundles, maintaining their existing path so that no massive code changes would be required. The framework should be able to handle this and merge resources from any given bundle.
As an example, the following application structure should be considered as valid:
Bundle1:
- index.html
- controllers
- MainController.ts
- directives
- SomeDirective.ts
Bundle2:
- controllers
- FeatureController.ts
- directives
- FeatureRelatedDirective.ts
Resource Conversion
While the simplest operation of the framework would be to unify resources from the various bundles and serve them, it should also support a pluggable architecture for resource compilation and conversion. In order to assess the requirements for such converters, let's consider the two examples in the drawing below.
The drawing illustrates compilation of two types of resources - a TypeScript file, and an SCSS (SASS) file. Thinking about the flows above, the following points come to mind:
- Resource converters are called in a chain according to the file type (extension) and a predefined order. It might very well be that two resource converters will handle the same file type.
- While a resource converter is triggered by an addition or change of a single resource, it's operation might involve accessing other files. While this is not directly expressed in the drawing, the Typescript compiler (2) might need to access additional typescript files in dependent modules while compiling.
- While it is often the case that a resource converter will output a single file - such as in (3), there will be cases where the output of a conversion would be multiple files. The SASS compiler (7), when configured to use source maps, will output both the css file (8) and also the css.map source map file (9)
- It should be possible to configure converters so that they operate only under certain conditions. The minifiers in the diagram - (4) and (10) should only be called in the deployed product, but not in development.