Frage

The Answer is below the question:

Maybe I don't understand the whole RequireJS thing fully, but here is my problem:

I got a set of files like that:

  • sub
    • sub1.js
    • sub2.js
  • main.js

In all of the files in sub, i use the define() function to define modules. In the main.js, i use the require() function to load all modules. All of this works.

Now when i run the optimizer (r.js) on the main.js, it just takes the content of all files and puts it into one file. Yes, i can then use this optimized file to do the same as what i could do with the multiple files.

All good, no error.

Now my question: In that optimized file, it still uses RequireJS. Can i optimize it to the point, where it doesn't use RequireJS, where it's just the functions put together?

Answer

You can only include RequireJS into your optimized file by setting the include option to "requireLib".

War es hilfreich?

Lösung

Are you trying to load the file in the script tag w/o using data-main + require.js? OR, are you trying to render the file so that RequireJS is no longer used at all? I suspect it's the latter, which is not possible. If the former, that is achieved by bundling Require in via a build file option: http://youtu.be/m6VNhqKDM4E?t=12m44s

Andere Tipps

No you cant. The point of the r.js is to compile all your dependencies situated in multiple files into one. So even after compiling the modules are still AMD modules, but now without the need to load them separately. And the modules still need an AMD loader to get work. The only thing you can do after compiling is to use a more lightweight loader loader like Almond

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