According to documentation :
The paths
property allows you to map modules that are to locations other than the URL
base of the script.
One of the uses indicated in documentation is for fallback , that is, to allow the use of the script from a CDN in production and from a local URL for development.
And example is:
requirejs.config({
//To get timely, correct error triggers in IE, force a define/shim exports check.
enforceDefine: true,
paths: {
jquery: [
'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min',
//If the CDN location fails, load from this location
'lib/jquery'
]
}
});
//Later
require(['jquery'], function ($) {
});
Use to set alternative locations for the same module.
On the other hand, the map
property allows different scripts (modules) of the same project that require a third module to use different versions of that module.
Example:
requirejs.config({
map: {
'newmodule': {
'foo': 'foo1.2'
},
'oldmodule': {
'foo': 'foo1.0'
}
}
});
According to the above configuration, when newmodule
uses require('foo')
it will receive foo1.2.js
. When oldmodule
does the same, it will receive foo1.0.js
.
Use to define which version of a particular module should be imported by each module.