react-imported-component
Version:
I will import your component, and help to handle it
23 lines (22 loc) • 829 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.commentsToConfiguration = void 0;
var tslib_1 = require("tslib");
var vm_1 = (0, tslib_1.__importDefault)(require("vm"));
var constants_1 = require("../configuration/constants");
var parseMagicComments = function (str) {
if (str.trim() === constants_1.CLIENT_SIDE_ONLY) {
return {};
}
try {
var values = vm_1.default.runInNewContext("(function(){return {" + str + "};})()");
return values;
}
catch (e) {
return {};
}
};
var commentsToConfiguration = function (comments) {
return comments.reduce(function (acc, comment) { return ((0, tslib_1.__assign)((0, tslib_1.__assign)({}, acc), parseMagicComments(comment))); }, {});
};
exports.commentsToConfiguration = commentsToConfiguration;
;