-1

I am building a JavaScript module. Can load the first file in the module no problem. From there I want to load other files, but requirejs follows the path from the index. I want the functions in the module to be available in global scope. The structure is like this:

index.html:

<script src="scripts/app.js"></script>

app.js:

requirejs([ "../../modules/foo" ], function(util) {
});

modules/foo.js:

requirejs([ "bar" ], function(util) {
});

That gives the error: ERR_FILE_NOT_FOUND, well, yes, if you look from app.js you will not find it. How to force requirejs to load from the module?

These posts are probably related, but I can't wrap my head around it:

RequireJS relative paths

Using require with relative paths

Community
  • 1
  • 1

1 Answers1

0

This is the way I found around this: Create a minified && uglified && required file, where all other files are loaded into. Also know as the RequireJS Optimizer.