3
votes

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

2
I second the observation. I downgraded r.js on my project to 2.1.15 and shaved off 2/3rds of the build time. My build also uses node on Windows, in my case Windows 7.Hanne Olsen

2 Answers

3
votes

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

0
votes

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 …