require.js: Access all loaded modules

前端 未结 3 908
暗喜
暗喜 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 15:12

    Yes, require.s.contexts._.defined is an object which its keys are the module names and the values include the value returned from that module.

    require.s.contexts._.defined includes all the modules (either define() or require() such as the Javascript file that is the starting point of the program and is indicated using data-main for RequireJS).

提交回复
热议问题