What is the difference between a path and map Requirejs

0
146
map vs path requirejs

After researching this a bit more, I have found one major difference between map and path.

+ map allows for ‘prefix mapping’
+ path only allows for exact matches

Example:

Using Map:

map: {
‘*’: {
editTrigger: ‘mage/edit-trigger’,
}
}

ensure the loading the editTrigger module actually loads the mage/edit-trigger module, but also that editTrigger/foo would load the mage/edit-trigger/foo module.

But when we Using Paths:

paths: {
editTrigger: ‘mage/edit-trigger’,
}

The paths directive is not a prefix mapping. It’s a simple one-to-one mapping.

If you want load file mage/edit-trigger/foo -> we need define:

paths: {
editTrigger: ‘mage/edit-trigger/foo’,
}