Requirejs 在 shim 配置中 deps 的用途是什么

Requirejs what is the use of deps in shim configuration

我从这里阅读了 requirejs 文档 api

requirejs.config({
    baseUrl: 'js/',
    paths: {
        app: 'app/js',
        jquery: '',
    },
    shim: {
        jquery: {
            exports: '$',
        },
        knockout: {
            deps: ['jquery', 'bootstrap', 'underscore'],
            exports: 'KnockOut'
        },
        underscore: {
            exports: '_'
        },
        a:{
            deps: ['x','b'],
            exports: 'a'
        }
    }
});

但我没有得到 deps shim 的一部分。 我为什么要使用 deps,这是否意味着如果我只加载 a 或其他什么

,这些文件(xb)将自动加载
    require(['a'], function(a){
    });

我试过了,但无法自动加载 xb。 请任何人举例说明为什么以及何时应该使用 deps。 谢谢。

RequireJS 加载符合异步模块定义 (AMD) 的模块。 AMD 模块必须调用由 AMD 加载程序提供的名为 define 的函数。基本调用是这样的:

define(["a", "b", "c", ...], function (a, b, c, ...) {
});

第一个参数是被定义的模块所依赖的模块列表。第二个参数是一个工厂函数,它构建被定义的模块。 RequireJS 将依赖项中列出的模块传递给它。还有其他方法可以调用 define 但上面的示例是典型的。

这一切都很好,但是如果您想加载第三方生成的库但不是 AMD 模块会怎样? shim 选项允许告诉 RequireJS 如何加载这些模块。对于 AMD 模块,您在传递给 define 的数组中指定依赖项,但对于 non-AMD 模块,您定义一个 shim,其中包含 deps 中的依赖项列表选项。它包含在加载垫片模块之前必须加载的模块的名称。在您的示例中,xb 必须在 a.

之前加载