diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts index 68cee31a7c..a89aa10f07 100644 --- a/packages/astro/src/core/build/pipeline.ts +++ b/packages/astro/src/core/build/pipeline.ts @@ -16,8 +16,8 @@ import { mergeInlineCss, } from './internal.js'; import { ASTRO_PAGE_MODULE_ID, ASTRO_PAGE_RESOLVED_MODULE_ID } from './plugins/plugin-pages.js'; -import { getVirtualModulePageNameFromPath } from './plugins/util.js'; import { RESOLVED_SPLIT_MODULE_ID } from './plugins/plugin-ssr.js'; +import { getVirtualModulePageNameFromPath } from './plugins/util.js'; import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from './plugins/util.js'; import type { PageBuildData, StaticBuildOptions } from './types.js'; import { i18nHasFallback } from './util.js'; diff --git a/packages/astro/src/core/build/plugins/util.ts b/packages/astro/src/core/build/plugins/util.ts index e205f75ebd..0c9636b307 100644 --- a/packages/astro/src/core/build/plugins/util.ts +++ b/packages/astro/src/core/build/plugins/util.ts @@ -45,7 +45,7 @@ export const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@'; /** * Prevents Rollup from triggering other plugins in the process by masking the extension (hence the virtual file). - * + * * 1. We add a fixed prefix, which is used as virtual module naming convention * 2. If the path has an extension (at the end of the path), we replace the dot that belongs to the extension with an arbitrary string. * @@ -54,10 +54,12 @@ export const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@'; */ export function getVirtualModulePageNameFromPath(virtualModulePrefix: string, path: string) { const extension = extname(path); - return virtualModulePrefix + + return ( + virtualModulePrefix + (extension.startsWith('.') ? path.slice(0, -extension.length) + extension.replace('.', ASTRO_PAGE_EXTENSION_POST_PATTERN) - : path); + : path) + ); } /** diff --git a/packages/astro/test/ssr-dynamic.test.js b/packages/astro/test/ssr-dynamic.test.js index 6016f5fbde..4cf0bcd5a6 100644 --- a/packages/astro/test/ssr-dynamic.test.js +++ b/packages/astro/test/ssr-dynamic.test.js @@ -1,11 +1,11 @@ import assert from 'node:assert/strict'; +import { mkdirSync, writeFileSync } from 'node:fs'; +import { dirname } from 'node:path'; import { before, describe, it } from 'node:test'; +import { fileURLToPath } from 'node:url'; import { load as cheerioLoad } from 'cheerio'; import testAdapter from './test-adapter.js'; import { loadFixture } from './test-utils.js'; -import { dirname } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { mkdirSync, writeFileSync } from 'node:fs'; describe('Dynamic pages in SSR', () => { /** @type {import('./test-utils').Fixture} */ @@ -29,7 +29,7 @@ describe('Dynamic pages in SSR', () => { const entrypoint = fileURLToPath( new URL(`${root}.astro/test.astro`, import.meta.url) ); - console.log(entrypoint) + console.log(entrypoint); mkdirSync(dirname(entrypoint), { recursive: true }); writeFileSync(entrypoint, '

Index

');