<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saif Jerbi on Medium]]></title>
        <description><![CDATA[Stories by Saif Jerbi on Medium]]></description>
        <link>https://medium.com/@SaifJerbi?source=rss-cf177151f63c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8NbAey89-aMIZkuJV6iNiw.jpeg</url>
            <title>Stories by Saif Jerbi on Medium</title>
            <link>https://medium.com/@SaifJerbi?source=rss-cf177151f63c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:00:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@SaifJerbi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Modular platform using Angular — Part 2]]></title>
            <link>https://medium.com/@SaifJerbi/modular-platform-using-angular-part-2-919abf45f081?source=rss-cf177151f63c------2</link>
            <guid isPermaLink="false">https://medium.com/p/919abf45f081</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[modular]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[extension]]></category>
            <dc:creator><![CDATA[Saif Jerbi]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 12:44:48 GMT</pubDate>
            <atom:updated>2019-01-27T12:44:48.063Z</atom:updated>
            <content:encoded><![CDATA[<h3>Modular platform using Angular — Part 2</h3><p><a href="https://medium.com/@SaifJerbi/modular-platform-using-angular-part-1-41c94be76351">Link to part 1.</a></p><p>In the first part, we prepared the platform application that will load our Plugin. At this part, we will develop our plugin.</p><p>So first of all, we will create a new angular application that we will call file-explorer.</p><pre>// Let&#39;s generate the plugin app<br>ng new files-explorer</pre><pre>// move into generated application<br>cd files-explorer</pre><pre>// add shared-api dependency <br>npm install [PATH_TO_SHARED_API_PACKAGE_DIST] --save-dev</pre><pre>// generate main module (entry point module)<br>ng g m entry-point</pre><pre>// create our file-displayer component<br>ng g c entry-point/display-files</pre><p>The file-displayer will use the FileAPI.getAllConfigFiles() method to retrieve the different files to display, so we will inject this class into our component constructor.</p><p>Use the code below for the display-files.component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50a74144230897288752bb77d7dc9d1c/href">https://medium.com/media/50a74144230897288752bb77d7dc9d1c/href</a></iframe><p>Now to test our display we may provide a fake implementation of the FileApi, so let’s change the app.module.ts and provide our fake service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a9d52dab38eae37f096cb180ee00326/href">https://medium.com/media/4a9d52dab38eae37f096cb180ee00326/href</a></iframe><p>Now, you can see that we need to create real entry component for our plugin, it’s the files-explorer.component. Using the cli let’s run the command below:</p><pre>ng g component entry-point/FilesExplorerComponent --flat</pre><p>Why flat ? to tell the cli to generate the component into the entry-point folder and don’t create a new specific folder for it. But you may reorganize the folder on your way. Just don’t forget to update the component reference in the public_api.ts</p><p>The FilesExplorerComponent will embed the different component that we will use for our plugin. This component looks like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09d25fb2ad116db0cbfaaea89253c9a7/href">https://medium.com/media/09d25fb2ad116db0cbfaaea89253c9a7/href</a></iframe><p>To start developing our extension into a Sandbox mode (isolated), we need to export this component in the entry-point.module so we can use it in the app.component of our plugin.</p><p>Let’s update the entry-point.module like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/011de78d98126d57ccbfa1e29d33effd/href">https://medium.com/media/011de78d98126d57ccbfa1e29d33effd/href</a></iframe><p>Now, let’s update the app.component.html of our plugin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faba02da8c61e9d2165ebe0cd5de4a5c/href">https://medium.com/media/faba02da8c61e9d2165ebe0cd5de4a5c/href</a></iframe><p>At this point, we need to show how our plugin will looks like ? so let’s run :</p><pre>ng serve</pre><p>Go to <a href="http://localhost:4200/">http://localhost:4200</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ep7bjV06bVEjL3AcB2cPg.png" /></figure><p>Providing a fake implementation can help our team members to develop their plugins (extensions) without taking care of the implementation of this kind of shared API. So they develop the plugin in a sandbox and a non blocking lifecycle.</p><p>At this point our plugin is ready, let’s build it and loaded using our platform.<br>As you can see, our plugin is a full angular application, but in our case it should be delivered as an angular module, this is why we will build only the entry-point module that we have created.</p><p>Creating a full angular application was to facilitate debugging and developing the plugin, but the packaging will contain only the required entry point module.<br>In our team we were dealing with gulp and rollup to build only the required module, but when <a href="https://github.com/ng-packagr/ng-packagr">ng-packagr</a> was released we have found it as the best solution for our build scripts. After that, it was adopted by the angular-cli team at the V6 and now they use it as a packager for the angular project generated by the cli. <br>So let’s add ng-packagr dependency</p><pre>npm install ng-packagr --save-dev</pre><pre>// mkdir ng-packagr folder, it will contain specific config<br>mkdir ng-packagr</pre><p>add the files below to ng-packagr folder<br>- tsconfig.packagr.json contains the required config<br>- build.ts contains the build runner for ng-packagr</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23f2c3d265a814f23458cc240b47eeac/href">https://medium.com/media/23f2c3d265a814f23458cc240b47eeac/href</a></iframe><p>We need to add a custom ng-packagr configuration into package.json of the plugin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a0f57f572489264a7d9e5cc551f60d9/href">https://medium.com/media/1a0f57f572489264a7d9e5cc551f60d9/href</a></iframe><p>The public_api.ts file is required to export the entry-point component, it will be used by ng-packagr to perform the final bundle. We need to create this file like below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fa3c3b8b711b98673edd33e972ecafc/href">https://medium.com/media/8fa3c3b8b711b98673edd33e972ecafc/href</a></iframe><p>Let’s update the tsconfig file and the package.json script section to add the build:module task.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d72bd1d3e7588a1a98948b53572cee2f/href">https://medium.com/media/d72bd1d3e7588a1a98948b53572cee2f/href</a></iframe><p>Run the command below:</p><pre>// using npm<br>npm run build:module</pre><pre>// using yarn (i&#39;m in love with yarn)<br>yarn build:module</pre><p>The log will display how ng-packagr is processing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkQILFe99PAMkjwVQRQnpA.png" /></figure><p>After finishing, you will get the different bundles into the different target type (umd, esm, fesm,…).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*iAIpDoy_Sjn8mxI_RmgPjQ.png" /></figure><p>The part two is ready now, we will go back into our last article (Part 3) to show you how you will load this already built umd bundles into the main angular application which is our platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=919abf45f081" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modular platform using Angular — Part 1]]></title>
            <link>https://medium.com/@SaifJerbi/modular-platform-using-angular-part-1-41c94be76351?source=rss-cf177151f63c------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c94be76351</guid>
            <category><![CDATA[ide]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[modular]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Saif Jerbi]]></dc:creator>
            <pubDate>Tue, 18 Dec 2018 11:22:44 GMT</pubDate>
            <atom:updated>2019-01-27T11:17:24.583Z</atom:updated>
            <content:encoded><![CDATA[<h3>Modular platform using Angular — Part 1</h3><p><em>It’s my first article in medium so i will take the opportunity to introduce my self in few lines before starting.</em></p><p><em>I’m Saif Jerbi, i’m a frontend tech lead in a in-house framework team at Vermeg. I joined the team as a frontend developer at 2014, supporting an old made presentation layer based on Google Web Toolkit (GWT), after a short period we started a new project using new technology stack. We started using Angular and NodeJS. The plan was to implement a modular Web Integrated Development Environment (IDE) using modern web frameworks. In this article, i will share with you some architectural design and technical solution that we have implemented to deal with modularity in Angular and NodeJS.</em></p><p>An IDE is typically an application that should handle some development workspace via different plugins that are developed and plugged in at runtime. Think about vs-code, eclipse, intelliJ… and all the extensions that you install according to your needs. <br>To design an IDE you need to think in modularity, it’s a pluggable application that load and run modules (plugins) at runtime.<br>To learn modularity we will develop together a modular application like an IDE and provide an extension (plugin) that can be installed and loaded in the main application.</p><p>We will start with the main application that we will call “platform”, it will contain the plugins loader and plugins runner. Next, we will develop a plugin that displays some information that are injected by the platform. So you will checkout how this will be developed and loaded into our modular system.</p><p>This articles describe the different steps to develop a modular web application using Angular. We will focus on the frontend layer.<br>Part 1: The main modular application and the shared api<br>Part 2: The extension module to be deployed<br>Part 3: The extension loader mechanism using SystemJs loader</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*s2WTw4AbdYlURvTAOXIXnQ.png" /></figure><h3><strong>Let’s start the project:</strong></h3><p><em>You can skip all this steps by cloning this repository from </em><a href="https://github.com/SaifJerbi/angular-web-ide-example.git"><strong><em>Github</em></strong></a><em>.</em></p><pre>// Let&#39;s generate the platfrom app<br>ng new platform</pre><pre>// move into generated application<br>cd platform</pre><pre>// add bootstrap &amp; font-awesome<br>yarn add bootstrap font-awesome</pre><pre>// generate main component (entry point)<br>ng g c main</pre><pre>// generate layouts components<br>ng g c layouts/header<br>ng g c layouts/body<br>ng g c layouts/side-bar<br>ng g c layouts/footer</pre><pre>// generate a module to handle pluggins<br>ng g m plugins-management</pre><pre>// generate required components<br>ng g c plugins-management/available-plugins-displayer --export<br>ng g c plugins-management/plugins-container --export</pre><pre>// generate a plugin loader service<br>ng g s plugins-management/plugins-loader</pre><p>Import the generated project into your preferred IDE and let’s start work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*m5SY37-zGaKsTdrNxMNEoQ.png" /></figure><p>Edit your angular.json file and add the required import of bootstrap and fontawesome files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*0XeLuzQWkqi6qqFvhqf9BA.png" /></figure><h3><strong>It’s time for coding</strong></h3><p>Let’s start preparing the global layouts components.</p><p>Put the code below into the layouts/header.component.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8994f80572ebad563eda41fae2648731/href">https://medium.com/media/8994f80572ebad563eda41fae2648731/href</a></iframe><p>The code below into for the layouts/side-bar.component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4941a2511b87f1fb479339d29964774/href">https://medium.com/media/a4941a2511b87f1fb479339d29964774/href</a></iframe><p>Put the code below into layouts/footer.component.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bb4af4cf74cda18ea87977aabd9a33f/href">https://medium.com/media/5bb4af4cf74cda18ea87977aabd9a33f/href</a></iframe><p>Transform the body component to a container by updating the layouts/body.component :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5312ad197ca2b6dbb4b6d93c73449fc1/href">https://medium.com/media/5312ad197ca2b6dbb4b6d93c73449fc1/href</a></iframe><p>Now, we will focus on the plugins-management components. First we will customize the plugins displayer.</p><blockquote>An IDE plugin is a remote angular module that will be loaded at runtime into the platform main application. It has a name, a version, an icon and a remote deploy url.</blockquote><p>To handle plugins we need to define what’s a plugin model in our application and what are the plugin model attributes. So we add a new interface that define a plugin under models/ide-plugin.model.ts</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c64b5f2879be81f8f2a0582e386f4d61/href">https://medium.com/media/c64b5f2879be81f8f2a0582e386f4d61/href</a></iframe><p>Ok, we are ready to focus on the plugin displayer. <br>Add the code below to available-plugins-displayer.component, don’t forget about css file to get the right look&amp;feel</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c353afc659a5b2787a75fa53206236d/href">https://medium.com/media/6c353afc659a5b2787a75fa53206236d/href</a></iframe><p>In this component we need an input that contains an array of ide-plugins to display and an event emitter in order to propagate the click to load action. So the component class should be as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0676222b96cc6e1e1f57a782134c4724/href">https://medium.com/media/0676222b96cc6e1e1f57a782134c4724/href</a></iframe><p>Now go to the main component in the platform app: main/main.component.html and update the template with the code below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecb37d126b073199ca94e1352d02ea8e/href">https://medium.com/media/ecb37d126b073199ca94e1352d02ea8e/href</a></iframe><p>In the app.component.ts you need to add the code below, and we will follow with router configuration in app.module.ts</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/965bdce977e527e736dacb3297f5c822/href">https://medium.com/media/965bdce977e527e736dacb3297f5c822/href</a></iframe><h3><strong><em>Let’s focus on the sidebar</em></strong></h3><p>A loaded module should be added to the sidebar, so we need to push the selected plugin into the side bar component. In this case of behavior, generally, we add a service that contain a Subject. We push the required data into that Subject, and it will be broadcasted to all subscribers. In our case, we will do the same thing, but we will get inspired from the store implementation of <a href="https://medium.com/u/5df0f4e36e72">@ngrx</a>.</p><p>A store in <a href="https://medium.com/u/5df0f4e36e72">@ngrx</a> is a service that implement the Observer interface, so it implement a next() method. It contains a BehaviorSubject so all subscribers that comes after pushing the data, will get the latest cached one in the observable. So we will create a plugin store:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ce5cdc487b7b0a423ed94ba66d995fa/href">https://medium.com/media/9ce5cdc487b7b0a423ed94ba66d995fa/href</a></iframe><p>PS: don’t forget to provide the PluginStore into app.module.ts</p><p>Now we will use this store to fetch the different selected plugins and display them. So let’s update the side-bar.component and inject the store</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40d0acec3861e820f84eb3b0cc2e573c/href">https://medium.com/media/40d0acec3861e820f84eb3b0cc2e573c/href</a></iframe><p>PS: <em>the </em><strong><em>filter</em></strong><em>(</em><strong><em>Boolean</em></strong><em>) pipe is used to filter the undefined data. The first value that will be pushed into this observable will be theinitialization value of the store’s behaviorSubject, which is “undefined”. So there are no need to let pass the undefined value. We can use also the skip(1) operator to skip the first emission.</em></p><p><em>Let’s update the main.component to push the selected plugins into the plugin store.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33d8be4e50b9e2e2e144ea7826e9ad0f/href">https://medium.com/media/33d8be4e50b9e2e2e144ea7826e9ad0f/href</a></iframe><p>At this point all visual components are ready to embark the different plugins.</p><p>A modular application must perform some shared API to be used by the different extension plugins. The extensions must consume the API and be decoupled than the implementation of the API. So we will add new npm module that will contains only interfaces. It will be called “shared-api”. The platfrom app will implement this interfaces and will provide this implementation to the different plugin at runtime using the Dependency Injection mechanism.</p><p><em>You can skip all this steps by cloning this repository from </em><a href="https://github.com/SaifJerbi/angular-web-ide-example-shared-api.git"><strong><em>Github</em></strong></a><em>.</em></p><pre>// create new folder<br>mkdir shared-api</pre><pre>// move into this folder<br>cd shared-api</pre><pre>// init the new npm package<br>npm init</pre><pre>// add required dependencies<br>npm install --save typescript ts-node rxjs gts</pre><pre>// create new api folder, it will contains the api interfaces<br>mkdir api</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Puva5w_RfmygEM8LHAyuxg.png" /></figure><p>Create new typescript file into the api folder named “file.api.ts”.</p><p>PS: Interfaces in angular can’t be injected, so we will create an abstract class instead of interface</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed824dc897734000e583c401a0c55f19/href">https://medium.com/media/ed824dc897734000e583c401a0c55f19/href</a></iframe><p>Let’s assume that our shared API will contain only this method. We need to implement this interface in the platform. So we add this npm package as a dependency.</p><p>Our npm module is written with typescript, so it must be compiled and built.<br>Add this tsconfig file and run tsc command to compile and build this typescript files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01ccb6a96b88fb4bedd8bfc8b446d3c5/href">https://medium.com/media/01ccb6a96b88fb4bedd8bfc8b446d3c5/href</a></iframe><p>We will install it locally from disk path</p><pre>// move to platform directory<br>npm install [PATH_TO_SHARED_API_PACKAGE_DIST] --save</pre><p>Now, we add new folder to our platform application called shared-api-impl.<br>And we create new injectable service that will implement the fileApi interface.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ace600ec6eacc33dac85fc116793b4/href">https://medium.com/media/90ace600ec6eacc33dac85fc116793b4/href</a></iframe><p>We need to update the app.module.ts in order to provide this implementation for the specific api interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*NTMmBZ9gX3JvEb1uX79Jjw.png" /></figure><p>At this point, each component that will ask for the fileAPI will get the FileApiImpl as injected service. So we have decoupled the implementation from the declaration.</p><p>The FileApi interface (or abstract class) will be visible for each plugin application because it’s declared into separate npm package (shared-api). All plugins component/service can use this abstract classes and consume its different methods. The real implementation will be provided at runtime when the plugin module will be loaded in the core application (platform).</p><p>Now that we have finished the platform application and the shared-api, let’s move to the <a href="https://medium.com/@SaifJerbi/modular-platform-using-angular-part-2-919abf45f081"><strong>next chapter</strong></a> to create the plugin for our Web IDE.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c94be76351" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>