I would like to implement a plugin (plugin) structure in an Angular 2 , Angular 4 or Angular 5 application.
(My specific use case for developing this plug-in structure is that I need to develop a miniature content management system. For a number of reasons that will not necessarily be developed here, Angular 2/4/5 is almost an ideal solution for most of the needs of this system.)
Thanks to the plug-in structure (or plug-in architecture), I mean a system that allows third-party developers to create or extend the functionality of the main application using plug-in components, without having direct access or knowledge of the application’s source code or internal work.
(This wording about “without direct access to the source code of the application or its internal work” or “knowledge” is the main task.)
Examples of plug-in frameworks include common content management systems such as WordPress or Drupal .
The ideal situation (as in the case of Drupal) is to simply install these plug-in components (or plug-ins) into a folder, the application automatically detects or detects them, and they simply magically “work”. "If this happens in some kind of hot plug-in manner, that is, while the application is running, it would be optimal.
I am currently trying to determine the answers (with your help) to the following five questions.
- Practicality: Are plugins for an
Angular 2/4/5 application even practical? (So far, I have not found a practical way to create a truly pluggable structure using Angular2/4/5 .) - Expected Tasks: What problems may arise when implementing a plugin for an
Angular 2/4/5 application? - Implementation Strategies: What specific methods or strategies can be used to implement the plugin platform for the
Angular 2/4/5 application? - Recommendations: What are the best methods for implementing a plug-in system for an
Angular 2/4/5 application? - Alternative technologies: If the plugin is not applicable in the
Angular 2/4/5 application, what relatively equivalent technologies (for example, React ) may be suitable for a modern highly responsive web application?
In general, using Angular 2/4/5 very desirable because:
- it is naturally very fast - it is unbelievable.
- it consumes very little bandwidth (after boot)
- it has a relatively small area (after
AOT and tree shaking ) - and this footprint continues to shrink - It is very functional, and the Angular team and community continue to grow rapidly in their ecosystem.
- it works well with many of the best and latest web technologies such as
TypeScript and Observables - Angular 5 now supports service workers ( https://medium.com/@webmaxru/a-new-angular-service-worker-creating-automatic-progressive-web-apps-part-1-theory-37d7d7647cc7 )
- supported by
Google , it is likely to be supported and improved in the future
I would really like to use Angular 2/4/5 for my current project. If I can use Angular 2/4/5 , I will also use Angular-CLI and possibly Angular Universal (for server-side rendering).
Here are my thoughts so far on the above issues. Please review and provide your feedback and education.
Angular 2/4/5 applications consume packages - but this is not necessarily the same as allowing plugins within the application. A plugin in other systems (for example, Drupal ) can be added by adding a plugin folder to the general modules directory, where the system is automatically "selected" by the system. In Angular 2/4/5 package (as a plugin can be) is usually installed via npm , added to package.json , and then manually imported into the application - as in app.module . This is much more complicated than the Drupal method for deleting a folder and the system automatically detects the package. The more difficult it is to install the plugin, the less likely it is that people will use them. It would be much better if there was an Angular 2/4/5 way to automatically detect and install plugins. I am very interested in finding a method that allows non-developers to install the Angular 2/4/5 application and install any selected plugins without having to understand the entire architecture of the application.
As a rule, one of the advantages of providing a plug-in architecture is that it is very easy for third-party developers to extend the functionality of the system. Obviously, these developers will not be familiar with all the complexities of the code for the application into which they are connected. After developing plugins, other even less technical users can simply install the application and any selected plugins. However, Angular 2/4/5 relatively complex and has a very long learning curve. To further complicate matters, most Angular 2/4/5 production applications also use Angular-CLI , Angular Universal and WebPack . Someone who implements the plugin should probably have at least some basic knowledge of how they all fit together - along with a strong working knowledge of TypeScript and a reasonable NodeJS . Are knowledge requirements so extreme that no third party will ever want to develop a plugin?
Most plugins will likely have some component on the server side (for example, for storing / receiving data related to plugins), as well as for output to the client side. Angular 2/4/5 specifically (and strongly) prevents developers from implementing their own templates at run time, as this poses a serious security risk. To handle the many types of output that a plug-in can connect (for example, displaying a graph), it seems that allowing users to create content that is entered into the response stream in one form is probably necessary. I wonder how it would be possible to satisfy this need without figuratively shredding Angular 2/4/5 security mechanisms.
Most Angular 2/4/5 production applications are precompiled using Ahead of Time ( AOT ) compilation. (Probably everything should be.) I'm not sure if plugins can be added to (or integrated) pre-compiled applications. A better scenario would involve compiling plugins separately from the main application. However, I am not sure how to do this. A failure may consist in recompiling the entire application with any plugins enabled, but this complicates the administrative user who just wants to install the application (on his own server) along with any selected plugins.
In an Angular 2/4/5 application, especially precompiled, one piece of erroneous or inconsistent code can break the entire application. Angular 2/4/5 applications are not always easier to debug. Using unscrupulous plugins can lead to very unpleasant experiences. Currently, I do not know about a mechanism for correctly handling plugins with incorrect behavior.
UPDATE:
11/22/2017. Now that Angular 5 has been released, I'm reviewing which new features can better facilitate the implementation of the plug-in infrastructure.
plugins angular angular-cli angular-universal
Anthony Gatlin Jan 03 '17 at 7:09 2017-01-03 07:09
source share