tinypilot
tinypilot copied to clipboard
Manage frontend dependencies via npm / package.json
Currently, our frontend dependencies all reside in app/static/third-party
, and we use the naming pattern ./library-name/version/file.js
.
That way, we are depending on pre-built script-type versions of the libraries, and have to dump them into the global namespace via <script src="">
tags.
Since we are using JS modules for our own JS code, it could be nicer to use module-type versions of the libraries, and have them automatically installed via npm from the package.json
file.
It’s possible (and not uncommon) to check in the node_modules
folder into the repository, to rule out the failure case of the npm servers being down at install time, or other leftpad-like shenanigans.
npm supports specifying the install location via the --prefix
option, so we can install to app/static/node_modules
, for example.
This is strongly related, by the way, to the topic of bundling.