asg017 / unofficial-observablehq-compiler

An unofficial compiler for Observable notebook syntax
https://www.npmjs.com/package/@alex.garcia/unofficial-observablehq-compiler
115 stars 22 forks source link

Show example of compiling without Inspector #13

Open tangert opened 4 years ago

tangert commented 4 years ago

Hey Alex, I'm interested in using the compiler server side but I'm having trouble getting a result compiling cell content and seeing the outputted JS without using the inspector. Wondering if you have any examples you've played with already. I'll keep hacking away and provide updates.

bryangingechen commented 4 years ago

Apologies if I'm misunderstanding what you want, but the current version of the compiler doesn't actually output JS code when given the source code of a cell or notebook. It's a bit more like an "interpreter", in that it takes the input and returns a "define" function (in memory) that is suitable for passing to the Observable runtime's runtime.module method.

Issue #5 tracks an addition which would actually be more like a source-to-source compiler.

tangert commented 4 years ago

@bryangingechen no you’re right, I think I was just misunderstanding the docs. Have to dig a bit more, but thanks for linking the other issue.

bryangingechen commented 4 years ago

@tangert source-to-source compiler functions have been added as of v0.5.0. See the compile.moduleToESModule and compile.notebookToESModule methods.