[Pkg-javascript-devel] Building bundles in postinst/trigger

Dominik George natureshadow at debian.org
Sat Aug 6 09:53:27 BST 2022


Hi,

for the packaging of [AlekSIS], I have a maybe somewhat strange question:

  Is it ok to build a webpack bundle in a maintainer script, or even a trigger?

Before throwing stones at me, let me explain a bit:

AlekSIS is a modular system, consisting of apps that are developed as reusable Django apps. Each app can ship a set of frontend scripts, in the form of Vuejs components.

Now this would all be quite trivial; after all, the respective app views could simply load the static frontend files through <script> tags, right?

Not quite – one huge challenge for AlekSIS is that it is used by teachers during classes, in buildings where there is no mobile network connectivity, let alone stable Wifi. So the AlekSIS frontend needs to run fully offline, caching changes to data until it gets back online. You can look at this as building a fully independent frontend app, that will be delivered as a PWA in one piece and then does not need the server for any frontend task anymore, it only calls GraphQL mutations after loading the bundle.

Then, for a monolithic app, this could all be done at build time (with the drawback of getting a ton of code copies in the binary package). But AlekSIS is modular – a school might start out without the class register app, and install that component later on. The frontend bundle needs to be updated then.

So, assuming that I have all dependencies nicely available in Debian as node-* packages, is it okay to run webpack in a postinst script to build a bundle on the target machine? And even install a trigger in the AlekSIS-Core package that triggers a rebuild of the bundle every time an app module is installed or upgraded?


Another approach would be to use webpack entry points to build one bundle per app package, and to that at build time. However, I think carrying code copies built into the binary package is worse.


What do others here think? Maybe someone has another idea yet?

Cheers,
Nik

  [AlekSIS]: https://aleksis.org/



More information about the Pkg-javascript-devel mailing list