Globbing imports removes an index file that had to be maintained by hand, and it ties the code to one bundler.
// lazy: each value is a function returning a promise
const modules = import.meta.glob('./routes/*.js')
const routes = Object.entries(modules).map(([path, load]) => ({
path: '/' + path.match(/./routes/(.*).js$/)[1],
component: load,
}))
// eager, if the modules are small and always needed
const all = import.meta.glob('./icons/*.svg', { eager: true })
The lazy form code-splits per entry with no configuration, which is most of the value. Deriving a route path from a filename makes renaming a file a routing change, and that deserves a comment — it is the kind of coupling that is obvious to whoever wrote it and invisible in a code review.