antfu / vite-plugin-glob

The design experiment for import.meta.glob from Vite.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supporting custom parameters

ElMassimo opened this issue · comments

The current proposal mentions support for a custom query.

I'm wondering if we could make that a bit more idiomatic for URLs that have custom parameters, such as in:

For example, as in this type of use case:

const images = import.meta.importGlob('./dir/*.jpg', { query: { preset: 'full' } })

/* {
  './dir/foo.jpg': () => import('./dir/foo.jpg?preset=full'),
  './dir/bar.jpg': () => import('./dir/bar.jpg?preset=full'),
} */

Yeah sounds like a good idea. Want to work on a PR for this?

The as syntax is to align https://github.com/tc39/proposal-import-reflection in the future (we might use it for static import in v3.0 instead of the query). But for now, I think query sounds like a more natural solution (we could throw an error ensure there is no as and query exist at the same time.

Working in it :P

Haha, you are too fast, I just woke up 😄

Thanks Anthony!