require.js: Access all loaded modules

前端 未结 3 897
暗喜
暗喜 2020-12-04 14:16

Is there any way to access all loaded modules of require.js?

Background:
I want to automatically call an init() function of my javascript-modules af

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 14:59

    I'm lazy, so I just did this:

        var modulesToLoad = Object.keys(require.s.contexts['_'].registry);
        require(modulesToLoad);
    

    Based on other answers here.

提交回复
热议问题