Skip to content

[Bug]: Vite - unable to build the app with shouldAnalyze={true} #333

@noxify

Description

@noxify

Description

While running the vite build command in a plain vite setup ( with plugin-rsc ), I get an error from the CodeBlock, because it can't format/analyze the code.

Steps to Reproduce

I have tested it with node@22.19.0.

git clone git@github.com:noxify/vite-rsc-ssg-renoun.git
cd vite-rsc-ssg-renoun
pnpm i
pnpm build

Expected Behavior

The build finishs ( hopefully ) without errors and calling pnpm preview shows you the static build.

Actual Behavior

Getting the following error:

Error: [renoun] Error trying to create CodeBlock source file at working directory "<project-dir>/vite-rsc-ssg-renoun"
    at getSourceTextMetadata (file://<project-dir>/vite-rsc-ssg-renoun/dist/rsc/assets/get-source-text-metadata-egTqduFb.js:166:15)
    at async Tokens (file://<project-dir>/vite-rsc-ssg-renoun/dist/rsc/index.js:62210:20) {
  [cause]: Error: Could not find source file: '<project-dir>/vite-rsc-ssg-renoun/_renoun/585b7724.jsx'.
      at getValidSourceFile (<project-dir>/vite-rsc-ssg-renoun/node_modules/.pnpm/@ts-morph+common@0.28.1/node_modules/@ts-morph/common/dist/typescript.js:152726:22)
      at Object.getCombinedCodeFix (<project-dir>/vite-rsc-ssg-renoun/node_modules/.pnpm/@ts-morph+common@0.28.1/node_modules/@ts-morph/common/dist/typescript.js:153478:24)
      at LanguageService.getCombinedCodeFix (<project-dir>/vite-rsc-ssg-renoun/node_modules/.pnpm/ts-morph@27.0.2/node_modules/ts-morph/dist/ts-morph.js:18433:52)
      at SourceFile.fixMissingImports (<project-dir>/vite-rsc-ssg-renoun/node_modules/.pnpm/ts-morph@27.0.2/node_modules/ts-morph/dist/ts-morph.js:13844:67)
      at getSourceTextMetadata (file://<project-dir>/vite-rsc-ssg-renoun/dist/rsc/assets/get-source-text-metadata-egTqduFb.js:150:20)
      at async Tokens (file://<project-dir>/vite-rsc-ssg-renoun/dist/rsc/index.js:62210:20) {

Environment

  • renoun version: 10.5.4
  • Node version: 22.19.0

Additional Context

The repro is based on:

Workaround

I have tested the following configuration in the mdx-components.tsx:

    CodeBlock: (props) => <CodeBlock {...props} shouldAnalyze={false} />,

This seems to solve the build problem, I only had to configure the available languages in the RootProvider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions