/
all.js
35 lines (29 loc) · 1016 Bytes
/
all.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
// The order of these transforms is informed by how they were done in the
// requirejs optimizer.
var transforms = [
require('./stubs'),
require('./defines'),
require('./replace')
];
/**
* Chains all the default set of transforms to return one function to be used
* for transform operations on traced module content.
* @param {Object} options object for holding options. The same options object
* is used and passed to all transforms. See individual transforms for their
* options.
* @return {Function} A function that can be used for multiple content transform
* calls.
*/
module.exports = function all(options) {
options = options || {};
var transformFns = transforms.map(function(transform) {
return transform(options);
});
return function(context, moduleName, filePath, contents) {
contents = transformFns.reduce(function(contents, transformFn) {
return transformFn(context, moduleName, filePath, contents);
}, contents);
return contents;
};
};