r.js中exlude和excludeShallow之间的区别

时间:2015-09-29 10:21:57

标签: node.js r.js

r.js中exlude和excludeShallow之间的区别为什么使用它们。

1 个答案:

答案 0 :(得分:1)

The r.js example build file通过示例解释了exclude和excludeShallow之间的区别,其中excludeShallow在开发过程中通常会有所帮助。

//This module entry combines all the dependencies of foo/bar/bip into one file,
//but excludes foo/bar/bop and its dependencies from the built file. If you want
//to exclude a module that is also another module being optimized, it is more
//efficient if you define that module optimization entry before using it
//in an exclude array.
{
    name: "foo/bar/bip",
    exclude: [
        "foo/bar/bop"
    ]
},

//This module entry shows how to specify a specific module be excluded
//from the built module file. excludeShallow means just exclude that
//specific module, but if that module has nested dependencies that are
//part of the built file, keep them in there. This is useful during
//development when you want to have a fast bundled set of modules, but
//just develop/debug one or two modules at a time.
{
    name: "foo/bar/bin",
    excludeShallow: [
        "foo/bar/bot"
    ]
},

The r.js documentation进一步解释了excludeShallow可能对快速开发有用:通过命令行使用优化器时,excludeShallow选项可用于排除模块的优化。