如何调试requireJS模块定义的路径/文件 [英] How to debug requireJS module defined path/file

查看:242
本文介绍了如何调试requireJS模块定义的路径/文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是RequireJS世界的新手.我正在其中一个模块中获得Load Timeout error,我已经在主文件中定义了这些模块.我在Chrome的网络"标签中看不到任何请求,可能是因为require早已加载了该文件.

I'm new to RequireJS world. I'm getting Load Timeout error for one of the modules, which I've already defined in the main file. I don't see any request in Network tab of Chrome, probably because require has already loaded that file earlier.

我迷上了require&的onError事件.我看到错误了.但是堆栈没有提供试图加载此模块的文件的确切位置/名称.有什么办法可以找出确切的file/linesOfCode吗?

I've hooked to onError event of require & I see the error. But the stack doesn't give the exact location/name of the file which tried to load this module. Is there any way to figure out the exact file/linesOfCode ?

此外,有什么方法可以在运行时找出requireJS中定义的所有路径,例如require.getPaths()

Also, is there any way to figure out at runtime all paths that are defined in requireJS, some API like require.getPaths()

推荐答案

requirejs.s.contexts._.config.paths

这将返回requirejs中定义的所有路径.如果有多个.config调用,则似乎包含所有重复的内容.

This will return all paths defined in requirejs. If there are multiple .config calls, it seems to contain all with no duplicates.

这篇关于如何调试requireJS模块定义的路径/文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆