LivelyKernel / lively4-core

A Self-supporting, Web-based Development Environment
https://lively-kernel.org/lively4/lively4-core/start.html
MIT License
73 stars 25 forks source link

Conflicting Var-Recorder and the Live-Programming plugin #372

Open onsetsu opened 5 years ago

onsetsu commented 5 years ago

Error

Printing the following code in a Workspace results in unexpected behavior:

var array = [1,2,3]
debugger
array = []
debugger
array

The above code, executed in one go, evaluates to [1, 2, 3]. However it should evaluate to an empty array.

Executing the code line-by-line results in the expected bahavior.

Possible Explanation

The issue may result from the interaction of two babel plugins, the Var-Recorder and the Live-Programming plugin, inside a workspace.

(function(System, SystemJS) {System.register([], function (_export, _context) {
  "use strict";

  return {
    setters: [],
    execute: function () {
      var __global_this__ = window.__pluginDoitThisRefs__["efafc263-5f9e-447b-aa34-68ee3ed50caf/"];
      var array = [1, 2, 3];
      _recorder_.undefined.array = array;
      debugger;
      _recorder_.undefined.array = [];
      debugger;
      const __result__ = array;

      _export("__result__", __result__);
    }
  };
});
})(System, System);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndvcmtzcGFjZWpzOmVmYWZjMjYzLTVmOWUtNDQ3Yi1hYTM0LTY4ZWUzZWQ1MGNhZi9saXZlbHkta2VybmVsLm9yZy9saXZlbHk0L2FleHByL3VubmFtZWRfbW9kdWxlXzQxNWEyZjFiXzhmYjhfNDhjZF9hNmFkXzdlYmQ5ZTgxZjhjMiJdLCJuYW1lcyI6WyJhcnJheSJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQUFBLFVBQUlBLFFBQVEsQ0FBQyxDQUFELEVBQUcsQ0FBSCxFQUFLLENBQUwsQ0FBWjs7QUFDQTtBQUNBLG1DQUFRLEVBQVI7QUFDQTt5QkFDQUEsSyIsImZpbGUiOiJ1bm5hbWVkX21vZHVsZV80MTVhMmYxYl84ZmI4XzQ4Y2RfYTZhZF83ZWJkOWU4MWY4YzIiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYXJyYXkgPSBbMSwyLDNdXG5kZWJ1Z2dlclxuYXJyYXkgPSBbXVxuZGVidWdnZXJcbmFycmF5XG4iXX0=

Executing both plugins leads the Live-Programming plugin to not use the rewritten value, but its original un-proxied reference.

Also notice the undefined module name resulting from evaluating the script inside a workspace. I did not yet checked for similar behavior inside a named js-module.

Possible Solutions

Rewriting both aspects in one go might remove this issue. If not, the Live-Programming plugin should be applied only after the Var-Recorder.

Similar Issues

257

JensLincke commented 4 years ago

still an issue image