Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using Requirejs, is it possible to have the optimizer automatically find all the dependencies?

I have many modules. One module loads another module, which loads another module. Etc...

And of course, when I load the page, all of these modules load. It works perfectly. Without the optimizer. (even though it takes a minute, because the browser has to load 50 things).

When I use optimizer...in my app.build.js, it seems that I have to manually specify each module!??

Why can't optimizer automatically traverse through the modules?

like image 941
user847495 Avatar asked Nov 18 '25 06:11

user847495


2 Answers

You only have to specify the module you wanna optimize, not its dependencies. From the docs:

In the modules array, specify the module names that you want to optimize, in the example, "main". "main" will be mapped to appdirectory/scripts/main.js in your project. The build system will then trace the dependencies for main.js and inject them into the appdirectory-build/scripts/main.js file.

({
    appDir: "../",
    baseUrl: "scripts",
    dir: "../../appdirectory-build",
    modules: [
        {
            name: "main"
        }
    ]
})
like image 102
Andreas Köberle Avatar answered Nov 19 '25 18:11

Andreas Köberle


Solved.

I had my paths wrong (I didn't understand baseURL , etc) . That's why things broke in the middle.

like image 30
user847495 Avatar answered Nov 19 '25 18:11

user847495