Sequence control when merging files?

In the past, it has been used normally, and the js files can be merged in the order of 1 2 3 as expected, but not in the expected order, resulting in some errors (the method is not initialized).

Specifically starting from the last few versions, I am not sure whether it is caused by version updates. I have tested several versions and there is no answer.

In the previous normal expectation, the merging order was that the files in the relevant directories were loaded in alphabetical order, with the root directory being merged first, followed by the js files in the secondary folders being merged in alphabetical order of the file names.

This is not the order now, so the common.js file in the root directory, which should have the highest priority, is not at the beginning of the merged file.

Please tell me how to control the order of file merging through explicit code when merging files?

182010d6513958719f259e347ddf04d


{{- $commonJs := partial "functions/concat" (dict "concatPath" "static/js/common/**.js" "targetPath" "static/js/common.bundle.js") }}
<script src="{{ $commonJs }}"></script>
{{/* https://gohugo.io/hugo-pipes/bundling/ */}}

{{ $concatPath := .concatPath }}
{{ $targetPath := .targetPath }}

{{ $bundle := resources.Match $concatPath | resources.Concat $targetPath }}

{{ if hugo.IsProduction }}
    {{ $bundle = $bundle | resources.Minify }}
{{ end }}

{{ return ($bundle.Permalink | relURL) }}

I have read the following documents and there is no introduction to controlling sorting.

In the following document, what is the order of $plugins and $global in the merged file?

Is it fixed?

{{ $plugins := resources.Get "js/plugins.js" }}
{{ $global := resources.Get "js/global.js" }}
{{ $js := slice $plugins $global | resources.Concat "js/bundle.js" }}

The current temporary method is to rename the common.js file to the number 0.js and then move it to the concat directory. The order is normal and no errors are reported for the time being.

Although this method can solve the current merge order problem when merging files, obviously this naming rule is not worth recommending.

Still hoping for help on how to explicitly control the priority of multiple matching files when merging.