All files / frontend/webpack require-polyfill.js

100% Statements 10/10
75% Branches 3/4
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251183x             1183x 4763x   4763x 25x   4738x 14178x 14178x       4738x 4738x        
define(['jquery', 'underscore', 'require-context'], function ($, _, requireContext) {
    /**
     * Provides a polyfill to hijack require() calls in twig templates
     *
     * @param  {String|Array}   modules An array of module names to request, or a string for a single module
     * @param  {Function} cb      The callback to run after fetching the module
     */
    return function(modules, cb) {
        var resolvedModules = [];
 
        if (typeof modules === 'string') {
            return requireContext(modules);
        } else {
            _.each(modules, function (module) {
                var resolvedModule = requireContext(module);
                resolvedModules.push(resolvedModule);
            });
        }
 
        Eif (cb) {
            cb.apply(this, resolvedModules);
        }
    };
});