NPM Best Practices for Observable

I’m converting my github repo to also be a npm project … see Best practices for non AMD/UMD package

Any pointers to making a really good npm package?

In particular, one that would be Observable-friendly?

I have finally groked UMD and converted my github repo to be UMD where there were IIFEs.

But npm seems more subtle than I thought. Many keys in package.json that I don’t really understand. (files? main? jsnext:main? module? …). I find obscure.

EDIT: Oh boy:

I don’t feel stupid anymore. It is hard!


OK, we’ve got a first shot at a npm package: @redfish/agentscript.

It has both a umd and esm rollup.


Observable: You can require the umd or import the esm. The short forms appear to work:

umd = require("@redfish/agentscript")
esm = import("@redfish/agentscript")

(Not sure if this works if there is a user named “redfish”.)

Both long and short form are shown here:

Oops, forgot to publish

earlier. It’s there now