withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.82k stars 2.41k forks source link

Build error when using `experimental.contentCollectionCache` with square brackets in file name. #9210

Open Tc-001 opened 10 months ago

Tc-001 commented 10 months ago

Astro Info

Astro                    v3.6.1
Node                     v18.17.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

Firefox

Describe the Bug

When building a site with experimental.contentCollectionCache, the builder will crash if there is [something] in square brackets in file or folder name.

Repro:

You should get an error:

16:05:32 [build] Building static entrypoints...
"[Test]" is not a valid placeholder in the "output.entryFileNames" pattern.
 error   "[Test]" is not a valid placeholder in the "output.entryFileNames" pattern.
  File:
    /home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:2287:30
  Code:
    2286 |     if (!(base instanceof Error)) {
    > 2287 |         base = Object.assign(new Error(base.message), base);
           |                              ^
      2288 |         Object.defineProperty(base, 'name', { value: 'RollupError' });
      2289 |     }
      2290 |     throw base;
  Stacktrace:
RollupError: "[Test]" is not a valid placeholder in the "output.entryFileNames" pattern.
    at error (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:15668:20
    at String.replace (<anonymous>)
    at renderNamePattern (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:15666:20)
    at Chunk.getPreliminaryFileName (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:15965:24)
    at reserveEntryChunksInBundle (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:17695:19)
    at renderChunks (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:17681:5)
    at Bundle.generate (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:17922:19)
    at async file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:26785:27
    at async catchUnfinishedHookActions (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25910:16)
    at async Module.build (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/vite@4.5.0/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:48085:22)
    at async ssrBuild (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/core/build/static-build.js:208:10)
    at async viteBuild (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/core/build/static-build.js:57:21)
    at async AstroBuilder.build (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:133:27)
    at async AstroBuilder.run (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:165:7)
    at async build (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:44:3)
    at async build (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/cli/build/index.js:21:3)
    at async runCommand (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/cli/index.js:116:7)
    at async cli (file:///home/me/Documents/Projects/temp/stale-singularity/node_modules/.pnpm/astro@3.6.1_typescript@5.3.2/node_modules/astro/dist/cli/index.js:144:5)

 ELIFECYCLE  Command failed with exit code 1.

What's the expected result?

The site should build without issues

Link to Minimal Reproducible Example

https://git.t0.lv/Tc001/astro-contentCollectionCache-repro

Participation

natemoo-re commented 10 months ago

Ahh that's a good one that I wouldn't have caught! Thanks for filing. As soon as 4.0.0 is out the door I'll be back on fixes for this flagged behavior.