From 3038d33ffac1b26638f11bec3dff74d2a68ca27b Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 22 Sep 2025 17:08:12 +0200 Subject: [PATCH 01/11] feat: e2e --- packages/astro/e2e/errors.test.js | 12 ---- .../src/components/AstroGlobOutsideAstro.js | 3 - .../src/pages/astro-glob-no-match.astro | 3 - .../src/pages/astro-glob-outside-astro.astro | 5 -- packages/astro/src/core/create-vite.ts | 2 - .../vite-plugin-astro-postprocess/README.md | 3 - .../vite-plugin-astro-postprocess/index.ts | 65 ------------------- 7 files changed, 93 deletions(-) delete mode 100644 packages/astro/e2e/fixtures/errors/src/components/AstroGlobOutsideAstro.js delete mode 100644 packages/astro/e2e/fixtures/errors/src/pages/astro-glob-no-match.astro delete mode 100644 packages/astro/e2e/fixtures/errors/src/pages/astro-glob-outside-astro.astro delete mode 100644 packages/astro/src/vite-plugin-astro-postprocess/README.md delete mode 100644 packages/astro/src/vite-plugin-astro-postprocess/index.ts diff --git a/packages/astro/e2e/errors.test.js b/packages/astro/e2e/errors.test.js index f64a22b5cfc9..85edc09ae960 100644 --- a/packages/astro/e2e/errors.test.js +++ b/packages/astro/e2e/errors.test.js @@ -117,18 +117,6 @@ test.describe('Error display', () => { expect(await page.locator('vite-error-overlay').count()).toEqual(0); }); - test('astro glob no match error', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/astro-glob-no-match'), { waitUntil: 'networkidle' }); - const message = (await getErrorOverlayContent(page)).message; - expect(message).toMatch('did not return any matching files'); - }); - - test('astro glob used outside of an astro file', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/astro-glob-outside-astro'), { waitUntil: 'networkidle' }); - const message = (await getErrorOverlayContent(page)).message; - expect(message).toMatch('can only be used in'); - }); - test('can handle DomException errors', async ({ page, astro }) => { await page.goto(astro.resolveUrl('/dom-exception'), { waitUntil: 'networkidle' }); const message = (await getErrorOverlayContent(page)).message; diff --git a/packages/astro/e2e/fixtures/errors/src/components/AstroGlobOutsideAstro.js b/packages/astro/e2e/fixtures/errors/src/components/AstroGlobOutsideAstro.js deleted file mode 100644 index 5307474c035a..000000000000 --- a/packages/astro/e2e/fixtures/errors/src/components/AstroGlobOutsideAstro.js +++ /dev/null @@ -1,3 +0,0 @@ -export function globSomething(Astro) { - return Astro.glob('./*.lua') -} diff --git a/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-no-match.astro b/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-no-match.astro deleted file mode 100644 index a7739af5807f..000000000000 --- a/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-no-match.astro +++ /dev/null @@ -1,3 +0,0 @@ ---- -Astro.glob('./*.lua') ---- \ No newline at end of file diff --git a/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-outside-astro.astro b/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-outside-astro.astro deleted file mode 100644 index 328de56ecf25..000000000000 --- a/packages/astro/e2e/fixtures/errors/src/pages/astro-glob-outside-astro.astro +++ /dev/null @@ -1,5 +0,0 @@ ---- -import { globSomething } from '../components/AstroGlobOutsideAstro' - -globSomething(Astro) ---- \ No newline at end of file diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 6a8bbdacd0d5..eecbfa33070a 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -22,7 +22,6 @@ import astroDevToolbar from '../toolbar/vite-plugin-dev-toolbar.js'; import astroTransitions from '../transitions/vite-plugin-transitions.js'; import type { AstroSettings, RoutesList } from '../types/astro.js'; import astroVitePlugin from '../vite-plugin-astro/index.js'; -import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js'; import { vitePluginAstroServer } from '../vite-plugin-astro-server/index.js'; import configAliasVitePlugin from '../vite-plugin-config-alias/index.js'; import vitePluginFileURL from '../vite-plugin-fileurl/index.js'; @@ -158,7 +157,6 @@ export async function createVite( astroEnv({ settings, sync, envLoader }), markdownVitePlugin({ settings, logger }), htmlVitePlugin(), - astroPostprocessVitePlugin(), astroIntegrationsContainerPlugin({ settings, logger }), astroScriptsPageSSRPlugin({ settings }), astroHeadPlugin(), diff --git a/packages/astro/src/vite-plugin-astro-postprocess/README.md b/packages/astro/src/vite-plugin-astro-postprocess/README.md deleted file mode 100644 index f4cc5fd6cced..000000000000 --- a/packages/astro/src/vite-plugin-astro-postprocess/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# vite-plugin-astro-postprocess - -Adds last-minute transforms to `.astro` files diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts deleted file mode 100644 index 0e48d8a663ac..000000000000 --- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { parse } from 'acorn'; -import type { Node as ESTreeNode } from 'estree-walker'; -import { walk } from 'estree-walker'; -import MagicString from 'magic-string'; -import type { Plugin } from 'vite'; -import { isMarkdownFile } from '../core/util.js'; - -// Check for `Astro.glob()`. Be very forgiving of whitespace. False positives are okay. -const ASTRO_GLOB_REGEX = /Astro2?\s*\.\s*glob\s*\(/; - -export default function astro(): Plugin { - return { - name: 'astro:postprocess', - async transform(code, id) { - // Currently only supported in ".astro" and ".md" (or any alternative markdown file extension like `.markdown`) files - if (!id.endsWith('.astro') && !isMarkdownFile(id)) { - return null; - } - - // Optimization: Detect usage with a quick string match. - // Only perform the transform if this function is found - if (!ASTRO_GLOB_REGEX.test(code)) { - return null; - } - - let s: MagicString | undefined; - const ast = parse(code, { - ecmaVersion: 'latest', - sourceType: 'module', - }); - - walk(ast as ESTreeNode, { - enter(node: any) { - // Transform `Astro.glob("./pages/*.astro")` to `Astro.glob(import.meta.glob("./pages/*.astro"), () => "./pages/*.astro")` - // Also handle for `Astro2.glob()` - if ( - node.type === 'CallExpression' && - node.callee.type === 'MemberExpression' && - node.callee.property.name === 'glob' && - (node.callee.object.name === 'Astro' || node.callee.object.name === 'Astro2') && - node.arguments.length - ) { - const firstArgStart = node.arguments[0].start; - const firstArgEnd = node.arguments[0].end; - const lastArgEnd = node.arguments[node.arguments.length - 1].end; - const firstArg = code.slice(firstArgStart, firstArgEnd); - s ??= new MagicString(code); - s.overwrite( - firstArgStart, - lastArgEnd, - `import.meta.glob(${firstArg}), () => ${firstArg}`, - ); - } - }, - }); - - if (s) { - return { - code: s.toString(), - map: s.generateMap({ hires: 'boundary' }), - }; - } - }, - }; -} From 7adc7e240383036c7c58440ca31212f9bdbd235c Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 22 Sep 2025 17:21:14 +0200 Subject: [PATCH 02/11] feat: remove Astro.glob mentions --- packages/astro/src/core/errors/dev/vite.ts | 25 +---------- packages/astro/src/core/errors/errors-data.ts | 43 +------------------ .../astro/src/runtime/server/astro-global.ts | 30 ------------- packages/astro/src/types/public/context.ts | 22 ---------- packages/astro/test/astro-global.test.js | 6 +-- packages/astro/test/astro-scripts.test.js | 4 +- .../astro-global/src/pages/glob.astro | 2 +- .../src/pages/omit-markdown-extensions.astro | 2 +- .../astro-global/src/pages/posts/[page].astro | 2 +- .../src/pages/posts/[slug]/[page].astro | 2 +- .../pages/posts/named-root-page/[page].astro | 2 +- .../posts/optional-root-page/[...page].astro | 2 +- .../astro-scripts/src/pages/glob.astro | 2 +- .../src/pages/episodes/[...page].astro | 2 +- .../src/pages/posts/[slug].astro | 2 +- .../src/components/Footer.astro | 2 +- .../src/components/Navbar.astro | 2 +- .../static-build/src/pages/index.astro | 2 +- packages/astro/test/glob-pages-css.test.js | 2 +- packages/astro/test/static-build.test.js | 2 +- .../test/units/runtime/astro-global.test.js | 29 ------------- .../mdx-component/src/pages/glob.astro | 2 +- .../src/pages/[slug].astro | 2 +- .../mdx-infinite-loop/src/pages/index.astro | 2 +- .../fixtures/mdx-slots/src/pages/glob.astro | 2 +- 25 files changed, 25 insertions(+), 170 deletions(-) delete mode 100644 packages/astro/test/units/runtime/astro-global.test.js diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index b624fdad5d62..f2212dbd03bd 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -6,7 +6,7 @@ import type { ErrorPayload } from 'vite'; import type { SSRLoadedRenderer } from '../../../types/public/internal.js'; import type { ModuleLoader } from '../../module-loader/index.js'; import { AstroError, type ErrorWithMetadata } from '../errors.js'; -import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from '../errors-data.js'; +import { FailedToLoadModuleSSR, MdxIntegrationMissingError } from '../errors-data.js'; import { createSafeError } from '../utils.js'; import { getDocsForError, renderErrorMarkdown } from './utils.js'; @@ -76,29 +76,6 @@ export function enhanceViteSSRError({ stack: safeError.stack, }) as ErrorWithMetadata; } - - // Since Astro.glob is a wrapper around Vite's import.meta.glob, errors don't show accurate information, let's fix that - if (safeError.message.includes('Invalid glob')) { - const globPattern = /glob: "(.+)" \(/.exec(safeError.message)?.[1]; - - if (globPattern) { - safeError.message = InvalidGlob.message(globPattern); - safeError.name = 'InvalidGlob'; - safeError.title = InvalidGlob.title; - - const line = lns.findIndex((ln) => ln.includes(globPattern)); - - if (line !== -1) { - const column = lns[line]?.indexOf(globPattern); - - safeError.loc = { - file: path, - line: line + 1, - column, - }; - } - } - } } return safeError; diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index e8348355da46..19393f7af93e 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -926,34 +926,6 @@ export const LocalImageUsedWrongly = { hint: 'If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections). See https://docs.astro.build/en/guides/images/#src-required for more information on the `src` property.', } satisfies ErrorData; -/** - * @docs - * @see - * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob) - * @description - * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import) instead to achieve the same result. - */ -export const AstroGlobUsedOutside = { - name: 'AstroGlobUsedOutside', - title: 'Astro.glob() used outside of an Astro file.', - message: (globStr: string) => - `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`, - hint: "See Vite's documentation on `import.meta.glob` for more information: https://vite.dev/guide/features.html#glob-import", -} satisfies ErrorData; - -/** - * @docs - * @see - * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob) - * @description - * `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern. - */ -export const AstroGlobNoMatch = { - name: 'AstroGlobNoMatch', - title: 'Astro.glob() did not match any files.', - message: (globStr: string) => `\`Astro.glob(${globStr})\` did not return any matching files.`, - hint: 'Check the pattern for typos.', -} satisfies ErrorData; /** * @docs * @see @@ -1050,20 +1022,7 @@ export const FailedToLoadModuleSSR = { message: (importName: string) => `Could not import \`${importName}\`.`, hint: 'This is often caused by a typo in the import path. Please make sure the file exists.', } satisfies ErrorData; -/** - * @docs - * @see - * - [Glob Patterns](https://docs.astro.build/en/guides/imports/#glob-patterns) - * @description - * Astro encountered an invalid glob pattern. This is often caused by the glob pattern not being a valid file path. - */ -export const InvalidGlob = { - name: 'InvalidGlob', - title: 'Invalid glob pattern.', - message: (globPattern: string) => - `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`, - hint: 'See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns.', -} satisfies ErrorData; + /** * @docs * @description diff --git a/packages/astro/src/runtime/server/astro-global.ts b/packages/astro/src/runtime/server/astro-global.ts index ea211004abad..31f352805a13 100644 --- a/packages/astro/src/runtime/server/astro-global.ts +++ b/packages/astro/src/runtime/server/astro-global.ts @@ -1,41 +1,11 @@ import { ASTRO_VERSION } from '../../core/constants.js'; -import { AstroError, AstroErrorData } from '../../core/errors/index.js'; import type { AstroGlobalPartial } from '../../types/public/context.js'; -/** Create the Astro.glob() runtime function. */ -function createAstroGlobFn() { - const globHandler = (importMetaGlobResult: Record) => { - // This is created inside of the runtime so we don't have access to the Astro logger. - console.warn(`Astro.glob is deprecated and will be removed in a future major version of Astro. -Use import.meta.glob instead: https://vitejs.dev/guide/features.html#glob-import`); - - if (typeof importMetaGlobResult === 'string') { - throw new AstroError({ - ...AstroErrorData.AstroGlobUsedOutside, - message: AstroErrorData.AstroGlobUsedOutside.message(JSON.stringify(importMetaGlobResult)), - }); - } - let allEntries = [...Object.values(importMetaGlobResult)]; - if (allEntries.length === 0) { - throw new AstroError({ - ...AstroErrorData.AstroGlobNoMatch, - message: AstroErrorData.AstroGlobNoMatch.message(JSON.stringify(importMetaGlobResult)), - }); - } - // Map over the `import()` promises, calling to load them. - return Promise.all(allEntries.map((fn) => fn())); - }; - // Cast the return type because the argument that the user sees (string) is different from the argument - // that the runtime sees post-compiler (Record). - return globHandler as unknown as AstroGlobalPartial['glob']; -} - // This is used to create the top-level Astro global; the one that you can use // inside of getStaticPaths. See the `astroGlobalArgs` option for parameter type. export function createAstro(site: string | undefined): AstroGlobalPartial { return { site: site ? new URL(site) : undefined, generator: `Astro v${ASTRO_VERSION}`, - glob: createAstroGlobFn(), }; } diff --git a/packages/astro/src/types/public/context.ts b/packages/astro/src/types/public/context.ts index 46e1ce811068..bc5cdc0bf6a5 100644 --- a/packages/astro/src/types/public/context.ts +++ b/packages/astro/src/types/public/context.ts @@ -4,14 +4,12 @@ import type { ActionClient, ActionReturnType, } from '../../actions/runtime/virtual/server.js'; -import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../core/constants.js'; import type { AstroCookies } from '../../core/cookies/cookies.js'; import type { CspDirective, CspHash } from '../../core/csp/config.js'; import type { AstroSession } from '../../core/session.js'; import type { AstroComponentFactory } from '../../runtime/server/index.js'; import type { Params, RewritePayload } from './common.js'; import type { ValidRedirectStatus } from './config.js'; -import type { AstroInstance, MarkdownInstance, MDXInstance } from './content.js'; /** * Astro global available in all contexts in .astro files @@ -208,27 +206,7 @@ export interface AstroGlobal< }; } -/** Union type of supported markdown file extensions */ -type MarkdownFileExtension = (typeof SUPPORTED_MARKDOWN_FILE_EXTENSIONS)[number]; - export interface AstroGlobalPartial { - /** - * Fetch local files into your static site setup - * - * Example usage: - * ```typescript - * const posts = await Astro.glob('../pages/post/*.md'); - * ``` - * - * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob) - * @deprecated Astro.glob is deprecated and will be removed in the next major version of Astro. Use `import.meta.glob` instead: https://vitejs.dev/guide/features.html#glob-import - */ - glob(globStr: `${any}.astro`): Promise; - glob>( - globStr: `${any}${MarkdownFileExtension}`, - ): Promise[]>; - glob>(globStr: `${any}.mdx`): Promise[]>; - glob>(globStr: string): Promise; /** * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option * diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js index c996de4364b3..c8f8e2292537 100644 --- a/packages/astro/test/astro-global.test.js +++ b/packages/astro/test/astro-global.test.js @@ -38,7 +38,7 @@ describe('Astro Global', () => { assert.equal($('#nested-child-pathname').text(), '/blog/'); }); - it('Astro.glob() returned `url` metadata of each markdown file extensions DOES NOT include the extension', async () => { + it('import.meta.glob() returned `url` metadata of each markdown file extensions DOES NOT include the extension', async () => { const html = await fixture.fetch('/blog/omit-markdown-extensions/').then((res) => res.text()); const $ = cheerio.load(html); assert.equal( @@ -90,13 +90,13 @@ describe('Astro Global', () => { assert.equal($('#site').attr('href'), 'https://mysite.dev/subsite/'); }); - it('Astro.glob() correctly returns an array of all posts', async () => { + it('import.meta.glob() correctly returns an array of all posts', async () => { const html = await fixture.readFile('/posts/1/index.html'); const $ = cheerio.load(html); assert.equal($('.post-url').attr('href'), '/blog/post/post-2'); }); - it('Astro.glob() correctly returns meta info for MD and Astro files', async () => { + it('import.meta.glob() correctly returns meta info for MD and Astro files', async () => { const html = await fixture.readFile('/glob/index.html'); const $ = cheerio.load(html); assert.equal($('[data-file]').length, 8); diff --git a/packages/astro/test/astro-scripts.test.js b/packages/astro/test/astro-scripts.test.js index 528a147cbf17..ed7b849ae701 100644 --- a/packages/astro/test/astro-scripts.test.js +++ b/packages/astro/test/astro-scripts.test.js @@ -58,7 +58,7 @@ describe('Scripts', () => { assert.equal(entryURL.includes('_astro/'), true); }); - it('Scripts added via Astro.glob are hoisted', async () => { + it('Scripts added via import.meta.glob are hoisted', async () => { let glob = await fixture.readFile('/glob/index.html'); let $ = cheerio.load(glob); @@ -131,7 +131,7 @@ describe('Scripts', () => { await devServer.stop(); }); - it('Scripts added via Astro.glob are hoisted', async () => { + it('Scripts added via import.meta.glob are hoisted', async () => { let res = await fixture.fetch('/glob'); let html = await res.text(); let $ = cheerio.load(html); diff --git a/packages/astro/test/fixtures/astro-global/src/pages/glob.astro b/packages/astro/test/fixtures/astro-global/src/pages/glob.astro index c25d3733dca9..85a371881ac4 100644 --- a/packages/astro/test/fixtures/astro-global/src/pages/glob.astro +++ b/packages/astro/test/fixtures/astro-global/src/pages/glob.astro @@ -1,5 +1,5 @@ --- -const data = await Astro.glob('./post/**/*'); +const data = Object.values(import.meta.glob('./post/**/*', { eager: true })); --- diff --git a/packages/astro/test/fixtures/astro-global/src/pages/omit-markdown-extensions.astro b/packages/astro/test/fixtures/astro-global/src/pages/omit-markdown-extensions.astro index 68101d447d60..794683a2ac39 100644 --- a/packages/astro/test/fixtures/astro-global/src/pages/omit-markdown-extensions.astro +++ b/packages/astro/test/fixtures/astro-global/src/pages/omit-markdown-extensions.astro @@ -1,7 +1,7 @@ --- import Route from "../components/Route.astro"; -const markdownPosts = await Astro.glob('./post/**/*.{markdown,mdown,mkdn,mkd,mdwn,md}'); +const markdownPosts = Object.values(import.meta.glob('./post/**/*.{markdown,mdown,mkdn,mkd,mdwn,md}', { eager: true })); const markdownExtensions = /(\.(markdown|mdown|mkdn|mkd|mdwn|md))$/g const aUrlContainsExtension = markdownPosts.some((page:any)=> { return markdownExtensions.test(page.url) diff --git a/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro b/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro index 7bdaa3b364d7..deefd1a61e24 100644 --- a/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro +++ b/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro @@ -2,7 +2,7 @@ import Route from "../../components/Route.astro"; export async function getStaticPaths({paginate}) { - const data = await Astro.glob('../post/*.md'); + const data = Object.values(import.meta.glob('../post/*.md', { eager: true })); return paginate(data, {pageSize: 1}); } const { page } = Astro.props; diff --git a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/[slug]/[page].astro b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/[slug]/[page].astro index 33df98cf598c..ea824e7053be 100644 --- a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/[slug]/[page].astro +++ b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/[slug]/[page].astro @@ -1,6 +1,6 @@ --- export async function getStaticPaths({paginate}) { - const allPosts = await Astro.glob('../../post/*.md'); + const allPosts = Object.values(import.meta.glob('../../post/*.md', { eager: true })); return ['red', 'blue'].flatMap((filter) => { const filteredPosts = allPosts.filter((post) => post.frontmatter.tag === filter); return paginate(filteredPosts, { diff --git a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/named-root-page/[page].astro b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/named-root-page/[page].astro index c908f1c431f5..ff0a5f202eaf 100644 --- a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/named-root-page/[page].astro +++ b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/named-root-page/[page].astro @@ -1,6 +1,6 @@ --- export async function getStaticPaths({paginate}) { - const data = await Astro.glob('../../post/*.md'); + const data = Object.values(import.meta.glob('../../post/*.md', { eager: true })); return paginate(data, {pageSize: 1}); } const canonicalURL = new URL(Astro.url.pathname, Astro.site); diff --git a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/optional-root-page/[...page].astro b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/optional-root-page/[...page].astro index c908f1c431f5..ff0a5f202eaf 100644 --- a/packages/astro/test/fixtures/astro-pagination/src/pages/posts/optional-root-page/[...page].astro +++ b/packages/astro/test/fixtures/astro-pagination/src/pages/posts/optional-root-page/[...page].astro @@ -1,6 +1,6 @@ --- export async function getStaticPaths({paginate}) { - const data = await Astro.glob('../../post/*.md'); + const data = Object.values(import.meta.glob('../../post/*.md', { eager: true })); return paginate(data, {pageSize: 1}); } const canonicalURL = new URL(Astro.url.pathname, Astro.site); diff --git a/packages/astro/test/fixtures/astro-scripts/src/pages/glob.astro b/packages/astro/test/fixtures/astro-scripts/src/pages/glob.astro index cb5124da6085..c18131b85875 100644 --- a/packages/astro/test/fixtures/astro-scripts/src/pages/glob.astro +++ b/packages/astro/test/fixtures/astro-scripts/src/pages/glob.astro @@ -1,6 +1,6 @@ --- import '../styles/global.css'; -const components = await Astro.glob('/src/components/Glob/*'); +const components = Object.values(import.meta.glob('/src/components/Glob/*', { eager: true })); const MyComponent = components[0].default; --- diff --git a/packages/astro/test/fixtures/astro-sitemap-rss/src/pages/episodes/[...page].astro b/packages/astro/test/fixtures/astro-sitemap-rss/src/pages/episodes/[...page].astro index 3732c4ba31b0..93366b73e378 100644 --- a/packages/astro/test/fixtures/astro-sitemap-rss/src/pages/episodes/[...page].astro +++ b/packages/astro/test/fixtures/astro-sitemap-rss/src/pages/episodes/[...page].astro @@ -1,6 +1,6 @@ --- export async function getStaticPaths({paginate, rss}) { - const episodes = (await Astro.glob('../episode/*.md')).sort((a, b) => new Date(b.frontmatter.pubDate) - new Date(a.frontmatter.pubDate)); + const episodes = Object.values(import.meta.glob('../episode/*.md', { eager: true })).sort((a, b) => new Date(b.frontmatter.pubDate) - new Date(a.frontmatter.pubDate)); rss({ title: 'MF Doomcast', description: 'The podcast about the things you find on a picnic, or at a picnic table', diff --git a/packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro b/packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro index ed85be913b6b..fc0a6f351ba1 100644 --- a/packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro +++ b/packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro @@ -3,7 +3,7 @@ import Debug from 'astro/debug'; // all the content that should be generated export async function getStaticPaths() { - const data = await Astro.glob('../../data/posts/*.md') + const data = Object.values(import.meta.glob('../../data/posts/*.md', { eager: true })); const allArticles = data.map((article) => { return { diff --git a/packages/astro/test/fixtures/glob-pages-css/src/components/Footer.astro b/packages/astro/test/fixtures/glob-pages-css/src/components/Footer.astro index 32d8844f24be..2cbc2fbd2f42 100644 --- a/packages/astro/test/fixtures/glob-pages-css/src/components/Footer.astro +++ b/packages/astro/test/fixtures/glob-pages-css/src/components/Footer.astro @@ -1,6 +1,6 @@ --- // The side-effect of this happening is needed for the test. -await Astro.glob("../pages/**/*.astro"); +Object.values(import.meta.glob("../pages/**/*.astro", { eager: true })); ---