API Docs for: 0.2.0
Show:

express-yui_lib_patches_optional-requires Module

Patches Y.Loader to support optionalRequires, which enables you to require modules that might not be available in a runtime, and avoid to throw when that happens.

!IMPORTANT/TODO: this patch can be removed once we get PR1629 merged into YUI.

It also add support for modules that are essencially polyfills, this means that some modules can only be used if the test is passed first otherwise they should be ignored.

This helps when it comes to define modules that are only available on the server or client, or polyfills, while other modules that are common can require them as optionals.

app.yui.patch(require('express-yui/lib/patches/optional-requires'));

When this patch is applied, you can add a new entry called test in the metas for a module, this entry is a functions. If the test fails, the module will be automatically discarded.

Note that the optional implementation in YUI does not cover this case, and it only covers the case where the module was required or not by another module in the use statement, which is not quite the same.