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

穿精又带淫゛_ 提交于 2019-12-10 21:47:30

问题


I have noticed a dramatic increase in build time in r.js versions 2.1.16/2.1.17, as compared to 2.1.15 and before. The extra time seems to be spend during the 'Tracing dependencies for...' fase.

My build.js looks something like this:

({
    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"
})

In run this build using node.js in a Windows environment. Both base and specific have a decent (but not absurd) amount of nested dependencies (base is referenced internally in specific, and is therefore excluded). In 2.1.15 this build would take ±2 seconds on my system; in 2.1.16/2.1.17 it takes ±8 seconds. (note that all uglification has been disabled, so this is not a factor)

I include this build.js for reference, but I don't think it is actually my settings that cause the slowdown. I have tried many (simple) scenarios and they all seem to be a lot slower at tracing dependencies on 2.1.16/2.1.17.

Anyone have this happening too? Or is it just me? I'm pretty sure that while my project grows, this 4x increase in build time will start to annoy me exponentially, so please advice :-)


回答1:


I have the same issue on Linux with findNestedDependencies: true. The issue is reported here https://github.com/jrburke/r.js/issues/850

The following release info is mentioned here http://requirejs.org/docs/download.html. This is the most likely reason for the issue.

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).




回答2:


you can try the latest r.js snapshot. jrburke says this change brings a significant improvement.

from the 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 …



来源:https://stackoverflow.com/questions/29987399/is-r-js-dependency-tracing-significantly-slower-since-v2-1-16-or-is-it-just-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!