自 v2.1.16 以来,r.js 依赖项跟踪是否显着变慢?或者只是我?

Is r.js dependency tracing significantly slower since v2.1.16? Or is it just me?

我注意到 r.js 版本 2.1.16/2.1.17 与 2.1.15 及之前版本相比,构建时间显着增加。额外的时间似乎是在 'Tracing dependencies for...' 期间花费的。

我的 build.js 看起来像这样:

({
    baseUrl: 'some/path/here',
    mainConfigFile: 'some/path/here',
    dir: 'some/path/here',
    modules: [
        {
            name: "base"
        },
        {
            name: "specific",
            exclude: ["base"]
        }
    ],
    findNestedDependencies: true,
    removeCombined: true,
    skipDirOptimize: true,
    optimize: "none"
})

在 运行 中,此构建在 Windows 环境中使用 node.js。 basespecific 都有相当数量(但不荒谬)的嵌套依赖项(basespecific 内部引用,因此被排除在外)。在 2.1.15 中,此构建在我的系统上需要 ±2 秒;在 2.1.16/2.1.17 中需要 ±8 秒。 (请注意,所有丑化已被禁用,因此这不是一个因素)

我将此 build.js 包括在内以供参考,但我认为这实际上不是我的设置导致速度下降的原因。我尝试了很多(简单的)场景,它们在跟踪 2.1.16/2.1.17 上的依赖项时似乎都慢了很多。

有人遇到过这种情况吗?或者只是我?我很确定,随着我的项目的增长,构建时间的 4x 增加将开始让我感到烦恼,所以请指教:-)

我在 Linux 和 findNestedDependencies: true 上有同样的问题。 此处报告了此问题 https://github.com/jrburke/r.js/issues/850

此处提到了以下发布信息http://requirejs.org/docs/download.html。这是问题最可能的原因。

2.1.16

The notable changes are in the r.js optimizer:

Esprima 2.0 is used by the optimizer when parsing modules for dependencies. This allows some ES6 features to be used. Whatever is parsable by Esprima 2.0 is what is supported (when running in xpcshell, Reflect.parse is still used).

你可以试试the latest r.js snapshot. jrburke says this change带来的显着改善。

来自 github issue comment:

[PR] #900 just landed a change that seems to really reduce time spent in the parsing steps. If people that had slow build times want to try out the latest master snapshot …