Open cworld1 opened 3 days ago
Hello @cworld1. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
Well! Here's the minimal reproduction: https://github.com/cworld1/astro-blog-test/tree/utils (Main branch is about another issue)
Error: The "astro:content" module is only available server-side.
Error info on AstroError:
at generateContentEntryFile (file:///D:/code/test/astro-blog-test/node_modules/.pnpm/astro@5.0.3_rollup@4.28.0_typescript@5.7.2/node_modules/astro/dist/content/vite-plugin-content-virtual-mod.js:195:11)
at LoadPluginContext.load (file:///D:/code/test/astro-blog-test/node_modules/.pnpm/astro@5.0.3_rollup@4.28.0_typescript@5.7.2/node_modules/astro/dist/content/vite-plugin-content-virtual-mod.js:91:28)
at EnvironmentPluginContainer.load (file:///D:/code/test/astro-blog-test/node_modules/.pnpm/vite@6.0.3/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:46974:17)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async loadAndTransform (file:///D:/code/test/astro-blog-test/node_modules/.pnpm/vite@6.0.3/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:40786:22)
at async viteTransformMiddleware (file:///D:/code/test/astro-blog-test/node_modules/.pnpm/vite@6.0.3/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:42296:24)
Error info on build (currently on Vercel, and locally deploy is the same):
Running "pnpm run build"
> astro-blog-test@0.0.1 build /vercel/path0
> astro build
08:19:30 [content] Syncing content
08:19:30 [content] Synced content
08:19:30 [types] Generated 632ms
08:19:30 [build] output: "server"
08:19:30 [build] directory: /vercel/path0/dist/
08:19:30 [build] adapter: @astrojs/vercel
08:19:30 [build] Collecting build info...
08:19:30 [build] ✓ Completed in 665ms.
08:19:30 [build] Building server entrypoints...
08:19:32 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/blog/[...slug].astro. Add `export const prerender = true;` to prerender the page as static HTML during the build process.
08:19:33 [vite] ✓ built in 3.52s
08:19:33 [build] ✓ Completed in 3.56s.
building client (vite)
08:19:34 [vite] transforming...
08:19:34 [vite] ✓ 2 modules transformed.
08:19:34 [ERROR] [vite] x Build failed in 28ms
[ServerOnlyModule] [astro-content-virtual-mod-plugin] Could not load
Error reference:
https://docs.astro.build/en/reference/errors/server-only-module/
Stack trace:
at generateContentEntryFile (file:///vercel/path0/node_modules/.pnpm/astro@5.0.3_rollup@4.28.0_typescript@5.7.2/node_modules/astro/dist/content/vite-plugin-content-virtual-mod.js:195:11)
at Object.handler (file:///vercel/path0/node_modules/.pnpm/vite@6.0.3/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:50826:15)
at async PluginDriver.hookFirstAndGetPlugin (file:///vercel/path0/node_modules/.pnpm/rollup@4.28.0/node_modules/rollup/dist/es/shared/node-entry.js:20712:28)
at async Queue.work (file:///vercel/path0/node_modules/.pnpm/rollup@4.28.0/node_modules/rollup/dist/es/shared/node-entry.js:20922:32)
ELIFECYCLE Command failed with exit code 1.
Error: Command "pnpm run build" exited with 1
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Firefox
Describe the Bug
For file
src/utils.ts
but when component S inserted in dynamic server page P, astro seems cannot split out scripts and shows warnings.
What's the expected result?
When component S inserted in dynamic server page P, astro can work well.
Link to Minimal Reproducible Example
https://github.com/cworld1/astro-blog-test/tree/utils
Participation