Reputation: 12561
I'm encountering a situation where a path set in the configuration for require.js is not being honored, and I have two guesses as to why not. I've set the following entry in the paths of my require config:
"initVars": "../initVars"
And then in a module I'm able to successfully refer to it simply as "initVars"
However, I'm also trying to refer to the above in a script block directly in the HTML immediately below the script tag src'ing require.js (and of course specifying the config file in the 'data-main' attribute):
//require(['initVars'], function(VARS) { // *doesn't work*
require(['../initVars'], function(VARS) {
VARS.init({
ENV: "${env}"; //"Play" framework "template" variable
});
});
So my two guesses as to why in this particular situation I must specify the full path are as follows, but I'm hoping somebody can tell me for certain:
Upvotes: 0
Views: 165
Reputation: 19397
See the data-main Entry Point section in the documentation:
Note: the script tag require.js generates for your data-main module includes the async attribute. This means that you cannot assume that the load and execution of your data-main script will finish prior to other scripts referenced later in the same page.
And also this older answer that was written before the above was added to the API documentation:
Require.js bug random Failed to load resource
Upvotes: 4