Creating Externs For Dummies
There are a lot of high quality, useful JS libraries. Most of these have not been packaged for cljsjs. Of the ones that have been packaged for cljsjs, many of them are out of date. On paper, externing is a straightforward process where a list of functions and variables are declared so the advanced compiler won't touch their names. In practice, I can't figure out how to do it.
The current guide to externing is detailed here: https://github.com/cljsjs/packages/wiki/Creating-Externs. A reader of that page is clearly there to create externs, it says right in the URL: "Creating-Externs". It describes what an extern is, purpose, and necessity but leaves the reader hanging on the exact process to create externs. Resources are listed but the concrete process to extern creation is an exercise left to the reader.
What needs to be there is a step by step idiot proof way to create externs. For example, suppose I want to extern an NPM package. Which files must I include during the externing process? Which versions? Where can I find these files? What is the blessed method of extern creation?
For example, suppose I want to extern an NPM package. Which files must I include during the externing process?
NPM packages can't usually be consumed by browser as-is and are first compiled to a single browser compatible file (UMD module or such) using browserify/webpack/etc. This single file would be the one to package in Cljsjs and one to generate files from.
For people still trying to figure out how to create externs, you may want to have a look at the following video and the companion Github repo. While it's not a complete comprehensive tutorial it does provide some useful information that may be helpful to people that are struggling to create externs.
https://www.youtube.com/watch?v=p6UMq4LSKl0
and the Github repo that goes with it:
https://github.com/lambdaisland/thirdpartyjs
There are also extern generators like the one below which can automate most or all the process.
https://github.com/jmmk/javascript-externs-generator https://jmmk.github.io/javascript-externs-generator/