From 83bbc5edab4fb9a8ff66bc1d4e4aafaff07b9646 Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Fri, 5 Mar 2021 19:43:38 +0100 Subject: [PATCH] fix for undefined, back to production mode --- src/js/index.js | 58 +++++++++++++++++++++++++---------------------- webpack.config.js | 2 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 593255e..9b2c19a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -134,38 +134,42 @@ const handle_enter = function () { let tokens = scan(command); let statement = parse(tokens); value = visit(statement); - let binding; - if (value.is_binding) { // if it's declaration work with the initializer - binding = value.name; // but we also need the name of the bound variable - value = state[binding]; // lookup the value for the binding - } else if (Object.prototype.hasOwnProperty.call(value, ['id'])) { - references['@' + value.id] = value; - } - while (value.lazy_expression) { - value = value.get(); - } - if (binding) { - bindings[binding].evaluated = value; // store evaluation result - } + if (value !== undefined) { + let binding; + if (value.is_binding) { // if it's declaration work with the initializer + binding = value.name; // but we also need the name of the bound variable + value = state[binding]; // lookup the value for the binding + } else if (Object.prototype.hasOwnProperty.call(value, ['id'])) { + references['@' + value.id] = value; + } + while (value.lazy_expression) { + value = value.get(); + } + if (binding) { + bindings[binding].evaluated = value; // store evaluation result + } - if (value.is_visual) { - if (binding && bindings[binding].previous && bindings[binding].previous.is_visual) { - update_vector_arrow(bindings[binding].previous.id, value); + if (value.is_visual) { + if (binding && bindings[binding].previous && bindings[binding].previous.is_visual) { + update_vector_arrow(bindings[binding].previous.id, value); + } else { + if (value.is_new) { + value.label_text = binding ? binding : ""; + value.is_new = false; + add_vector_arrow(value); + } + } } else { - if (value.is_new) { - value.label_text = binding ? binding : ""; - value.is_new = false; - add_vector_arrow(value); + if (binding && bindings[binding].previous && bindings[binding].previous.is_visual) { + label(bindings[binding].previous, '@' + bindings[binding].previous.id); } } - } else { - if (binding && bindings[binding].previous && bindings[binding].previous.is_visual) { - label(bindings[binding].previous, '@' + bindings[binding].previous.id); + update_visible_objects(); + if (value.description) { + value = value.description; } - } - update_visible_objects(); - if (value.description) { - value = value.description; + } else { + value = 'value is undefined'; } } catch (exception) { value = exception.message; diff --git a/webpack.config.js b/webpack.config.js index 738094f..0ba298c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); const HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { - mode: 'development', + mode: 'production', entry: './src/js/index.js', output: {