Frage

I have a SPA that makes use of the breeze.js library. I am using require.js to load modules. I want to optimize the application into a single JavaScript file using r.js, however I am getting the following error:

Tracing dependencies for: main Error: ../Scripts/breeze.debug.js has two many anonymous modules in it. at ...\Scripts\r.js:20154:35

Am I barking up the wrong tree trying to optimize with r.js? I can't see anything on the breeze.js site site to indicate that it can or can not be done.

Cut down version of m main.js:

    require.config({

    paths: {
        "jquery": "../Scripts/jquery-1.9.1",
        "Q": "../Scripts/q",
        "breeze": "../Scripts/breeze.debug"    
    },

    shim: {
        "breeze": {
            "deps": ["Q"]
        }
    }, 
});


require(["breeze"], function (breeze) {
    //do something
});

Here is the app.build.js build file:

({
    baseUrl: "../App",
    mainConfigFile: '../app/main.js',
    name: "main",
    out: "../Build/Output/main-built.js"
})
War es hilfreich?

Lösung

Don't know why you're getting that error.

To be honest, we are unlikely to explore why any time soon mostly because we're not convinced that merging the entire application into a single file is a goal we would pursue with much enthusiasm.

There is great value in reducing the number of script files but it's not clear that there is much value in reducing that number to one. Breeze itself is on the (ahem) larger side so you've got a pretty healthy payload for that script request alone. A browser that can ask for scripts in parallel might actually load several scripts more quickly than it could load just one big script. And, finally, you could benefit from loading Breeze from a CDN rather than as embedded material in a mondo-script file on your web server.

Still, we hate the idea that this is failing for you. If you can figure out what is going on, we'd take reasonable steps to correct it. Thanks ... from the Breeze team.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top