We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
astro
1.0.0-beta.63
None
npm
Mac
After setting up aliases in tsconfig.js I was expecting these to be available to Astro.glob() as well:
Astro.glob()
{ "compilerOptions": { "baseUrl": ".", "paths": { "@components/*": [ "src/components/*" ], "@layouts/*": [ "src/layouts/*" ], "@assets/*": [ "src/assets/*" ], } } }
import { Debug } from 'astro/components'; import Layout from '@layouts/Layout.astro'; import Card from '@components/Card.astro'; // Works: // const components = await Astro.glob('../components/*.astro'); // Fails const components = await Astro.glob('@components/*.astro');
A workaround in astro.config.mjs - which is what I expected to be done automatically under the hood:
// https://astro.build/config export default defineConfig({ integrations: [], vite: { resolve: { alias: { '@components': path.resolve('./src/components/') } } } });
See /src/pages/index.astro in the Sandbox below.
https://codesandbox.io/s/flamboyant-parm-hmhud7
The text was updated successfully, but these errors were encountered:
Even with the Vite resolve alias workaround, building for production fails:
[vite:build-import-analysis] Invalid glob import syntax: pattern must start with "." or "/" (relative to project root) or alias path
Sorry, something went wrong.
Hmm, this does look like an Astro-specific issue. :(
We are automatically setting vite.resolve.alias but Astro.glob doesn't seem to be passing these through to import.meta.glob properly.
vite.resolve.alias
Astro.glob
import.meta.glob
See plain Vite repro (it works) https://stackblitz.com/edit/vitejs-vite-mktopt?file=vite.config.ts,main.js&terminal=dev
FYI The workaround in this issue was working previously, but I believe that the fix from #3933 broke the workaround.
I can't seem to use Astro.glob with a monorepo at all anymore.
matthewp
Successfully merging a pull request may close this issue.
What version of
astro
are you using?1.0.0-beta.63
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
After setting up aliases in tsconfig.js I was expecting these to be available to
Astro.glob()
as well:A workaround in astro.config.mjs - which is what I expected to be done automatically under the hood:
See /src/pages/index.astro in the Sandbox below.
Link to Minimal Reproducible Example
https://codesandbox.io/s/flamboyant-parm-hmhud7
Participation
The text was updated successfully, but these errors were encountered: