{"componentChunkName":"component---gatsby-theme-teklog-src-templates-post-tsx","path":"/how-to-bundle-many-typescript-files-using-systemjs","result":{"data":{"site":{"siteMetadata":{"siteUrl":"https://blog.tekmi.nl","author":{"name":"Teklog","avatar":"/img/tekmi-icon.svg"}}},"blogPost":{"frontmatter":{"title":"How to bundle many TypeScript files using SystemJS","slug":"how-to-bundle-many-typescript-files-using-systemjs","series":null,"date":"2019-08-25","datePretty":"25 August, 2019","coverImage":{"childImageSharp":{"fixed":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQBAgMF/8QAFgEBAQEAAAAAAAAAAAAAAAAAAQAC/9oADAMBAAIQAxAAAAHS60aHTkBf/8QAGxAAAgIDAQAAAAAAAAAAAAAAAhIAAQMREyH/2gAIAQEAAQUCrH6t6SKsKzEe5T//xAAVEQEBAAAAAAAAAAAAAAAAAAAAEv/aAAgBAwEBPwGEv//EABYRAQEBAAAAAAAAAAAAAAAAAAASE//aAAgBAgEBPwHRT//EABwQAAICAgMAAAAAAAAAAAAAAAACAZERMhAhMf/aAAgBAQAGPwLPvGp27WZhps3ez//EABoQAQACAwEAAAAAAAAAAAAAAAEAESFBYTH/2gAIAQEAAT8hpCKQxG6vwnEKItdECOoQ74P/2gAMAwEAAgADAAAAEAPv/8QAFhEBAQEAAAAAAAAAAAAAAAAAARBB/9oACAEDAQE/EFGx/8QAFxEAAwEAAAAAAAAAAAAAAAAAAAERUf/aAAgBAgEBPxBLhZ//xAAaEAEAAwEBAQAAAAAAAAAAAAABABEhYVGh/9oACAEBAAE/EDcfIQ3vI1EFZCGdq63GLy6EXUzWS7HxZYwPhP8A/9k=","width":1000,"height":750,"src":"/static/674821e3cae9ad7896b31f9464b75801/a7715/cyclingRouteField.jpg","srcSet":"/static/674821e3cae9ad7896b31f9464b75801/a7715/cyclingRouteField.jpg 1x"}}},"author":null,"authorAvatar":null},"timeToRead":5,"excerpt":"Introduction TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. You can install it from Node Package Manager (NPM) and…","html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p><a href=\"https://www.typescriptlang.org\">TypeScript</a> is a typed superset of JavaScript that compiles to plain JavaScript. You can install it from Node Package Manager (NPM) and tinker with its <code class=\"language-text\">tsc</code> executable. It accepts a handful of <a href=\"https://www.typescriptlang.org/docs/handbook/compiler-options.html\">options</a> which may be stored inside <a href=\"https://www.typescriptlang.org/docs/handbook/tsconfig-json.html\">tsconfig.json</a> configuration file.</p>\n<p><a href=\"https://github.com/systemjs/systemjs\">SystemJS</a> is a JavaScript module loader that allows using ES Modules in all browsers. You can get it either via CDN or from Node Package Manager.</p>\n<p>You may be wondering why do we even talk about SystemJS and Typescript together? Wouldn't it suffice to use Typescript compiler alone? </p>\n<p>Unfortunately, Typescript compiler is not that almighty. While it can compile each file to a given target, it has no way to bundle several files into one.</p>\n<p>Strangely enough, it looks like Typescript supports ES6 Modules syntax inside <em>*.ts</em> files, since you can write either <em>export</em> or <em>export default</em>. You can even use Babel-like imports and named imports, thanks to <em>esModuleInterop</em> option. But underneath, Typescript transforms all <em>export</em> and <em>import</em> instructions via the <strong>module</strong> code generation option.</p>\n<hr>\n<p><strong>module</strong> can be one of: None, CommonJS, AMD, System, UMD, ES6, ES2015, ESNext.</p>\n<hr>\n<p>Node environment uses <em>CommonJS</em> modules and don't need to bundle files into one, so in this case, Typescript alone would suffice. But browsers face more challenges. They neither understand <em>CommonJS</em> syntax nor <em>ES6 Modules</em> syntax. Thus, Typescript must delegate the hard work of bundling to:</p>\n<ul>\n<li>either build-time bundlers such as Webpack</li>\n<li>or run-time module loaders such as SystemJS, AMD.</li>\n</ul>\n<p>To facilitate bundling, Typescript provides two compiler options: <strong>module</strong> and <strong>outFile</strong>. The moment you specify <strong>outFile</strong> option, <strong>module</strong> option becomes limited to <em>System</em> or <em>AMD</em>.</p>\n<h2 id=\"tldr\" style=\"position:relative;\"><a href=\"#tldr\" aria-label=\"tldr permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TL;DR</h2>\n<p>In this tutorial, we will focus on the SystemJS, which is one of the run-time module loaders. If you can't wait to see the code, I've created a <a href=\"https://github.com/tekmi/blogging-typescript-with-bundlers\">Github repository</a> for you. Otherwise, let's start off our tutorial.</p>\n<h2 id=\"systemjs-configuration\" style=\"position:relative;\"><a href=\"#systemjs-configuration\" aria-label=\"systemjs configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>SystemJS configuration</h2>\n<p>Firstly, we are going to install SystemJS</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">yarn</span> <span class=\"token function\">add</span> systemjs</code></pre></div>\n<p>With that, create an <strong>index.html</strong> file with the following content</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token doctype\">&lt;!DOCTYPE html></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>html</span> <span class=\"token attr-name\">lang</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>en<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>head</span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">charset</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>UTF-8<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>title</span><span class=\"token punctuation\">></span></span>Typescript with SystemJS 5.x<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>title</span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>script</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>./node_modules/systemjs/dist/s.js<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span><span class=\"token script\"></span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>script</span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>script</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>./node_modules/systemjs/dist/extras/named-register.js<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span><span class=\"token script\"></span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>script</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>head</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>body</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>script</span><span class=\"token punctuation\">></span></span><span class=\"token script\"><span class=\"token language-javascript\">\n  System<span class=\"token punctuation\">.</span><span class=\"token function\">import</span><span class=\"token punctuation\">(</span><span class=\"token string\">'./bundle.js'</span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> System<span class=\"token punctuation\">.</span><span class=\"token function\">import</span><span class=\"token punctuation\">(</span><span class=\"token string\">'systemjs/app'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span>console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">.</span><span class=\"token function\">bind</span><span class=\"token punctuation\">(</span>console<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n</span></span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>script</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>body</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>html</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>As you see in the snippet above, in the head section we must include the s.js and named-register.js scripts.</p>\n<ul>\n<li>You could also include <em>system.js</em>, but <em>s.js</em> is a lighter version.</li>\n<li>The necessity to include <em>named-register.js</em> came after SystemJS reached its 2.0 version. You can read more about <a href=\"https://guybedford.com/systemjs-2.0\">SystemJS 2.0 release here</a>.</li>\n</ul>\n<p>Having the base SystemJS configuration, let's move on to the minimal Typescript configuration.</p>\n<h2 id=\"typescript-configuration\" style=\"position:relative;\"><a href=\"#typescript-configuration\" aria-label=\"typescript configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Typescript configuration</h2>\n<p>In here, we are going to install Typescript globally</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">yarn</span> global <span class=\"token function\">add</span> typescript</code></pre></div>\n<p>Next, we must create <strong>tsconfig.json</strong> file inside our project, as shown below</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"compilerOptions\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"target\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"es5\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"module\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"system\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"outFile\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"./bundle.js\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"strict\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"esModuleInterop\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"inlineSourceMap\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"inlineSources\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"exclude\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n    <span class=\"token string\">\"node_modules\"</span>\n  <span class=\"token punctuation\">]</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Notable parts from the snippet above are:</p>\n<ul>\n<li><strong>module</strong> must be set to <em>system</em>, to use the SystemJS run-time module loader</li>\n<li><strong>outFile</strong> can point to any file which will bundle all your <em>*.ts</em> files. In this tutorial, it's a <em>bundle.js</em> since SystemJS reads this file inside index.html.</li>\n<li><strong>target</strong> is <em>es5</em>, since we do not use any transpiler (e.g Babel). Code inside <em>bundle.js</em> is thus understandable by every browser.</li>\n</ul>\n<p>After you run <code class=\"language-text\">tsc</code> compiler, the content of your <em>bundle.js</em> file should be similar to the snippet below.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token comment\">// For readability, only crucial bits are displayed</span>\nSystem<span class=\"token punctuation\">.</span><span class=\"token function\">register</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"systemjs/app\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token string\">\"shared/Family\"</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">exports_5<span class=\"token punctuation\">,</span> context_5</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span> <span class=\"token comment\">/*...*/</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nSystem<span class=\"token punctuation\">.</span><span class=\"token function\">register</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"shared/Family\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token string\">\"shared/Child\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"shared/Parent\"</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">exports_4<span class=\"token punctuation\">,</span> context_4</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span> <span class=\"token comment\">/*...*/</span> <span class=\"token punctuation\">}</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nSystem<span class=\"token punctuation\">.</span><span class=\"token function\">register</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"shared/Parent\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">exports_3<span class=\"token punctuation\">,</span> context_3</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span> <span class=\"token comment\">/*...*/</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Bundle.js is already a big file which uses many <em>System.register</em> calls, combining all our <em>.ts</em> modules. This is exactly what SystemJS 5.x with Extra Named register needs.</p>\n<p>Importantly, <em>systemjs/app</em> was marked as the root element for SystemJS import. Corresponding <em>systemjs/app.ts</em> script loads all other <em>.ts</em> files from a <em>shared</em> directory.</p>\n<h2 id=\"project-structure\" style=\"position:relative;\"><a href=\"#project-structure\" aria-label=\"project structure permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Project structure</h2>\n<p>With the proper configuration of Typescript and SystemJS, let's dive into the project structure.</p>\n<p>Feel free to clone related repository <a href=\"https://github.com/tekmi/blogging-typescript-with-bundlers\">https://github.com/tekmi/blogging-typescript-with-bundlers</a> yourself.</p>\n<p>The main file lives inside <strong>systemjs/app.ts</strong> which imports all the needed dependencies.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token keyword\">import</span> Family<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> Child<span class=\"token punctuation\">,</span> Parent <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"../shared/Family\"</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">const</span> child1 <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Child</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Marc'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> parent1 <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Parent</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Adam'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> parent2 <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Parent</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Yanjiao'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">const</span> myFamily <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Family</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nmyFamily<span class=\"token punctuation\">.</span><span class=\"token function\">addMember</span><span class=\"token punctuation\">(</span>child1<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nmyFamily<span class=\"token punctuation\">.</span><span class=\"token function\">addMember</span><span class=\"token punctuation\">(</span>parent1<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nmyFamily<span class=\"token punctuation\">.</span><span class=\"token function\">addMember</span><span class=\"token punctuation\">(</span>parent2<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\nmyFamily<span class=\"token punctuation\">.</span><span class=\"token function\">printNames</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you look inside the <em>package.json</em>, you will see that <em>systemjs</em> is the main dependency. Next to it, there is <em>lite-server</em> dev dependency which is used to start the local server.</p>\n<p>Once you cloned the repository, you can follow those steps to see the Typescript and SystemJS in practice.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token builtin class-name\">cd</span> systemjs\n<span class=\"token function\">yarn</span> <span class=\"token function\">install</span>\n<span class=\"token function\">yarn</span> dev</code></pre></div>\n<p>The last command will open your browser. So the only thing left is actually checking console logs inside your browser Developer Tools.</p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>Typescript is gaining momentum and bringing lots of good things for JavaScript developers. It doesn't try to be an all-at-once tool and it doesn't try to lock us inside its ecosystem. With its <strong>target</strong> and <strong>module</strong> options, it gives us lots of flexibility.</p>\n<p>Typescript focus on one thing. It brings a powerful compiler that enhances JS with strong typings. Other parts, like bundling, are gracefully delegated to other, battle-tested tools from the frontend world.</p>\n<p>In this tutorial, we have focused on SystemJS and Typescript, but there is much more to explore. In the upcoming tutorials, I will be looking into AMD, Gulp and Webpack modules integration.</p>"}},"pageContext":{"postId":"c1e754ff-3e6f-5c98-8a1b-1f00ae278050","slug":"how-to-bundle-many-typescript-files-using-systemjs"}}}