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

Lazy loaded React-Router reports sourcemap issue #11238

Closed
7 tasks done
swernerx opened this issue Dec 7, 2022 · 1 comment · Fixed by #13662
Closed
7 tasks done

Lazy loaded React-Router reports sourcemap issue #11238

swernerx opened this issue Dec 7, 2022 · 1 comment · Fixed by #13662

Comments

@swernerx
Copy link

swernerx commented Dec 7, 2022

Describe the bug

We are using generouted to build a routing setup (for react-router) based on file system layout (NextJS inspired). Interestingly, the whole setup using import.meta leads to a lazy loading of react-router. I am not sure why, as the RouterProvider is part of the initial import sequence.

The initial log files looks like:

VITE v3.2.5  ready in 248 ms

  ➜  Local:   http://127.0.0.1:5173/
  ➜  Network: use --host to expose
Sourcemap for "/Users/sebastian/Workspace/vite-react-router-bug/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/react-router-dom/dist/index.js" points to missing source files
Sourcemap for "/Users/sebastian/Workspace/vite-react-router-bug/node_modules/.pnpm/[email protected][email protected]/node_modules/react-router/dist/index.js" points to missing source files
10:15:45 [vite] ✨ new dependencies optimized: react-router-dom
10:15:45 [vite] ✨ optimized dependencies changed. reloading

This all happens on directly on the start of the server and leads to some unwanted side-effects (in our larger app) as it seems. When restarting the dev-server the warning is gone and the application works fine.

This is the relevant import-related code in generouted

We have also tried the following to work-around the issue:

import { Link } from 'react-router-dom';
Link;

This added to the root-level App.tsx fixes the issue. No warning. No application bug.

Reproduction

https://github.com/swernerx/vite-react-router-bug

Steps to reproduce

  • pnpm install
  • npm run dev

System Info

System:
    OS: macOS 13.0.1
    CPU: (20) arm64 Apple M1 Ultra
    Memory: 1.02 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - /opt/homebrew/opt/node@16/bin/node
    Yarn: 1.22.19 - /opt/homebrew/opt/node@16/bin/yarn
    npm: 8.19.2 - /opt/homebrew/opt/node@16/bin/npm
  Browsers:
    Chrome: 108.0.5359.94
    Firefox: 106.0.5
    Safari: 16.1
  npmPackages:
    @vitejs/plugin-react: ^2.2.0 => 2.2.0
    vite: ^3.2.3 => 3.2.5

Used Package Manager

pnpm

Logs

No response

Validations

@swernerx
Copy link
Author

swernerx commented Dec 7, 2022

Same issue with 4.0.0-beta.2:

image

@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant