How to debug requireJS module defined path/file

2020-05-21 05:20发布

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.

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 ?

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

1条回答
Viruses.
2楼-- · 2020-05-21 05:57
requirejs.s.contexts._.config.paths

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

查看更多
登录 后发表回答