Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssr: false: build script creates a server bundle and deletes it #12641

Open
Hawmex opened this issue Dec 25, 2024 · 2 comments
Open

ssr: false: build script creates a server bundle and deletes it #12641

Hawmex opened this issue Dec 25, 2024 · 2 comments
Labels

Comments

@Hawmex
Copy link

Hawmex commented Dec 25, 2024

I'm using React Router as a...

framework

Reproduction

Prior to v7, we used v6 and component routes. After upgrading to v7 as a framework and setting ssr: false, we faced some problems including:

  • @mui/icons-material imports started to fail. So we added this to vite.config.ts:
    ...
    resolve: {
      alias: {
        '@mui/icons-material': '@mui/icons-material/esm'
      }
    }
    ...
    
  • the build script started to fail. The client bundle would be created with no errors. However, the build script would try to create a server bundle and face import resolution errors with @mui/utils (this is used in @mui packages' internals).
    We currently have solved this issue by using the current vite.config.ts:
    ...
    ssr: {
      noExternal: command === 'build' ? true : [],
    }
    ...
    
    The interesting thing is that with the current setting, the server bundle will be created successfully and then it gets deleted. What is the reason to this?
  • We also have problems using client side components in ErrorBoundary when facing 404 error. It complains about the unavailability of browser globals such as local storage. I had assumed that upgrading to v7 and using the SPA mode would be seamless. I have set SSR to false and yet I am facing problems here and there regarding SSR in the prod and dev environments.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 5.96 GB / 15.78 GB
  Binaries:
    Node: 22.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.15.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.86)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @react-router/dev: ^7.0.2 => 7.0.2
    @react-router/fs-routes: ^7.0.2 => 7.0.2
    @react-router/node: ^7.0.2 => 7.0.2
    @react-router/serve: ^7.0.2 => 7.0.2
    react-router: ^7.0.2 => 7.0.2
    vite: ^5.4.11 => 5.4.11

Used Package Manager

pnpm

Expected Behavior

Having a complete client-side router that gives us the option of using file-based routing, in case ssr: false.

Actual Behavior

Server bundle generation during build, and import resolution errors that didn't exist with v6.

@Hawmex Hawmex added the bug label Dec 25, 2024
@khatabakhsh
Copy link

I have this issue, too!

@pfe-nazaries
Copy link

pfe-nazaries commented Jan 3, 2025

Im facing something similar with rxjs and ant design where the SSR build (sometimes in dev mode too) cannot find some modules

[vite] Internal server error: Cannot find module '/Users/pfe/WebstormProjects/rtr-admin/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/rc-util/es/omit' imported from /Users/pfe/WebstormProjects/rtr-admin/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/antd/es/layout/layout.js
[VITE] Did you mean to import "rc-util/es/omit.js"?

And i not using ssr at all, just spa mode (ssr:false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants