Bug 40773 - Improve build of "vue/dist" files
Summary: Improve build of "vue/dist" files
Status: Passed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on: 37911 39849
Blocks:
  Show dependency treegraph
 
Reported: 2025-09-09 02:10 UTC by David Cook
Modified: 2025-09-09 23:04 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40773: Do not map "vue/dist" files in Makefile (2.73 KB, patch)
2025-09-09 02:54 UTC, David Cook
Details | Diff | Splinter Review
Bug 40773: Do not map "vue/dist" files in Makefile (2.79 KB, patch)
2025-09-09 09:48 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 40773: Do not map "vue/dist" files in Makefile (2.87 KB, patch)
2025-09-09 10:05 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-09-09 02:10:42 UTC
I've been thinking how the "rm -rf koha-tmpl/intranet-tmpl/prog/js/vue/dist/*" step discussed in "Bug 37911 - Prototype vue islands within static pages" for a build from a git working directory isn't intuitive or easy to know about.

I've also heard of stories where people building from git repos are still getting files included even though they've run "rm -rf koha-tmpl/intranet-tmpl/prog/js/vue/dist/*". This should be impossible, so there's probably something else going on there, but I think I have a solution which removes the necessity for this step anyway.

(Note that for Debian package installs and regular tarball installs, the step isn't needed at all, because the tarballs are generating using "git archive" which doesn't include "vue/dist" files.)

Anyway, the solution is to tell Makefile.PL specifically not to include "koha-tmpl/intranet-tmpl/prog/js/vue/dist/*" in the "$file_map" data structure. That way, it should be impossible for these files to wind up in the "blib" except where we copy them in via the "move_compiled_js" target from bug 39849
Comment 1 David Cook 2025-09-09 02:54:45 UTC
Created attachment 186271 [details] [review]
Bug 40773: Do not map "vue/dist" files in Makefile

This change ensures that "vue/dist" files are not mapped into
the pm_to_blib target of the Makefile, so that they are only handled
by the explicit compile steps in the top targets of the Makefile.

Test plan:
0. Apply the patch
1. perl build-resources.PL
2. ls ./koha-tmpl/intranet-tmpl/prog/js/vue/dist
3. Note that files are present
4. perl Makefile.PL
5. Take all the defaults
6. vi Makefile
7. Search for vue\/dist
8. Note that the only hit is for "cp -r koha-tmpl/intranet-tmpl/prog/js/vue/dist
blib/INTRANET_TMPL_DIR/prog/js/vue/"
Comment 2 David Cook 2025-09-09 03:00:21 UTC
Note that anything in "koha-tmpl/intranet-tmpl/prog/js/vue/dist/" will be copied across into the "blib".

I wonder if rspack.config.js or something else should have a step that ensures that "koha-tmpl/intranet-tmpl/prog/js/vue/dist/" is empty before doing a build?

I suppose build-resources.PL could also do that. Anyway, I'd say that's a bit of a side issue really.
Comment 3 Paul Derscheid 2025-09-09 09:48:55 UTC
Created attachment 186279 [details] [review]
Bug 40773: Do not map "vue/dist" files in Makefile

This change ensures that "vue/dist" files are not mapped into
the pm_to_blib target of the Makefile, so that they are only handled
by the explicit compile steps in the top targets of the Makefile.

Test plan:
0. Apply the patch
1. perl build-resources.PL
2. ls ./koha-tmpl/intranet-tmpl/prog/js/vue/dist
3. Note that files are present
4. perl Makefile.PL
5. Take all the defaults
6. vi Makefile
7. Search for vue\/dist
8. Note that the only hit is for "cp -r koha-tmpl/intranet-tmpl/prog/js/vue/dist
blib/INTRANET_TMPL_DIR/prog/js/vue/"

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 4 Paul Derscheid 2025-09-09 09:49:38 UTC
Hi David, great change. Thanks.
Comment 5 Paul Derscheid 2025-09-09 09:57:07 UTC
Btw, there's a webpack/rspack option:
output: {
  ...
  clean: true,
}
that does exactly that.

But we should probably work on the structure beforehand.
This should be configured for prod, not for dev where you might want to keep old assets. Meaning should be a follow-up, out of scope for this bug.
Comment 6 Paul Derscheid 2025-09-09 09:57:46 UTC
For reference: https://rspack.rs/config/output#outputclean
Comment 7 Jonathan Druart 2025-09-09 10:05:38 UTC
Created attachment 186281 [details] [review]
Bug 40773: Do not map "vue/dist" files in Makefile

This change ensures that "vue/dist" files are not mapped into
the pm_to_blib target of the Makefile, so that they are only handled
by the explicit compile steps in the top targets of the Makefile.

Test plan:
0. Apply the patch
1. perl build-resources.PL
2. ls ./koha-tmpl/intranet-tmpl/prog/js/vue/dist
3. Note that files are present
4. perl Makefile.PL
5. Take all the defaults
6. vi Makefile
7. Search for vue\/dist
8. Note that the only hit is for "cp -r koha-tmpl/intranet-tmpl/prog/js/vue/dist
blib/INTRANET_TMPL_DIR/prog/js/vue/"

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 David Cook 2025-09-09 23:04:48 UTC
(In reply to Paul Derscheid from comment #5)
> Btw, there's a webpack/rspack option:
> output: {
>   ...
>   clean: true,
> }
> that does exactly that.
> 
> But we should probably work on the structure beforehand.
> This should be configured for prod, not for dev where you might want to keep
> old assets. Meaning should be a follow-up, out of scope for this bug.

I had a feeling that you'd know what to do!