简体   繁体   English

调试SystemJS模块加载?

[英]Debugging SystemJS module loading?

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? 有没有办法使用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? 对于提供像“RxJs”这样的包的模块,如果我在一个脚本标签中包含该包,或者如果我尝试使用SystemJS配置加载它,我该怎么知道我应该能够在我加载的内容中找到什么它在哪里? For instance I can get rxjs to work by copying the node_modules/rxjs to `wwwroot/libs/rxjs' and using this: 例如,我可以通过将node_modules/rxjs复制到`wwwroot / libs / rxjs'并使用以下rxjs来获得rxjs

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. 现在说我使用脚本标记来加载rxjs包。 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? 在SystemJS中是否有办法查看它是否会使用捆绑包以及它可以解决的问题?

System.entries Allows you to retrieve all modules in the System registry. System.entries允许您检索System注册表中的所有模块。 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' }
    };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM