From 059dfd7f5f9cfc6111320eb2c0c45c1fb2a29f80 Mon Sep 17 00:00:00 2001 From: qilei0529 Date: Mon, 21 Dec 2020 19:59:44 +0800 Subject: [PATCH] feat: remove code in simplified dsl to reduce compiled size --- packages/cli/src/cmd/dev/simplifyDSL.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/cmd/dev/simplifyDSL.js b/packages/cli/src/cmd/dev/simplifyDSL.js index 758e759..53867de 100644 --- a/packages/cli/src/cmd/dev/simplifyDSL.js +++ b/packages/cli/src/cmd/dev/simplifyDSL.js @@ -3,7 +3,11 @@ const fs = require('fs-extra'); const extractObj = (obj = {}, keys = []) => { const ret = {}; - keys.forEach((key) => (ret[key] = obj[key])); + keys.forEach((key) => { + if (obj[key]) { + ret[key] = obj[key]; + } + }); return ret; }; @@ -14,7 +18,9 @@ const simplify = (dsl) => { if (cell.shape === 'edge') { return extractObj(cell, ['id', 'shape', 'source', 'target']); } else { - return extractObj(cell, ['id', 'shape', 'data']); + const newCell = extractObj(cell, ['id', 'shape']); + newCell.data = extractObj(cell.data, ['trigger', 'configData']); + return newCell; } }), };