Debugging SystemJS module loading?
Asked Answered
M

1

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?

Mauser answered 26/5, 2016 at 9:1 Comment(3)
Funny, I found this because I am having trouble getting RxJS to load as well.Cauca
found this while trying to figure out why I get GET http://localhost:3000/traceur 404 (Not Found)Agglutinative
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 - #37440355Influx
S
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' }
    };
Simarouba answered 21/4, 2019 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.