SystemJS-TypeScript in Plain Laguage Volume 2

      SystemJS-TypeScript in Plain Laguage Volume 2

      The example in Using module to separate our code will not work as written with any version of systemjs above 0.19.46. When installing systemjs I had to use:
      npm install systemjs@0.19.46 --save. I could not find a solution with the current systemjs 0.20.9.
      Hi stanlouis,
      Thanks for notifying me about this issue. After reading your message this morning I updated my Node and npm to the latest versions ( which have nothing to do with this issue but I wanted to review the book up to the problem you have encountered. You were absolutely right. They have changed the way the modules are loaded.

      After version 0.20.0 The script on the HTML needs to be slightly different. This is because support for defaultJSExtensions has been removed. I have tested the new script version and it is working for me. I have also updated the script linked to the book so that everyone can get the new version.

      I really appreciate the time you have taken to notify me about this.

      Thank you!
      Tony de Araujo

      Here's the HTML with the new script version. Lines 18,19,20,21 and 22 were modified:
      (The package module configuration is discussed here: SystemJS)

      HTML Source Code

      1. <!DOCTYPE html>
      2. <html>
      3. <head>
      4. <meta charset="utf-8">
      5. <title>Your project title goes here</title>
      6. <meta name="viewport" content="width=device-width, initial-scale=1">
      7. </head>
      8. <body>
      9. <script src="node_modules/systemjs/dist/system.js"></script>
      10. <script>
      11. // set our baseURL reference path
      12. SystemJS.config({
      13. baseURL: '/myscripts',
      14. packages: {
      15. '/': {
      16. defaultExtension: 'js'
      17. }
      18. }
      19. });
      20. // loads /js/scripts.js
      21. SystemJS.import('scripts.js');
      22. </script>
      23. </body>
      24. </html>


      HTML Source Code

      1. <script src="node_modules/systemjs/dist/system.js"></script>
      2. <script>
      3. // set our baseURL reference path
      4. SystemJS.config({
      5. baseURL: '/myscripts',
      6. defaultJSExtensions: true
      7. });
      8. // loads /js/scripts.js
      9. SystemJS.import('scripts.js');
      10. </script>

      P.S. SystemJS is only used in two of the exercises in the book. Later in the book, modules will be loaded by using Webpack which is more popular for Angular 2

      Another script using SystemJS can be seen here:
      innerHTML project - Breaking the old code into a module
      New eBook release: Go Exercises in Plain Language, Volume 1, Volume 2, Volume 3
      New eBook release: TypeScript in Plain Language Volume I | Volume 2 with Angular 4
      New quick read: The Factorial Recursive Function: A language agnostic explanation with samples in Go and JavaScript.
      - Please subscribe my Twitter or my Amazon profile to be notified of new releases.
      Author's profile on Amazon