Skip to content

Commit

Permalink
fixup! api: require option documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dustyo-O committed Feb 12, 2018
1 parent 3833d24 commit 7944c91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 12 additions & 2 deletions docs/en/3-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ For example:
requires: {
'lib-name': {
globals: 'libName', // Variable name from global scope
ym: 'lib-name', // Module name from YModules
commonJS: 'path/to/lib-name' // path to CommonJS library
commonJS: 'path/to/lib-name', // path to CommonJS library
ym: 'lib-name' // Module name from YModules
}
}
}
Expand Down Expand Up @@ -493,6 +493,16 @@ E.g. if you specify just global scope the library will only be available as glob
}
```

In other case, if you specify multiple modular systems, template will attempt to get it from them in this order:
1) global
2) CommonJS
3) YModules (if available)
If required module was found on some step, next steps will be ignored and template will use that first retrieved module.

Thus, if module available in global variable, its value will be provided inside template, in spite of module avialability in CommonJS/YModules.

Same way, CommonJS module is more prior to YModules one.

Example of using `moment.js` library:

You don’t need to to provide path to module:
Expand Down
6 changes: 2 additions & 4 deletions docs/ru/3-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ templates.BEMContext.prototype.onError = function(context, err) { … };
requires: {
'lib-name': {
globals: 'libName', // Название переменной в глобальной видимости
commonJS: 'path/to/lib-name' // Путь к модулю CommonJS относительно собираемого файла
ym: 'lib-name', // Имя модуля из YModules
commonJS: 'path/to/lib-name', // Путь к модулю CommonJS относительно собираемого файла
ym: 'lib-name' // Имя модуля из YModules
}
}
}
Expand Down Expand Up @@ -496,8 +496,6 @@ block('button').content()(function () {

И также, модуль из CommonJS приоритетнее модуля в YModules.

Это позволяет, например, переопределять ваши модули на статические объекты в целях тестирования в соответствующих конфигурациях.

**Пример подключения библиотеки `moment`**

Указывается путь к модулю:
Expand Down

0 comments on commit 7944c91

Please sign in to comment.