-
Notifications
You must be signed in to change notification settings - Fork 99
Position of import.meta.glob causes error #944
Copy link
Copy link
Open
Labels
- P2: has workaroundBug, but has workaround (priority)Bug, but has workaround (priority)
Description
Astro Info
Astro v4.2.1
Node v20.9.0
System macOS (x64)
Package Manager npm
Output static
Adapter none
Integrations @astrojs/mdx
@astrojs/sitemap
@astrojs/tailwind
@astrojs/react
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
with the following frontmatter astro throws an error that i is not defined.
---
import type { ImageMetadata } from 'astro';
import Layout from '../layouts/FullWidth.astro';
import Section from '../components/page/Section.astro';
import StaffMember from '../components/page/StaffMember.astro';
import { Image } from 'astro:assets';
const images = import.meta.glob<{ default: ImageMetadata }>('/src/images/pillar-contact/*.svg');
import { staff } from '../data/staff';
---
astro compiles to
import {
Fragment,
render as $$render,
createAstro as $$createAstro,
createComponent as $$createComponent,
renderComponent as $$renderComponent,
renderHead as $$renderHead,
maybeRenderHead as $$maybeRenderHead,
unescapeHTML as $$unescapeHTML,
renderSlot as $$renderSlot,
mergeSlots as $$mergeSlots,
addAttribute as $$addAttribute,
spreadAttributes as $$spreadAttributes,
defineStyleVars as $$defineStyleVars,
defineScriptVars as $$defineScriptVars,
createMetadata as $$createMetadata
} from "astro/runtime/server/index.js";
import type { ImageMetadata } from 'astro';
import Layout from '../layouts/FullWidth.astro';
import Section from '../components/page/Section.astro';
import StaffMember from '../components/page/StaffMember.astro';
import { Image } from 'astro:assets';
import { staff } from '../data/staff';
import * as $$module1 from '../layouts/FullWidth.astro';
import * as $$module2 from '../components/page/Section.astro';
import * as $$module3 from '../components/page/StaffMember.astro';
import * as $$module4 from 'astro:assets';
import * as $$module5 from '../data/staff';
export const $$metadata = $$createMetadata("Card.astro", { modules: [{ module: $$module1, specifier: '../layouts/FullWidth.astro', assert: {} }, { module: $$module2, specifier: '../components/page/Section.astro', assert: {} }, { module: $$module3, specifier: '../components/page/StaffMember.astro', assert: {} }, { module: $$module4, specifier: 'astro:assets', assert: {} }, { module: $$module5, specifier: '../data/staff', assert: {} }], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
const $$Astro = $$createAstro();
const Astro = $$Astro;
const $$Card = $$createComponent(async ($$result, $$props, $$slots) => {
const Astro = $$result.createAstro($$Astro, $$props, $$slots);
Astro.self = $$Card;
const images = import.meta.glob<{ default: ImageMetadata }>('/src/images/pillar-contact/*.svg');
i
return $$render`wediowqed`;
}, 'Card.astro');
export default $$Card;
If i move the import above, the error goes away.
What's the expected result?
it should work no matter the order
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: has workaroundBug, but has workaround (priority)Bug, but has workaround (priority)