According to the documentation:
The estate paths
allows you to map modules that are to other locations than the URL
basis of the script.
One of the uses indicated in documentation is for fallback, that is, 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 property map
allows scripts (modules) different from the same project that may require a third module to use different versions of this module.
Example:
requirejs.config({
map: {
'newmodule': {
'foo': 'foo1.2'
},
'oldmodule': {
'foo': 'foo1.0'
}
}
});
According to the above configuration, when newmodule
use require('foo')
he will receive foo1.2.js
. How much oldmodule
do the same, he will receive foo1.0.js
.
Use to define which version of a particular module should be imported by each module.
Your reply is clearer than the documentation, thank you.
– Gabriel Gartz