1 | import * as tslib_1 from "tslib";
|
2 | import vm from 'vm';
|
3 | import { CLIENT_SIDE_ONLY } from '../configuration/constants';
|
4 | var parseMagicComments = function (str) {
|
5 | if (str.trim() === CLIENT_SIDE_ONLY) {
|
6 | return {};
|
7 | }
|
8 | try {
|
9 | var values = vm.runInNewContext("(function(){return {" + str + "};})()");
|
10 | return values;
|
11 | }
|
12 | catch (e) {
|
13 | return {};
|
14 | }
|
15 | };
|
16 | export var commentsToConfiguration = function (comments) {
|
17 | return comments.reduce(function (acc, comment) { return (tslib_1.__assign({}, acc, parseMagicComments(comment))); }, {});
|
18 | };
|