Skip to content

Commit d5b9cbc

Browse files
committed
0.2.0
1 parent a30e167 commit d5b9cbc

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

doc/rationale.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Rationale
2+
3+
lively.modules provides a framework for loading, defining and interactively
4+
modifying JavaScript modules. A module is an entity containing JavaScript
5+
source code that adheres to the definition of the
6+
[ECMAScript Language Specification](https://tc39.github.io/ecma262/#sec-modules).
7+
8+
## Live development
9+
10+
lively.modules provides an interface to support interactive development with
11+
[es6 modules](http://exploringjs.com/es6/ch_modules.html). In particular it
12+
allows to capture the runtime state (internal variables and definitions) of
13+
modules to allow to access local state when evaluating code in module contexts.
14+
It also allows to iteratively update the runtime state of a module (e.g.
15+
modifying a function or adding a new definition) and will take care that
16+
dependencies are updated accordingly.
17+
18+
## Packages
19+
20+
Since the EcmaScript standard does not define a package concept (package = set
21+
of modules belonging togeter), lively.modules adds a very lightweight
22+
convention for identifying and loading packages that is mostly based on
23+
the [npm package conventions](https://docs.npmjs.com/how-npm-works/packages).
24+
25+
This is crucial because es6 modules leave name resolution open to the
26+
[module loader implementation](https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule).
27+
28+
Consider an import statement like
29+
30+
```js
31+
import { foo } from 'some-package/bar.js';
32+
```
33+
34+
To what specific resource (modules don't need to be files!)
35+
`'some-package/bar.js'` is resolved is up to the loader, i.e. up to
36+
lively.modules. Using the package concept we can have simple conventions that
37+
define how a resource like `some-package` can be found.
38+
39+
## Lively ecosystem
40+
41+
A flexible and lightweight notion of packages can help us to make Lively more
42+
"approachable", meaning that the system can be broken into clearly defined
43+
sub-systems thus reducing the complexity of an otherwise monolothic syste,
44+
Also, those package can be re-used outside the main Lively system.
45+
46+
## Debugging
47+
48+
The main problem we faced when implementing the source-transformation-based
49+
debugging approach was code management: Once the number of modules approaches
50+
non-trivial numbers it becomes a resource intensive task to manage rewritten
51+
and original code in a way that is performant enough for convenient interactive
52+
development. This especially posed a problem b/c the semnatics of JavaScript
53+
allow lexical scoping and with that "hiding" internal module state. Once a
54+
not-transformed conventional JS "module" is defined there is no generic way to
55+
instrument it later.
56+
57+
es6 modules provide a new restriction between modules: Module boundaries are
58+
clear and can be statically determined. Imports and exports are restricted to
59+
well defined notion of bindings that allows live updates and circular
60+
references. By treating modules as "black boxes", a source-transformation
61+
debugger can gradually transform modules, redefining them but maintaining their
62+
exported state.
63+
64+
## PartsBin
65+
66+
A tension that exists in the PartsBin workflow up to this point is the mix of
67+
state (think "binary" blobs of serialized objects) and source code. So far, the
68+
existing Lively module system and serialized objects don't share a common
69+
concept, making them harder to learn and use. Modules and packages might offer
70+
an interesting alternative: Since a module can be any kind of resource, not
71+
just JS statements, we can mix code and serialized objects in our package
72+
concept. This would allow to combine both approaches from the ground up.
73+
74+
...

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lively.modules",
3-
"version": "0.1.7",
3+
"version": "0.2.0",
44
"main": "dist/lively.modules.js",
55
"scripts": {
66
"test": "mocha-es6 tests/*-test.js",

0 commit comments

Comments
 (0)