<?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 Olivier Combe on Medium]]></title>
        <description><![CDATA[Stories by Olivier Combe on Medium]]></description>
        <link>https://medium.com/@OCombe?source=rss-5ae4b2205cba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UUSOf2_nCncdWVZG-Blt7g.jpeg</url>
            <title>Stories by Olivier Combe on Medium</title>
            <link>https://medium.com/@OCombe?source=rss-5ae4b2205cba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:30:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@OCombe/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[A Modern Approach for Angular Development]]></title>
            <link>https://medium.com/bitsrc/modern-angular-development-b469341a3620?source=rss-5ae4b2205cba------2</link>
            <guid isPermaLink="false">https://medium.com/p/b469341a3620</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Olivier Combe]]></dc:creator>
            <pubDate>Thu, 23 Nov 2023 10:24:34 GMT</pubDate>
            <atom:updated>2024-01-25T20:08:15.691Z</atom:updated>
            <content:encoded><![CDATA[<h4>Build composable and modernized Angular apps with Bit!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Oy83XwN0UVLTaWO.png" /></figure><p>Traditional development practices and tools often face challenges when it comes to component isolation. As applications become complex, managing and reusing components across projects becomes increasingly challenging.</p><blockquote>This is where <a href="https://bit.dev/"><strong>Bit</strong></a><strong> </strong>steps in to offer a modern and efficient solution.</blockquote><p>Bit is a build system for composable software. With Bit, you can build components as independent pieces of code shared and collaborated via <a href="https://bit.cloud/">remote component hostings</a>.</p><h3>Understanding App Composability</h3><p>Before we jump into the specifics of Bit, let’s first grasp the concept of app composability.</p><blockquote>At its core, app composability refers to the ability to build applications by composing reusable components.</blockquote><p>Imagine having a toolkit of well-crafted components ready to be seamlessly integrated into your Angular project. These components, encapsulated with their logic and styles, can be combined to create complex and feature-rich applications, like assembling building blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgrR1AddISoQUiIMOEhwKw.png" /><figcaption>Example: a dependency graph of independent, reusable (Bit) Angular components</figcaption></figure><p>This method offers a plethora of benefits, including:</p><ul><li><strong>Enhanced maintainability</strong>: Complex applications become significantly easier to manage and update when composed of independent components.</li><li><strong>Improved reusability</strong>: Reusable components can be shared across different applications, saving time and effort and promoting consistency.</li><li><strong>Specialization and collaboration</strong>: Each team can specialize in specific parts of the application development (user management, APIs, forms, etc.) with a clear scope and share their components with other teams.</li><li><strong>Better testability</strong>: Independent and smaller components are more straightforward to test individually, leading to a more robust and reliable application.</li></ul><h3>Quick start on using Angular with Bit</h3><p>Integrating Bit with your Angular project is a breeze.</p><h4>Step 1: Installing Bit in your Angular project</h4><p>First, use Bit’s version manager (bvm) to install Bit globally and then initialize a <a href="https://bit.dev/docs/getting-started/installing-bit/start-bit-workspace">workspace</a> with Angular.</p><pre>npx @teambit/bvm install<br>bit new angular my-workspace --env bitdev.angular/angular-env</pre><h4>Step 2: Creating and tracking components</h4><p>Once Bit is set up, use the Bit CLI to create and track components.</p><pre>bit create ng-standalone ui/my-button</pre><p>This will create a component a Button component. You can build your component and code using standard Angular syntax. Once you’re ready to ship your component onto the world, you can run the command:</p><pre>bit snap -m &quot;Creating new ui/my-button component&quot;</pre><p>Sharing components is where the real power of Bit shines. Push your components to Bit cloud, making them accessible to your team or the broader community.</p><pre>bit export</pre><p>If necessary, you can also publish your components to npm’s registry instead of Bit’s registry.</p><h4>Step 4: Consuming Bit components in Angular applications</h4><p>Now that your components are on Bit cloud, let’s explore how to consume them in other Angular projects.</p><p><strong>Create an Angular application</strong></p><p>In your workspace, create a new Angular application:</p><pre>bit create ng-app apps/my-angular-app</pre><p>Your app should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*eMmvxSLhQcL6ftDoh1YAjw.png" /></figure><p>This is essentially a component which is deployable to providers like Netlify and Vercel.</p><p><strong>Importing Bit components</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/0*1C7jOX46wXhh3tbC.png" /></figure><p>As shown above, you can consume these components like any other package. If the new Angular application is in a different workspace, you first need to install it:</p><pre>bit install @my-org/my-scope.ui.my-button</pre><p>Next, you can import it like you’d normally would and continue using it:</p><pre>import { MyButton } from &#39;@my-org/my-scope.ui.my-button&#39;;</pre><h3>Benefits of using Bit for Angular Development</h3><p>There are many benefits of using Angular with Bit. For a better understanding, let’s look at them in detail.</p><h4><strong>Bit components and Angular components</strong></h4><p>In Angular, a component is a class that contains the logic and the template of a specific part of your application.</p><p>Bit components are more like modular repositories. Their source code and artifacts, in the context of Angular, can be thought of as an Angular library. It is a collection of files that are related to a specific functionality. This means that a Bit component can contain multiple Angular components, as well as other files such as services, directives, and stylesheets.</p><p>Think of Bit components as packages. Each component will have its own package.json file and be distributed with its own package name.</p><h4>Component-centric approach</h4><p>Bit is a modern development tool that treats components as first-class citizens, making them easy to manage, organize, and share across projects.</p><p>Instead of dealing with cumbersome monorepos, you can focus on building and maintaining independent pieces of functionality.</p><p>Each Bit component will be automatically compiled and available in the node modules of your workspace, meaning that you can import them like any other package. This simplifies development because you do not need to build your Angular libraries before you run your app; everything is already set up for you.</p><h4>Isolation and dependency management</h4><p>Bit effectively isolates components and manages their dependencies seamlessly, ensuring consistent behavior across different applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*_vwhytNH5tdUXZADDZhAXA.png" /></figure><p>Bit keeps track of the dependency tree and is able to understand the components that rely on each other. It does this by parsing the code to automatically generate the package.json file and categorize imports between runtime, peer, and dev dependencies.</p><p>You do not need to worry about manually creating and maintaining your library package file. Of course, you can still change it manually if you have any specific requirements in terms of dependencies.</p><p>Each component is then versioned independently, providing granular control over updates and changes. You do not need to wait for large-scale releases to push bug fixes and new features.</p><h4>Bit’s collaboration and sharing capabilities</h4><p>Bit facilitates developers’ collaboration and sharing of components by providing a centralized hub for your components. The <a href="https://bit.cloud/">bit.cloud</a> platform is a repository where developers can discover, share, and collaborate on components. You can set up different levels of access to your organization’s code, and even non-developers can follow along and interact with the progress of your projects, providing valuable feedback.</p><p>This means that you can easily find out if your organization has already created the component that you need instead of reinventing the wheel. You can check its code, API, and documentation to see if it meets your expectations. You can also verify if it is compatible with your current version of Angular. If not, you can then either submit a change request or fork it to gain time.</p><h4>Effortless component documentation</h4><p>Documentation is often an overlooked aspect of software development. Bit, however, makes it easy to generate and maintain documentation for individual components. This enhances collaboration and serves as a valuable resource for developers using shared components.</p><p>Besides markdown documentation, you can also create compositions that simulate components in different variations for testing, visualization, and discoverability purposes. This is similar to other solutions like Storybook, except that it is already integrated, so you do not need to set it up.</p><p>This is especially interesting when you work on UI components, as it is a good way to ensure that you follow your designer’s specifications. By showcasing the different variations of each component, you can ensure that it meets the requirements. And then, by comparing the compositions of different versions, you can check if there have been any visual regressions.</p><h4>Advanced component testing</h4><p>Testing is a critical aspect of software development, and Bit simplifies the process by enabling developers to test components both in isolation and integrated into your applications.</p><p>When working on packages imported into different applications, a mono repository was previously the only solution to quickly test if your code changes were functional. But with Bit, you get the advantages of a mono repository while keeping the versatility of independent components. You can import everything in the same workspace locally to simulate a mono repository, but then every component is individually packaged and versioned.</p><p>By using Bit’s CI, named Ripple CI, you can ensure that your changes do not break your components’ dependents, as they can be automatically tested against the code that you pushed to bit cloud.</p><h4>Streamlining continuous integration with Ripple CI</h4><p>Bit utilizes Ripple CI as its default CI, offering a highly optimized CI experience specifically designed for component-driven software. Ripple CI provides several benefits for Angular development:</p><ul><li><strong>Parallelized component builds</strong>: Ripple CI parallelizes component builds, significantly reducing build times and improving development efficiency.</li><li><strong>Efficient builds with optimized component dependencies</strong>: Ripple CI only builds affected components and their dependencies, ensuring efficient use of resources and optimizing build performance.</li><li><strong>Faster feedback loops with incremental component builds</strong>: Ripple CI provides faster feedback loops by incrementally building components as they change, allowing developers to identify and address issues early on.</li><li><strong>Automatic propagation of dependent component builds</strong>: Ripple CI automatically propagates the builds of dependent components, including those not maintained in your workspace, ensuring that the entire application is always up-to-date. You can easily detect if your modifications contain bugs or breaking changes.</li><li><strong>Out-of-the-box configuration</strong>: Ripple CI is automatically integrated with Bit, requiring no additional configuration, thus allowing developers to focus on their code rather than spending time fine-tuning CI settings.</li></ul><p>Basically, Ripple CI transforms all the code of your organization into a big mono repository, which means that you see the direct impact of your Bit components and how they interact with the other components and applications that depend on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVfExesl0B6gwutHzwIMpg.png" /></figure><p>This is where app composability takes its full meaning. You build small pieces of code, whether it be modules, services, directives, styles, or a mix of everything, and package it into a single entity that will then be used by other components or applications. In the end, everything comes together on bit cloud with Ripple CI, making sure that your code works for your whole organization.</p><h3>Conclusion</h3><p>Bit and Ripple CI have drastically improved how to approach Angular development. It introduces a modern and efficient process for building composable applications. By embracing app composability, developers can create more maintainable, reusable, and testable applications while enhancing collaboration and productivity.</p><p>With its powerful features, seamless integration with Angular, and out-of-the-box support for Ripple CI, Bit is the ideal solution for developers seeking to elevate their Angular development skills and create the best web applications.</p><p>If you want to explore a sample application with Bit and Angular, feel free to <a href="https://bit.cloud/learnbit-angular">explore this scope in Bit Cloud</a>.</p><p>I hope you have found this useful.</p><p>Thank you for reading!</p><h3>Learn More</h3><ul><li><a href="https://blog.bitsrc.io/creating-a-developer-website-with-bit-components-3f4083a7f050">Creating a Developer Website with Bit components</a></li><li><a href="https://blog.bitsrc.io/getting-started-with-a-new-vue-js-project-in-2023-7ea97498ab6a">Getting Started with a New Vue.js Project in 2023</a></li><li><a href="https://blog.bitsrc.io/building-vue-js-micro-frontends-5d572d236d4">Building Vue.js Micro Frontends</a></li><li><a href="https://blog.bitsrc.io/component-driven-development-with-bit-a-case-study-b76459a554ad">Component-Driven Development with Bit: A Case Study</a></li><li><a href="https://blog.bitsrc.io/getting-started-with-a-new-angular-project-in-2023-c6ae93facbd6">Getting Started with a New Angular Project in 2023</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b469341a3620" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitsrc/modern-angular-development-b469341a3620">A Modern Approach for Angular Development</a> was originally published in <a href="https://medium.com/bitsrc">Bits and Pieces</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to publish a library for Angular 2 on npm]]></title>
            <link>https://medium.com/@OCombe/how-to-publish-a-library-for-angular-2-on-npm-5f48cdabf435?source=rss-5ae4b2205cba------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f48cdabf435</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular2]]></category>
            <dc:creator><![CDATA[Olivier Combe]]></dc:creator>
            <pubDate>Sat, 17 Oct 2015 08:54:03 GMT</pubDate>
            <atom:updated>2017-03-20T21:25:39.548Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Disclaimer: This article was last updated for Angular 2 beta 1.</em></p><p><strong>Update 2017–03–20: this article is a bit outdated, it can still be used for some parts but you should probably read this article by Minko Gechev </strong><a href="http://blog.mgechev.com/2017/01/21/distributing-an-angular-library-aot-ngc-types/"><strong>http://blog.mgechev.com/2017/01/21/distributing-an-angular-library-aot-ngc-types/</strong></a><strong><br> And take a look at that starter: </strong><a href="https://github.com/preboot/angular-library-seed"><strong>https://github.com/preboot/angular-library-seed</strong></a></p><h3>Context</h3><h4><em>You can skip this if you just want the code!</em></h4><p>I started a new project a few days ago, and quickly needed to add i18n support. When I was using Angular 1, I’ve been spoiled by the awesome <a href="https://angular-translate.github.io/">Angular Translate</a> written by the even more awesome <a href="https://medium.com/u/32a0d1331713">Pascal Precht ʕ•̫͡•ʔ</a>. I wanted my i18n translations to be easy and quick like I was used to, but since the<a href="https://github.com/angular/i18n"> i18n support for Angular 2</a> isn’t ready for now, I decided to write my own lib, and to share it with the world. That’s how <a href="https://github.com/ocombe/ng2-translate">ng2-translate</a> was born !</p><p>And that’s where things started to get hairy.</p><p>If you’ve tried Angular 2, you might have noticed that the setup for a new project is still a bit complicated (but a lot better than it was at the beginning of the alpha). The Google team is working really hard right now to make this easier. Their ultimate goal is that you shouldn’t have to setup anything other than linking to the Angular 2 library and start coding your app.</p><p>But if you’re writing Angular 2 code then you’re probably using TypeScript to do so (if that’s not the case then I highly encourage you to). And TypeScript uses what they call “TypeScript Definitions” (also named typings). Those are TypeScript files that only contain the interfaces of your classes.</p><p>When you use a typing file (which is a file that ends by <em>.d.ts</em>) you will get auto-completion in your favorite IDE (let it be Webstorm, Visual Code studio, or any other IDE that supports TypeScript) and also errors when you’re using incompatibles types or trying to access properties/methods that don’t exist. The TypeScript compiler will also warn you when that’s the case.</p><p>For example, if you’re trying to check the equality of a string and a number, it will tell you that both types are incompatible and might not produce the result that you expect.</p><p>It also warns you when you are trying to access a property/method that isn’t defined in this object (for example trying to call <em>.then</em> on a variable that isn’t a Promise).</p><p>All of this is really awesome, but it only works if the lib that you’re using exports these TypeScript definitions in a way that your IDE/compiler can use.</p><p>You can use <a href="http://definitelytyped.org/tsd/">TSD</a> to get TypeScript definitions for the most popular libraries, but I will explain here how to ship those typings with your library in a way that doesn’t involve publishing them to TSD (one less thing to do !).</p><p>This technique is similar to <a href="https://docs.google.com/document/d/1LvPBh7yxmjr7N1vCQ-kBj4guZGfGLBiz44CfenOX6o0/preview">the one used by the Google team for Angular 2</a>.</p><h3>Let’s write our library</h3><h4><em>This is where we start the real code!</em></h4><p>The first thing that you need to do to write your library is to init your npm module.</p><p>Go to your library folder and type:</p><pre>npm init</pre><p>This will generate the package.json file that you’ll need for your library.</p><p>Since we will be writing a library for Angular 2, let’s install it:</p><pre>npm install --save angular2</pre><p>Create your first <em>.ts</em> source file at the root of your folder and give it the name of your library. In my case, I named it <em>ng2-translate.ts</em> because I decided to call my library ng2-translate. This will be the name that people will use when they import your library in their own code:</p><pre>import {TranslateService} from &quot;ng2-translate/ng2-translate&quot;;</pre><p>When they write “ng2-translate/ng2-translate”, the first “ng2-translate” is the name of your npm module (and folder inside the node_module directory), and the second one is the name of the main file that we just created (without the .ts extension because it is the default, so we don’t need to write it).</p><p>This main file will just be used to export all of the things that you want to export from your library. We will put the real source files in a separate folder that we’ll name s<em>rc </em>(but you can name it however you want).</p><p>Create a <em>.ts</em> source file in your s<em>rc</em> folder and write your code in it. Let’s take the example of my ng2-translate library here. I’ll make a file named translate.service.ts:</p><pre><strong>import </strong>{Injectable} <strong>from &#39;angular2/angular2&#39;</strong>;<br><strong>import </strong>{Http} <strong>from &#39;angular2/http&#39;</strong>;</pre><pre>@<strong><em>Injectable</em></strong>()<br><strong>export class </strong>TranslateService {<br><br>    <strong>constructor</strong>(http: Http) {<br>        // ...<br>    }<br>}</pre><p>Now let’s move back to our ng2-translate.ts file at the root of your project. We want it to export this TranslateService. Let’s write this:</p><pre>export {TranslateService} from &#39;./src/translate.service&#39;;</pre><p>Since we will probably put more than TranslateService in the translate.service.ts file (some interfaces, some other classes), we will change it to export everything that is publicly available:</p><pre>export * from &#39;./src/translate.service&#39;;</pre><p>If you add a new source file later on, just add a new line to your <em>ng2-translate.ts</em> file. For example if we make a translate.pipe.ts file, add it like this:</p><pre>export * from &#39;./src/translate.pipe&#39;;<br>export * from &#39;./src/translate.service&#39;;</pre><p>We’re done with the library, let’s make it ready for distribution.</p><h3>Preparing your project for distribution</h3><p>To use your library, people will need two things:</p><ul><li>the .js files compiled to ES5 that will be loaded by the browser</li><li>the .d.ts TypeScript definition files (typings) that will be used for auto-completion and type checking when you’re coding.</li></ul><p>Those files can be generated by the TypeScript compiler. Let’s install it locally:</p><pre>npm install --save-dev typescript</pre><p>Since we don’t want to forget to generate those files when we release a new version of our library, we need to define a script that npm will call when we publish the lib. To do that we will use the <a href="https://docs.npmjs.com/misc/scripts">prepublish script</a> which will be executed by npm just before you publish a new version of your lib.</p><p>The description of this script states:</p><blockquote>prepublish: Run BEFORE the package is published. (Also run on local npm install without any arguments.)</blockquote><p>When it says “local npm install”, it means that you’re doing <em>npm install</em> inside the folder of the module that you’re writing. It doesn’t mean that it is executed when someone does <em>npm install</em> inside their own project that uses your library.</p><p>Edit your package.json file and add this:</p><pre>&quot;scripts&quot;: {<br>  &quot;prepublish&quot;: &quot;tsc&quot;<br>}</pre><p>The tsc command is what will compile your .js files and .d.ts typings, but we need to configure a few things for the compiler.</p><p>To do that we will create a tsconfig.json file at the root of our project that will be used by default by the TypeScript compiler. Put this inside your config file:</p><pre>{<br>    &quot;compilerOptions&quot;: {<br>        &quot;noImplicitAny&quot;: true,<br>        &quot;module&quot;: &quot;commonjs&quot;,<br>        &quot;target&quot;: &quot;ES5&quot;,<br>        &quot;emitDecoratorMetadata&quot;: true,<br>        &quot;experimentalDecorators&quot;: true,<br>        &quot;sourceMap&quot;: true,<br>        &quot;declaration&quot;: true<br>    },<br>    &quot;files&quot;: [<br>        &quot;ng2-translate.ts&quot;<br>    ],<br>    &quot;exclude&quot;: [<br>        &quot;node_modules&quot;<br>    ]<br>}</pre><p>Let’s review those parameters together:</p><ul><li>noImplicitAny: Raise error on expressions and declarations with an implied ‘any’ type.<br>You can put it to false, but it isn’t recommended.</li><li>module: we choose “commonjs” here. It is the most commonly (!) used module system, it’s supported by all loaders (ES6 import, SystemJS, Webpack, RequireJS &amp; Browserify).<br>It also looks like it is the fastest module system right now (until the ES6 implementation is supported by all browsers). <a href="https://github.com/angular/angular/issues/5223">For the beta Google decided to add UMD modules which are AMD/CommonJS compatibles</a>.</li><li>target: Specify ECMAScript target version: ‘ES3’ (default), ‘ES5’, or ‘ES6’.</li><li>emitDecoratorMetadata: Emit design-type metadata for decorated declarations in source.<br>Required for Angular 2.</li><li>experimentalDecorators: Support ES7-proposed asynchronous functions using the async/await keywords.<br>Required for Angular 2.</li><li>sourceMap: Generates corresponding ‘.map’ file.</li><li>declaration: Generates corresponding ‘.d.ts’ file.</li></ul><p>In the “files” parameter just put your main .ts file because the compiler will follow your imports anyway. If you decide to make multiple separate modules (like Angular 2 with http, router, …) then you should add them here as well.</p><p>Exclude the “node_modules” folder because you don’t want to compile those files for nothing.</p><p>Now we can test our prepublish hook by doing:</p><pre><strong>npm run prepublish</strong></pre><p>It should generates the .js, .d.ts and .js.map files for your project.</p><p>Now, we don’t want to commit those files to github because they are unnecessary and will pollute your repository, so let’s make a .gitignore file and add this:</p><pre><strong># Node generated files</strong><br>node_modules<br><em>npm-debug.log</em></pre><pre><strong># OS generated files</strong><em><br>Thumbs.db<br>.DS_Store</em></pre><pre><strong># Ignored files</strong><br>*.js<br>*.map<br>*.d.ts</pre><p>Since we added those files to the .gitignore file, you might be wondering how the user who installs your lib will get them. Well I discovered something here: when you do npm install, you don’t pull the module from github, you get it from the npm cache servers. Those servers will store what ever you pushed with npm publish, not what is available on github.</p><p>So when you’re doing npm publish, it will first call the prepublish script that we just wrote, generate the .js, .d.ts &amp; .js.map files and push all of your files to the npm cache server.</p><p>But there is a trick here, npm will only publish the files that it doesn’t ignore and by default it will use the .gitignore file.</p><p>So we need to make a .npmignore file that is a copy of your .gitignore file with the only exception that we will remove *.js, *.map &amp; *.d.ts from it. If a .npmignore file is present, npm won’t use your .gitignore file!</p><p>Your .npmignore file should look like this:</p><pre><strong># Node generated files<br></strong>node_modules<br><em>npm-debug.log</em></pre><pre><strong># OS generated files<em><br></em></strong><em>Thumbs.db<br>.DS_Store</em></pre><pre><strong># Ignored files<br>*.ts<br>!*.d.ts</strong></pre><p>Wait, why are you ignoring `*.ts` files? You just said remove all the ignored files? Well it’s because we don’t want to publish those `.ts` source files to npm. The typescript compiler will load them by default (instead of your `.d.ts` files) and it will generate errors because those sources files are not in your root directory. The end-user doesn’t need the TypeScript source files, he will consume the ES5 js files anyway.</p><p>The last thing that we need to do is to tell your IDE/TypeScript compiler what your typing file is. To do that open package.json and add this:</p><pre><strong>&quot;typings&quot;</strong>: <strong>&quot;./ng2-translate.d.ts&quot;</strong>,</pre><p>And we’re done !</p><h3>Let’s test our setup</h3><p>We want to make sure that all we did here works. To do that there is a “secret” technique called <a href="https://docs.npmjs.com/cli/link">npm link</a>. It will allow you to use the lib that you’re developing in your own project without having to publish it.</p><p>Go to the root folder of your library and type:</p><pre>npm link</pre><p>Now go to the root of your project and type:</p><pre>npm link ng2-translate</pre><p>Of course you should replace “ng2-translate” by the name of your library.</p><p>This will install the library in your project as if you had installed it with <em>npm install</em>.</p><p>You should be able to import your library and use it in your project without any other setup ! For example to use our TranslateService we would do:</p><pre>import {TranslateService} from &quot;ng2-translate/ng2-translate&quot;;</pre><p>And if we use the SystemJS loader, we would have to add our library to the config.js file like this:</p><pre><strong><em>System</em></strong>.config({<br>    <strong>packages</strong>: {<br>        <strong>&quot;/ng2-translate&quot;</strong>: {<strong>&quot;defaultExtension&quot;</strong>: <strong>&quot;js&quot;</strong>}<br>    }<br>});</pre><p>This way when you import the TranslateService it will load the file node_modules/ng2-translate/src/translate.service.js because in your ng2-translate.ts file you have exported the TranslateService from ‘./src/translate.service’.</p><p>And we’re all done, now you just have to publish the library to npm with:</p><pre>npm publish</pre><p><strong>Congratulations !</strong></p><p>I hope that you will now be able to make your own Angular 2 libraries. If I missed anything here, don’t hesitate to ask for it in the comments and I’ll update my article.</p><p>You can find all that I explained here in my <a href="https://github.com/ocombe/ng2-translate">ng2-translate repository</a>.</p><p><em>I would like to thank Rob Wormald &amp; Dmitriy Shekhovstov who helped me alpha test my library and find the right setup.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f48cdabf435" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>