Requirejs: paths vs map

后端 未结 3 2008
自闭症患者
自闭症患者 2020-12-17 08:29

Trying to understand where it\'s right to use \"map\" with a wildcard vs \"paths\".

Looking at the require source (but certainly not being 100% fluent with it) it s

3条回答
  •  轮回少年
    2020-12-17 08:50

    I have found one difference, and that's in the case of requirejs loader plugins, example Example: define(['cs!module'], function(){...} ) for CoffeeScript.

    Using the map:* part of config for declaring the plugins (and paths for dependent modules) worked in the browser. However, in Node, Requirejs would fail to locate the loader plugins unless they were under paths.

    In the end, for the sake of being able to run the same config in Node and the browser, I got rid of the map:* section, and declared everything in paths and it works just fine for me now, even if I'm still hoping to get some clarification on why.

提交回复
热议问题