The first commit 2ef363f is the same as in #6. To reply to your comment from that PR, I would support a request for the parser package to export acorn's simple (though maybe since parser is an acorn plugin they could use peerDependencies instead? not sure...). Also, I guess I could've set the version for acorn-walk to the same version that the parser uses, but it slipped my mind...
The second commit 618a215 implements imports for viewof & mutable cells:
I had to change the code for specifiers and injections from map to a for...of loop because viewof and mutable imports add more than one new cell. I was a little unsure about what to do with import...with so I did some testing which led to this issue; Given Mike Bostock's reply there I'm pretty confident that the implementation is correct now.
I added a new flag hasInjections that controls whether to derive a new module or not. Previously, the generated define function was derive-ing for every import, which differs from the behavior on the ObservableHQ site, where only modules that are imported using with get derive'd.
I still haven't added any tape tests, just some examples from the above forum post in test.html.
The third and fourth commits are other tweaks. I noticed that the define function is currently using creating its own Library for Generators (and Mutable in my addition). In the third commit 5eb6098, I changed this to just rely on the runtime's builtin module, as in the ES modules served by the Observable API (example. This is a little more efficient at runtime (as is, the user will have an extra Library object from the compiler) and also allows us to move the runtime package to the dev dependencies since it's now only used in the tests.
The fourth commit b5482fc is just a style thing, I noticed that the markdown cells labeling the imports had a level of indentation which didn't seem intentional so I removed it. Let me know if I guessed wrong and you want the indentation back.
Feel free to add comments to the code if you have questions!
The first commit 2ef363f is the same as in #6. To reply to your comment from that PR, I would support a request for the
parser
package to export acorn'ssimple
(though maybe sinceparser
is an acorn plugin they could use peerDependencies instead? not sure...). Also, I guess I could've set the version foracorn-walk
to the same version that the parser uses, but it slipped my mind...The second commit 618a215 implements imports for viewof & mutable cells:
specifiers
andinjections
frommap
to afor...of
loop because viewof and mutable imports add more than one new cell. I was a little unsure about what to do withimport...with
so I did some testing which led to this issue; Given Mike Bostock's reply there I'm pretty confident that the implementation is correct now.hasInjections
that controls whether toderive
a new module or not. Previously, the generateddefine
function wasderive
-ing for every import, which differs from the behavior on the ObservableHQ site, where only modules that are imported usingwith
getderive
'd.tape
tests, just some examples from the above forum post intest.html
.The third and fourth commits are other tweaks. I noticed that the
define
function is currently using creating its ownLibrary
forGenerators
(andMutable
in my addition). In the third commit 5eb6098, I changed this to just rely on the runtime's builtin module, as in the ES modules served by the Observable API (example. This is a little more efficient at runtime (as is, the user will have an extraLibrary
object from the compiler) and also allows us to move theruntime
package to the dev dependencies since it's now only used in the tests.The fourth commit b5482fc is just a style thing, I noticed that the markdown cells labeling the imports had a level of indentation which didn't seem intentional so I removed it. Let me know if I guessed wrong and you want the indentation back.
Feel free to add comments to the code if you have questions!