UNPKG

581 BJavaScriptView Raw
1import * as tslib_1 from "tslib";
2import vm from 'vm';
3import { CLIENT_SIDE_ONLY } from '../configuration/constants';
4var 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};
16export var commentsToConfiguration = function (comments) {
17 return comments.reduce(function (acc, comment) { return (tslib_1.__assign({}, acc, parseMagicComments(comment))); }, {});
18};