-
Notifications
You must be signed in to change notification settings - Fork 47
/
wrapper_template.js
40 lines (32 loc) 路 1.41 KB
/
wrapper_template.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
36
37
38
39
40
import template from 'babel-template';
export default template(`
module.exports = function __injector(__injections) {
__injections = __injections || {};
(function __validateInjection() {
var validDependencies = DEPENDENCIES;
var injectedDependencies = Object.keys(__injections);
var invalidInjectedDependencies = injectedDependencies.filter(function (dependency) {
return validDependencies.indexOf(dependency) === -1;
});
if (invalidInjectedDependencies.length > 0) {
var validDependenciesString = '- ' + validDependencies.join('\\n- ');
var injectedDependenciesString = '- ' + injectedDependencies.join('\\n- ');
var invalidDependenciesString = '- ' + invalidInjectedDependencies.join('\\n- ');
throw new Error('Some of the injections you passed in are invalid.\\n' +
'Valid injection targets for this module are:\\n' + validDependenciesString + '\\n' +
'The following injections were passed in:\\n' + injectedDependenciesString + '\\n' +
'The following injections are invalid:\\n' + invalidDependenciesString + '\\n'
);
}
})();
var module = { exports: {} };
var exports = module.exports;
function __getInjection(dependency) {
return __injections.hasOwnProperty(dependency) ? __injections[dependency] : null;
}
(function () {
SOURCE
})();
return module.exports;
}
`);