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 https://github.com/rollup/rollup/wiki/pkg.module obscure.

EDIT: Oh boy: https://github.com/d3/d3/issues/3138

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

@tom?

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

It has both a umd and esm rollup.

umd: https://unpkg.com/@redfish/agentscript
esm: https://unpkg.com/@redfish/agentscript?module

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

AgentScript: test es6 module import() and umd require() / Owen Densmore | Observable

earlier. It’s there now