asg017 / dataflow

An experimental self-hosted Observable notebook editor, with support for FileAttachments, Secrets, custom standard libraries, and more!
https://alexgarcia.xyz/dataflow/
MIT License
400 stars 24 forks source link

Bundler plugins for webpack, esbuild, rollup, etc. #15

Open asg017 opened 3 years ago

asg017 commented 3 years ago

I think it would be cool to make plugins for common JavaScript build/bundler tools in order to make it easier to embed Dataflow notebooks into other applications. These plugins would compile .ojs files into ES modules (as well as handle FileAttachments the dataflow-way), in ways like:

import {Runtime} from "@observablehq/runtime"
import {Library} from "@alex.garcia/dataflow/core" // not possible right now
import define from "./notebook.ojs"

// could also be react, vue, svelte, etc.
function main() {
  const runtime = new Runtime(new Library());
  const main = runtime.module(define, Inspector.into(document.body));
  // etc.
}

The bundler tool would compile .ojs imports into ES modules, similar to dataflow compile.