30

I'm having an incredibly hard time understanding the modules and need a way to debug my issues. Is there a way to enumerate modules and their exports using SystemJS?

The config file seems like a poorly documented minefield. For modules that supply bundles like 'RxJs', if I include the bundle in a script tag or if I try to get it to load using the SystemJS config, how can I tell what I should be able to find in what I've loaded and where it is at? For instance I can get rxjs to work by copying the node_modules/rxjs to `wwwroot/libs/rxjs' and using this:

System.config({
    map: {
        'rxjs': 'lib/rxjs'
    },
    packages: {
        'rxjs': { defaultExtension: 'js' }
    }

This seems to load each individual file. Now say I use a script tag to load the rxjs bundle. How can I tell that the bundle has the modules I need? Is there a way in SystemJS to see if it would use the bundle and what it could resolve to?

Javier Enciso
  • 55
  • 1
  • 2
  • 11
Jason Goemaat
  • 28,692
  • 15
  • 86
  • 113
  • 2
    Funny, I found this because I am having trouble getting RxJS to load as well. – theblang Aug 02 '16 at 01:46
  • 3
    found this while trying to figure out why I get `GET http://localhost:3000/traceur 404 (Not Found)` – Brad Kent Sep 09 '16 at 19:43
  • 1
    I've written an explanation of the config file and how SystemJS uses it to determine where to find modules, after I also struggled to understand what it's doing and why I was getting 404 errors - https://stackoverflow.com/questions/37439855/what-does-systemjs-config-js-do-in-angular-2-packaging-structure/48780734#48780734 – Chris Halcrow Feb 16 '18 at 05:42

1 Answers1

1

System.entries Allows you to retrieve all modules in the System registry. Each value will be an array with two values: a key and the module.

for (const [id, ns] of System.entries()) {
      console.log(id); // 'http://localhost/path-to-file.js'
      console.log(ns); // { exportName: 'value' }
    };
Onur Gelmez
  • 1,044
  • 7
  • 9