I\'m using require.js and r.js to package my AMD modules. I\'m using jquery & requirejs via the following syntax:
How are you defining your require.config? I think for it to take effect before you import require.js, you need to code it like this:
Specifically, a an object named 'require' must be constructed before you import require.js.
UPDATE
As Jesse points out in the comments below, there are a few enhancements you should apply to your require{} object for production use. The above example is cribbed from the RequireJS documentation and modified as little as possible to answer this question.
Here are a few things to consider for production use:
So if you apply these techniques, your code might look like:
Note, in this case {{buildNumber}} is a value supplied by the server.
UPDATE 2
The urlArgs cache bust solution has problems. Unfortunately you cannot control all proxy servers that might be between you and your user's web browser. Some of these proxy servers can be unfortunately configured to ignore URL parameters when caching files. If this happens, the wrong version of your JS file will be delivered to your user.
I would recommend using a buildNumber
in your Javascript filename request, like buildNumber.myModule.js
(prefix) or myModule.buildNumber.js (postfix). You can use the prefix style by modifying the baseUrl:
baseUrl: "/scripts/buildNumber",
Note the lack of a '/' at the end of the baseUrl.
You will need to use a modified version of require.js to use the postfix solution. You can read more about this here: https://stackoverflow.com/a/21619359/1017787
Obviously in either case you will want to use some solution to replace buildNumber
with some type of version number that changes with each release.