tinypilot icon indicating copy to clipboard operation
tinypilot copied to clipboard

Manage frontend dependencies via npm / package.json

Open jotaen4tinypilot opened this issue 2 years ago • 1 comments

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.

jotaen4tinypilot avatar Mar 30 '22 11:03 jotaen4tinypilot

This is strongly related, by the way, to the topic of bundling.

jotaen4tinypilot avatar Mar 30 '22 11:03 jotaen4tinypilot