Kudos, notebook to nodejs works

Wow I did not expect there would be a working solution but yes! I can actually pull notebook JS into nodejs ecosystem from the commandline!

  npm install @observablehq/runtime@4
  npm install "https://api.observablehq.com/@tomlarkworthy/rate-estimation-min.tgz?v=3"

The complete example is here

I am constantly impressed with the quality of the foundations of Observable. I am learning so much from seeing how this thing is put together. I never thought a notebook could be module.

So now I can really explore serverside topics in notebooks and depend on them directly. Amazing! I am in such awe of your guys work and the platform, I wish you the best.


you’re going too fast :slight_smile:

I would suggest to add as the first line:

npm init --yes 

and the index.mjs needs a bit of work (copy/pasted it breaks).

  import notebook from '@tomlarkworthy/rate-estimation-min'
  import Observable from '@observablehq/runtime'
  const module = new Observable.Runtime().module(notebook);
  module.value("rate_estimator").then(rate_estimator => {
    const estimatorA = rate_estimator();

Works on nodejs 15. Top level await in modules is a relatively new v14.8.0 feature so probably thats the issue.

Thanks for the feedbacks I updated the notebook.

This rate limiter is for the serverside cells. Though I think it be nice to rate limit reactive updates too (e.g. ‘now’ is often too fast).

ah ok. I’m was still with v14.4.0 :slight_smile:

One surprise for me is commonJS modules (require) cannot import ESM modules (import), so you have to convert your codebase to entirely to ESM incl. dependencies, so hope your dependencies have ESM packaging too! I was lucky in that this was not a problem. So I am happy to report the serverside cells[1] (now renamed to serverless cells) have rate limiting authored on Observable too.