Closed felixsanz closed 2 years ago
I forgot to use ?raw
when reading text files, sorry!
Reopening because passing ?raw
to import.meta.glob
or import.meta.globEager
doesn't work, it returns an empty object.
const imports = import.meta.glob('../components/**/*.ftl')
console.log(imports)
/*
{
'../components/ui/About/en.ftl': [Function: ../components/ui/About/en.ftl],
'../components/ui/About/es.ftl': [Function: ../components/ui/About/es.ftl]
}
*/
const imports = import.meta.glob('../components/**/*.ftl?raw')
console.log(imports)
/*
{}
*/
So.. if using ?raw
, nothing is returned. If not using it,... obviously it crash.
?raw
works fine when used with import
, but not with glob/globEager
Hmm interesting, I wonder if there's still a Vite transformation happening here. Definitely a suspicious edge case in one of our Vite plugins.
This is intentional. Check https://github.com/vitejs/vite/issues/7017 for more info.
Provide the raw
query like this:
const modules = import.meta.glob('./dir/*.js', { as: 'raw' })
it works! thanks
Edited the issue because the problem was related, so feel free to ignore this message and jump directly to my third message.
What version of
astro
are you using?v1.0.0-beta.40
Are you using an SSR adapter? If so, which one?
No
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
import.meta.glob
works fine, but when usingimport.meta.globEager
i get this error:I created this test case but it doesn't work on codesandbox because
import.meta
doesn't work there, but it's a reproducible minimal example.Link to Minimal Reproducible Example
https://codesandbox.io/s/priceless-mayer-rhmb7c?file=/src/i18n.ts
Participation