-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed as not planned
Labels
Description
I'm using React Router as a...
framework
Reproduction
- Go to https://stackblitz.com/edit/stackblitz-starters-6zkc9f?file=react-router.config.ts
- If dev server starts automatically, stop the dev server
- Run
pnpm run build-> build/client/index.html is generated as part of build because ofssr: false - Enable serverModuleFormat: "cjs" in react-router.config.ts
(because even though the server build is deleted after running the build in ssr: false, ssr is used for initial prerendering and some third party libraries don't have good esm support) - Run
pnpm run buildagain -> Error:[react-router] exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '/home/projects/stackblitz-starters-6zkc9f/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
- Rename react router config to
react-router.config.cjs - Run
pnpm run buildagain
System Info
See stackblitz environmentUsed Package Manager
pnpm
Expected Behavior
When config contains ssr: false and serverModuleFormat: "cjs", the build does not fail and renders static html.
Actual Behavior
Error instructs to rename config to react-router.config.cjs but .cjs file is ignored and default config is being used -> ssr: true.